Conditions for catalog task definitions

charushk
Tera Contributor

Please help with the conditions in the catalog task definition,

If the user country is Israel and the short description is something then the assignment group should be ITAM

2 REPLIES 2

Amit Gujarathi
Giga Sage
Giga Sage

HI @charushk ,
I trust you are doing great.
Please find the below reference code for the same.

(function executeRule(current, previous /*null when async*/) {

    // Get the user's country
    var userCountry = current.opened_by.country;

    // Get the short description of the task
    var shortDescription = current.short_description;

    // Check if the user's country is Israel and the short description meets your criteria
    if (userCountry === 'Israel' && /* condition for short description */) {
        // Set the assignment group to 'ITAM'
        var itamGroup = new GlideRecord('sys_user_group');
        itamGroup.addQuery('name', 'ITAM');
        itamGroup.query();
        if (itamGroup.next()) {
            current.assignment_group = itamGroup.sys_id;
        }
    }

})(current, previous);

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



 

charushk_2-1701161352589.jpeg

Need to add the condition in the catalog task definition of the catalog item