i have a catalog variable (not catalog field) of reference type 'Qualtiy approver'

LVPhanee
Tera Contributor

My requestion is when the catalog varaiable name is changed only Notiifcation should be triggered, right now if any change happens on state or priority field of sc_task

I have sc_take (where Quality analyst variable ), Business rule on the sc_task table screen shot and current logic with below condition 

LVPhanee_2-1781085386077.png

 

 and 

LVPhanee_1-1781085158503.png

 



and code is writtne like this 

''

(function executeRule(current, previous) {

    var ritm_QA = new GlideRecord('sc_req_item');

    if (ritm_QA.get(current.request_item)) {

        var groupMemberId = ritm_QA.variables.quality_approver;

        if (groupMemberId) {

            var memberGR = new GlideRecord('sys_user_grmember');

            if (memberGR.get(groupMemberId)) {

                var userSysId = memberGR.user;

               // gs.log(" BR TRIGGERED USER SYS_ID: " + userSysId);

                gs.eventQueue(
                    'rd.quality_approver.assigned',
                    current,
                    userSysId.toString(),
                    ''
                );
            }
        }
    }

})(current, previous);''

Can you help by added the required logic so that if only Quality Approver ( catalog variable ) is changed then only email should be triggered. 

1 ACCEPTED SOLUTION

Teja R
Kilo Sage

Hi @LVPhanee ,
Before Business rule will work.After BR does not captures the Previous value.

If my response helped, mark it as helpful and accept the solution.

Thanks,
Teja.

View solution in original post

9 REPLIES 9

@LVPhanee 

did you print the variable value and compare?

try to add this in BR condition current.variables.variableName.changes() along with your existing

it has worked in the past

Business rule condition - Variable value changes 

💡 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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

here is the log screen shot and current BR code 
log screen shot:

LVPhanee_0-1781087847267.png

and code screen shot:

LVPhanee_1-1781087905683.png

It is not working for Catalog variable, don't how it worked previously.

on the sc_task I changed the value from 'userA' to 'userB' Here i am getting sysid of 'userB' only.  BR is on sc_task table only. 

@LVPhanee 

did you try same BR on RITM and see the behavior?

Another way is to write BR on sc_item_option table where variable and it's value are stored

You can write BR on that and then handle the logic

BR Condition: Question = Your Variable AND Value Changes

Script:

1) query sc_item_option_mtom with "Dependent Item" = current.sys_id

2) then check the RITM is for which catalog item and then proceed

56.png55.png

💡 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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Teja R
Kilo Sage

Hi @LVPhanee ,
Before Business rule will work.After BR does not captures the Previous value.

If my response helped, mark it as helpful and accept the solution.

Thanks,
Teja.

LVPhanee
Tera Contributor

Completed this requirement with your suggestion went with before BR.