Script Action or AI

Hey All,

I am trying to essentially get a main task to update its custom field from subtask custom fields.

For example when any subtask is set to in progress, mark the main task as in progress.

Either I am desperately overcomplicating things or AI rules do not seem to be able to do it.

Perhaps a script action?

1 Like

AI cannot help because it can’t update “another” task, only a script can do it.

1 Like

Yes, I would advise using Script Action.

Something like that:

1- When “trigger to be defined”

2- Then, add a script action

async function run() {
  const pillarCustomFieldGid = '1209785914660601';

  const triggeringTask = await tasksApiInstance.getTask(task_gid, {
    opt_fields: `parent.custom_fields.gid,parent.custom_fields.enum_value.gid`
  });

  if(triggeringTask.data.parent) {
    const parentPillarGid = triggeringTask.data.parent.custom_fields.find(
    f => f.gid === pillarCustomFieldGid
  )?.enum_value?.gid;

  log("Current pillar is now: " + parentPillarGid);

  if (!parentPillarGid) {
    log("No pillar value found. Skipping update.");
    return;
  }
  
  await tasksApiInstance.updateTask({
        data: {
          custom_fields: {
            [pillarCustomFieldGid]: parentPillarGid
          }
        }
      }, task_gid);

      log("Task updated: " + task_gid);
 
  }
  
}

run();

PS: this is a basic script, feel free to re-work it with your favorite LLM tool to adapt it to your needs.
PSS: I would recommend using the Script action “Run History” to read the logs and eventually improve it. example:

1 Like

Yeah I thought so

@Danni_VanguardCC, I’m pretty sure you can achieve what you need with @Richard_Sather’s:

…but you may not want to because it’s a few moving parts.

But just including that here for completeness’ sake.

Thanks,

Larry

3 Likes