Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Email notification issues

JVINAY
Tera Contributor

Hi Community,

I need some one help , I have created two emails , one is interrupted another one name rejected.  I have created two events for these notifications.

Event names : 

cloud_intake.olympus_vending_errorv2 :  Rejected message
cloud_intake.olympus_vending_error : interrupted message.

 

the above two events are fired via REST message. after development completed , this two events triggered respective emails it's working fine. but the issue is  suppose the vending status success same interrupted  event triggered and interrupted email sent.

I need help to resolve this isssue. 

 

scripts :

 var accId = accountGR.getUniqueValue();
        accountGR.u_cloud_vending_status = vendStatus;
        accountGR.update();

        var cit = new GlideRecord('u_cloud_intake_task');
        cit.addQuery('u_cloud_task_type', 'provision');
        cit.addQuery('u_environment', accId);
        cit.query();
        while (cit.next()) {
            if (cit.u_environment.u_cloud_vending_status == 'true') cit.state = '3';
            if (vendMessage) cit.comments = vendMessage;
            if (cit.u_environment.u_cloud_vending_status == 'false' && vendMessage.toString().includes("SCHEMA validation failed")) {
                var vend1 = (!cit.getValue('assigned_to')) ? gs.getUserID() : cit.getValue('assigned_to');
                gs.eventQueue('cloud_intake.olympus_vending_errorv2', cit, vend1, vendMessage);
            } else {
                var parm1 = (!cit.getValue('assigned_to')) ? gs.getUserID() : cit.getValue('assigned_to');
                gs.eventQueue('cloud_intake.olympus_vending_error', cit, parm1, vendMessage);
            } 
            cit.update();
        }

        var successResponseBuilder = {};
        successResponseBuilder.message = 'Success';
        successResponseBuilder.detail = 'Vending status for ' + accountNumber + " was successfully updated to " + vendStatus;
        response.setContentType('application/json');
        response.setStatus(200);
        var streamWriter = response.getStreamWriter();
        streamWriter.writeString(JSON.stringify(successResponseBuilder));
@Ankur Bawiskar #servicenowdevelopers
1 REPLY 1

Mark Manders
Mega Patron

Please close this one: https://www.servicenow.com/community/servicenow-impact-forum/email-trigger-isssue/td-p/2978111


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark