Upcoming database upgrades. to improve our reliability at 03:30 UTC on Feb. 25 / 7:30pm PT on Feb. 24. Some users may briefly experience slow load times or error messages. Learn more here

Automate a script running in applications as a click-button

323 0
Showing results for 
Search instead for 
Did you mean: 

Hello, is it possible to create a script that automates an application I already have? Essentially I have an application that will convert a URL to an attachment, but would like to have it run on a script instead of having to click the button multiple times a day to get it to run.

Code for the application currently is:

let settings = input.config({

title: "Convert URLs to attachments",

description: `This script will download all attachments from a URL into an attachment field. The 

source field can be a URL field or any text field containing a URL. Each cell should only contain a single URL.`,

items: [

    input.config.table("table", { label: "Table" }),

    input.config.field("urlField", {

        parentTable: "table",

        label: "URL field",


    input.config.field("attachmentField", {

        parentTable: "table",

        label: "Attachment field",

        description: "URLs will be downloaded into this field",




async function convertURLsToAttachments() {

let { table, urlField, attachmentField } = settings;

if (attachmentField.type !== "multipleAttachments") {


        `${} is not a attachment field.\nRun the script again when you have an attachment field.`




let skipAlreadySet = await input.buttonsAsync(

    "Skip attachment entries that already have files?",


        { label: "Yes", value: true },

        { label: "No", value: false },



let updates = [];

for (let record of (

    await table.selectRecordsAsync({ fields: [urlField, attachmentField] })

).records) {

    let existingAttachments = record.getCellValue(attachmentField) || [];

    if (skipAlreadySet && existingAttachments.length) continue;

    let urls = record.getCellValueAsString(urlField);

    if (typeof urls !== "string") continue;

    let attachmentsFromUrls = urls.split("\n").map((url) => ({ url }));



        fields: {

            []: [







for (let i = 0; i < updates.length; i += 50) {

    await table.updateRecordsAsync(updates.slice(i, i + 50));



await convertURLsToAttachments();

0 Replies 0