How to get Catalog task field value in the workflow activity.

bhargavi143
Tera Contributor

Hi Team,
I have a requirement we need to add a custom field, the type of the field is True/false in the catalog task once the task is completed and value is set to that field,I need to get the value of the custom field in the workflow.If the value is true i need to trigger one activity or if the value is false i needs to trigger another activity.

How can we achieve this?

Please help me.
Thanks.

1 ACCEPTED SOLUTION

Instead of "request_item" you can use "parent" in line no. 8 and also verify that in the task record in which field RITM no. gets populated. And if it is different than request_item and parent then use that instead of both.

 

Thank you!

Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru

View solution in original post

11 REPLIES 11

Brad Bowman
Kilo Patron
Kilo Patron

Since the workflow runs on the RITM (sc_req_item) table, you will need an If activity with a script that executes a GlideRecord on the sc_task table for the current.sys_id as the GlideRecord request_item or parent.  Once the correct record is retrieved, you can set the return/answer based on the custom field on the sc_task table record.  Give the script a shot, and post your progress using the insert code icon </> if you get stuck.

Dnyaneshwaree
Mega Sage

Hello @bhargavi143 ,

Please refer below logic and if it is not working then please elaborate your requirement so i will update my response accordingly:

After catalog task activity of your workflow, you can use "if" condition activity and set advance = true and in script you can add below code:

  function ifScript() {

    var grTask = GlideRecord('sc_task');
    grTask.addQuery('request_item',current.sys_id); // update query as per your req.
    grTask.query();
    if( grTask.next() ){
        if (grTask.custom_field == 'true')// update field name and value as per your req.

        return 'yes';
     }
     return 'no';
  }



Dnyaneshwaree_0-1717162195087.png

 

After "If" activity, you can join your next activity to "yes" which required to execute for true condition and join your another activity to "No" which required to execute for false condition.

If my answer helped you in any way, please then mark it as helpful or correct.

Thank You in advance!!





Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru

Hi ,
Thanks for the reply!
I have tried in my instance but no luck its every time triggering "no" condition if i have selected the custom field as true in the catalog task.
Please check the below screenshot and give me the suggestion where i need to change.

bhargavi143_0-1717170556589.png

 

 Thanks.

 



 

Since your custom field is the true/false type, use true without quotes in the if condition.  Also, be aware if you have more than one Catalog Task at this point for this Catalog Item you will need an additional addQuery line on short_description, or another field that differentiates them, to ensure you return the intended one.