The CreatorCon Call for Content is officially open! Get started here.

how do I get the sys id of the task created by a "Catalog Task Activity" in a workflow?

patricklatella
Mega Sage

Hi gang,

I've got a workflow for an application request catalog item, and in that I'm using a "Catalog Task" activity to create a task.  I need to have a 2nd activity later in the workflow reference that created task to either close it, or assign it.  To further explain, I'm using orchestration to add a user to an AD group, but I want to have a task record created so that we can track the number of requested items.  So I want the task to be created (but not assigned), and then if the "Add user to group" orchestration activity is successful, I want to close that task.  But if the orchestration activity is unsuccessful, then I want to be able to set the assignment group.

To do so, when the task is created in the activity, how can I grab the sys_id of the created task record and write it to the scratchpad?

or is there another way to reference a task created with a workflow, later in the workflow?

thanks!

1 ACCEPTED SOLUTION

think I figured it out...this worked for grabbing the sys_id of the task created by the Catalog Task activity.

workflow.scratchpad.taskid = task.setNewGuid();

View solution in original post

11 REPLIES 11

Abhinay Erra
Giga Sage

I am not quite sure of the sys_id, but you can grab the task number by adding the following line in the Advanced script section in the catalog task activity

workflow.scratchpad.task_number=task.number;

patricklatella
Mega Sage

thanks, that should work.  And then in my 2nd activity, I can just do a GlideRecord to find that task and update it.  Or is there an easier way to update that task in an activity later in the workflow that you know of?

I would say use a Run script activity and do a GlideRecord query based on the task number and update accordingly.

perfect, will try that.  thanks Abhinay!