event is not triggering

Aditya Kumar
Kilo Guru

hi experts...

my simple event is not triggering...

AdityaKumar_0-1671732139263.png

 

1 ACCEPTED SOLUTION

Aditya Kumar
Kilo Guru

It is solved, I needed to add GR for getting the recipient's name.

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

    function checkRemainingHours() {
        var isZero = true;
        var gr = new GlideRecord('service_entitlement');
        gr.addQuery('account', current.account);
        gr.query();

        while (gr.next()) {
            if (gr.remaining_units != 0) {
                isZero = false;
                break;
            } else {
                isZero = true;
            }
        }
        return isZero;
    }

    if (checkRemainingHours() == true) {
        var grTwo = new GlideRecord('customer_account');
        grTwo.addQuery('sys_id', current.account);
        grTwo.query();
        if (grTwo.next()) {
            gs.eventQueue('cd.primary.contact.entitlement.mail', current, grTwo.primary_contact);
        }
    }

})(current, previous);

 

View solution in original post

3 REPLIES 3

SanjivMeher
Kilo Patron
Kilo Patron

Not sure if you should have dots in your event name. I think you should replace those with underscore.

Also you should add some debug statement such as gs.addInfoMessage to check, if it enters the if condition.

 


Please mark this response as correct or helpful if it assisted you with your question.

I've added gs.addinfo and it's working fine I just want to trigger the notification. 

- have created the events with dots if we check out of the box name of events then dots 

are in the name 

- in notification, I've selected the event and selected the event param one. 

 

Aditya Kumar
Kilo Guru

It is solved, I needed to add GR for getting the recipient's name.

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

    function checkRemainingHours() {
        var isZero = true;
        var gr = new GlideRecord('service_entitlement');
        gr.addQuery('account', current.account);
        gr.query();

        while (gr.next()) {
            if (gr.remaining_units != 0) {
                isZero = false;
                break;
            } else {
                isZero = true;
            }
        }
        return isZero;
    }

    if (checkRemainingHours() == true) {
        var grTwo = new GlideRecord('customer_account');
        grTwo.addQuery('sys_id', current.account);
        grTwo.query();
        if (grTwo.next()) {
            gs.eventQueue('cd.primary.contact.entitlement.mail', current, grTwo.primary_contact);
        }
    }

})(current, previous);