Action

Insert All Conference Photos

Posted by sylumer, Last update 13 days ago - Unlisted

Insert a Markdown link each of the listed photos 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");
    
    // More than one record
    if(recImage.records.length >=2)
    {
    	// Insert all of the links
    	let astrContent = [];
    	recImage.records.map(recImage => astrContent.push("![](images/Conference/" + recImage.fields.Name + ")"));
    	editor.TA_insertTextPosAtEnd(astrContent.join("\n\n"));
    
    	// Delete each entry in Airtable
    	recImage.records.map(recRow => 
    	{
    		let atSettings = {};
    		atSettings.url = `https://api.airtable.com/v0/${BASEID}/${TABLE}/${recRow.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}`);
    	});
    }
    

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.