Approximating Two Way Sync - New Row

Hi, I’m making a pack that has a sync table and approximates two way sync using formulas. When my formula updates an existing row in the table, the row is immediately updated, as expected. However, when my formula creates a new row, that row is not added to the sync table. Is this behavior normal, or do I have an issue in my code?

pack.addFormula({
    name: "CreateTask",
    isAction: true,
    description: "Create a task in TickTick. Returns the task if successful, otherwise returns a blank",
    cacheTtlSecs: 0,
    parameters: [
        TASK_NAME_PARAM,
        TASK_DESCRIPTION_PARAM,
        TASK_SORT_ORDER_PARAM,
        TASK_PRIORITY_PARAM,
        TASK_PROJECTID_PARAM,
        TASK_START_DATE_PARAM,
        TASK_END_DATE_PARAM,
        TASK_REMINDERS_PARAM,
        TASK_IS_ALL_DAY_PARAM
    ],
    resultType: coda.ValueType.Object,
    schema: coda.withIdentity(TaskSchema, "Task"),
    execute: async function([ name, description, sortOrder, priorityStr, projectId, startDate, endDate, reminders, isAllDay = false ], context) {
        let url = `${API_BASE}/task`;
        let taskObj = await GenerateTaskObject(context, name, {
            description: description,
            sortOrder: sortOrder,
            priorityStr: priorityStr,
            projectId: projectId,
            startDate: startDate,
            endDate: endDate,
            reminders: reminders,
            isAllDay: isAllDay,
            completed: false
        });
        
        let response = await Fetch(url, "POST", context, JSON.stringify(taskObj));
        if (response.status == 200) {
            return ConvertTaskFields(response.body);
        } else {
            return "";
        }
    }
})

Hi @joe_joe - Unfortunately this is a known limitation with actions and sync tables today. It currently isn’t possible for an action to insert a row into a sync table. You can update your button however to run the RefreshTable() formula after the Pack formula runs, which should get it to pick up the new value.

1 Like