Issue with the notification that is being sent from the system

Aruna13
Tera Contributor

Hi All,

 

I have a requirement to send a 4 types of notifications for a custom table when a request is created or resolved for two different categories. Notifications are working fine, but the when they are being sent out, they are using incorrect mailbox. I have two mailboxes one is for requests related to Shipping category and other mailbox is for other categories. Notifications which are sent for other categories are sent from correct mailbox but the shipping mailbox has this issue. If the request is created/resolved where category is Shipping, the notification is sent out with other category mailbox and not from shipping mailbox.

 

Below is the mail script i am using in the notification:

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    var replyAddress  = '';
    if (current.u_category == 'shipping'){
    replyAddress = gs.getProperty('AR_requestFromTo_shipping');
    email.setFrom(replyAddress);
    email.setReplyTo(replyAddress);
    }else{
    replyAddress = gs.getProperty('AR_request_FromTo_other_categories');
    email.setFrom(replyAddress);
    email.setReplyTo(replyAddress);
    }
})(current, template, email, email_action, event);
 
 

Could you please help me to correct this issue since I am not that much into coding? And I also want to know where the current is taken from - is it taken from my custom table or other?

 

 

Thanks in advance!!

3 REPLIES 3

tharun_kumar_m
Mega Guru

Hi Aruna,

 

The "current" is taken from the table which you have sent while creating the 4 notifications.

Let's say for one of your notification, you have entered "task" for the table name, then current.category will fetch the category of the task record.  https://developer.servicenow.com/dev.do#!/learn/learning-plans/utah/new_to_servicenow/app_store_lear... 

 

Please check if you have set the correct table in the notifications. I believe the "if" condition didn't run and that might have caused this issue. 

tharun_kumar_m_0-1712308554332.png

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumbs up.

 

Best regards,

Tharun Kumar

Aruna13
Tera Contributor

Hi Tharun!

 

I have selected correct target table in my notifications. I also doubt that there might be issue with the if condition. Can you please help me to fix this.

 

Thanks!

Hi Aruna,

 

Please put some log statements in your code.

Before If condition please insert the following code.

var category = current.u_category;
gs.log(category);

Inside if and else conditions:

gs.log("Iam inside if now");
//at the end of if condition
gs.log(replyAddress);

//inside else
gs.log("Iam inside else now");
//at the end of if condition
gs.log(replyAddress);

Please check the logs to see the output you are getting. https://instance_name.service-now.com/syslog_list.do?sysparm_userpref_module=ab0b7690c0a8016400bdb85... 

 

If there is no issue in the code, please verify whether category mail box is active.

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumbs up.

 

Best regards,

Tharun Kumar