Action

Insert Conference Photo

Posted by sylumer, Last update 13 days ago - Unlisted

Insert a Markdown link for the last photo taken with the conference shortcut.

Details are retrieved from Airtable.

Steps

  • includeAction

    name
    TAD
  • script

    // Initialise
    const BASEID = "appYfCcGSmGO1BzLS"
    const TABLE = "Image"
    
    // Get image link from Airtable
    let at = new Airtable()
    let recImage = at.listRecords(BASEID, TABLE);
    
    // No records
    if(recImage.records.length == 0) app.displayWarningMessage("No image data available");
    
    // One record
    if(recImage.records.length == 1)
    {
    	// Insert the link
    	editor.TA_insertTextPosAtEnd("![](images/Conference/" + recImage.records[0].fields.Name + ")");
    
    	// Delete the entry in Airtable
    	let atSettings = {};
    	atSettings.url = `https://api.airtable.com/v0/${BASEID}/${TABLE}/${recImage.records[0].id}`
    	atSettings.method = "DELETE";
    	let respAT = at.request(atSettings);
    	if (respAT) console.log(`${recImage.records[0].id} deleted from ${BASEID}/${TABLE}`);
    	else context.fail(`Error deleting ${recImage.records[0].id}from ${BASEID}/${TABLE}`);
    }
    
    // More than one record
    if(recImage.records.length >=2) app.displayErrorMessage("Too many matches!");

Options

  • After Success Default
    Notification Error
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.