Survey is not triggerd based on catalog item category in RITM

mania
Tera Contributor

Hi,

 

I have three survey's 'A', 'B' and 'C' so and have three categories from catalog item Category is 'X', Category is 'Y' and Category is 'Z'.

I want to send survey when state is resolved based on catalog item category from RITM (Variables) as per below screensort:

mania_0-1762523397701.png

Business rule:

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

    // Add your code here

    if (current.state != 8)

        return;

    // Get Category variable value

    var category = current.variables.category;

    // If no value, stop

    if (!category)

        return;

    // Check category and trigger respective survey

    if (category == 'a') {

        // Survey sys_id

        var surveySysID1 = 'qewfgrhtjki2345678';

        gs.eventQueue('assessment.instance.create', current, surveySysID1, current.requested_for);

    }

 

    if (category == 'onboarding_offboarding') {

        var surveySysID2 = 'adwrfsg123456789';

        gs.eventQueue('assessment.instance.create', current, surveySysID2, current.requested_for);

    }

    if(category !== 'events' || category !== 'onboarding_offboarding'){

         gs.info("shilpa10");

        var surveySysID3 = 'sdarferhtykyuregf12345678';

        gs.eventQueue('assessment.instance.create', current, surveySysID3, current.requested_for);

    }

 

})(current, previous);
Notification:

mania_0-1762523732528.jpeg

Trigger Condition:

mania_2-1762523781810.png

 

But the survey is not triggered so can anyone please help on this where i missed  and it will be useful.

 

Thanks!

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@mania 

why are you using BR to trigger survey from script?

Directly in the trigger condition why can't you give Category condition?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@mania 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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