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

How to assign a catalog task based on the model category in alm_hardware table.

neha_rathore
Tera Contributor

we have to assign a catalog task to 'abc' group, if hardware asset assign to user has model category as 'Rugged Device'. And if its not rugged device the result will be no.

so we have written a script in IF activity in workflow, but it is not working as expected.

answer = ifScript();

function ifScript() {

    var requestFor = current.requested_for.sys_id;

    var category = 'Rugged Device';

    var gr1 = new GlideRecord('alm_hardware');

    gr1.addQuery('assigned_to', requestFor);

    gr1.addQuery('model_category.name', category);

    gr1.query();

    if (gr1.next()) {

        return 'yes';

    }

    return 'no';

}

neha_rathore_0-1702379787671.png

 

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

Are you saying the IF activity is not resulting in the correct yes/no for the user being tested, or that the Catalog task is not correctly assigned, which would be outside of / after this activity? 

Catalog task is not correctly assigned to group after IF activity.

The IF activity is not doing anything to assign the group, so we'll need to see what the workflow looks like, and the details of the activities following the IF.  It sounds like you don't need an IF activity, rather use your script within the Catalog Task activity to set the task.assignment_group to one value or another depending on the result of the GlideRecord.