Catalog Task workflow activity

Priya Bonam
Tera Expert

I have a requirement that only one workflow to be used for different catalog items.

only difference in the catalog task is description field to be pupulated with respective ritm short dscription.

var task = current;
 var ritm = new gliderecord("sc_req_item");
ritm.addquery('number',task.request_item);
ritm.query();
while(ritm.next())
{
    var gr = new GlideRecord('sc_task');
    gr.addQuery('request_item', task.request_item);
    gr.query();

    if (gr.next()) {
        // Update the state of the catalog task
        gr.description=ritm.short_description;
        gr.update();
my script is not working catalog task activity in workflow.please suggest the code.
5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

In the script of the Catalog Task workflow activity, just use:

task.short_description = current.short_description;

Shivalika
Mega Sage

Hello @Priya Bonam 

 

ritm.addquery('number',task.request_item); - Here you are putting filter on number but passing task.request_item - change it to "task.number". 

 

gr.addQuery('request_item', task.request_item); - change this to only "task"

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

Shivalika
Mega Sage

OR @Priya Bonam  

 

If my above corrections doesn't work, just use below script -

 

var requestItemShortDesc = current.short_description;

    // Find the associated catalog tasks
    var catalogTaskGR = new GlideRecord('sc_task');
    catalogTaskGR.addQuery('request_item', current.sys_id);
    catalogTaskGR.query();

    // Update the short description for each catalog task
    while (catalogTaskGR.next()) {
        catalogTaskGR.short_description = requestItemShortDesc;
        catalogTaskGR.update();
    }

Ankur Bawiskar
Tera Patron
Tera Patron

@Priya Bonam 

your workflow is already running on RITM table then why are you querying?

Script shared by @Brad Bowman will work here and will populate RITM Short Description -> Task Description

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader