How to create tasks using record producer

SD29
Tera Expert

Hi All,

I am creating a problem record using a record producer. I need to create 2 problem tasks in the related list when a problem record is created. Is it possible to create problem tasks using script from record producer or is it possible to trigger a workflow when the record producer is submitted so that i can create tasks via workflow ?

Please help!

Thanks,

SD

1 ACCEPTED SOLUTION

awessel
Kilo Guru

You should definitely be able to do this via the script that runs when the record producer is created. Just include something like this near the end of your script:



var probTask = new GlideRecord('problem_task');


probTask.initialize();


probTask.problem = current.sys_id; //This will ensure the Problem Task is tied to the Problem that was just created



//Add any other mappings you want here



probTask.insert();



probTask.some_field = test;



var task2ID = probTask.insert();


View solution in original post

5 REPLIES 5

awessel
Kilo Guru

You should definitely be able to do this via the script that runs when the record producer is created. Just include something like this near the end of your script:



var probTask = new GlideRecord('problem_task');


probTask.initialize();


probTask.problem = current.sys_id; //This will ensure the Problem Task is tied to the Problem that was just created



//Add any other mappings you want here



probTask.insert();



probTask.some_field = test;



var task2ID = probTask.insert();


Hi Adam,



This will only create 1 task right?


How can i create 2 different tasks for a single record?



Thanks,


SD


You could just include the above script twice. Or, even easier, make the modifications to probTask that you want for the second task and then do another insert(). That will ensure any of the fields you set for the first task that you want to be the same are also set for the 2nd task.


I updated the script in my original post to include a second task.