- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2023 04:19 PM
Hi,
I am trying to use the Advance Condition on an approval email notification to restrict the notification to only send out when a specific catalog item is submitted. This is the code that I am using and is currently working:
var record = new GlideRecord('sc_req_item');
var sysApprovalSysId = current.sysapproval;
record.addQuery('sys_id', sysApprovalSysId);
record.query();
if (record.next())
{
if ( record.cat_item.name.toString() == 'Email Distribution Lists')
{
gs.log('Email Notification for: Email Distribution List: '+record.cat_item.name.toString()+'\nStatus: True','Email test');
answer = true;
}
else
{
gs.log('Email Notification for: Email Distribution List: '+record.cat_item.name.toString()+'\nStatus: False','Email test');
answer = false;
}
}
But now I wanted to include into the code the answer to one of the variables. I have a question on the form where the user needs to select between New or Change, if they select 'New' I want to send this notification.
I was trying to use the conditional builder but I can't get to the variable level, only to the catalog item name.
Any suggestion?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2023 05:14 PM
Do not add anything in condition builder just add below advance condition script
var record = new GlideRecord('sc_req_item');
var sysApprovalSysId = current.sysapproval;
record.addQuery('sys_id', sysApprovalSysId);
record.query();
if (record.next())
{
if ( record.cat_item.name.toString() == 'Email Distribution Lists' && record.variables.new_or_change == 'New')
{
gs.log('Email Notification for: Email Distribution List: '+record.cat_item.name.toString()+'\nStatus: True','Email test');
answer = true;
}
else
{
gs.log('Email Notification for: Email Distribution List: '+record.cat_item.name.toString()+'\nStatus: False','Email test');
answer = false;
}
}
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2023 05:14 PM
Do not add anything in condition builder just add below advance condition script
var record = new GlideRecord('sc_req_item');
var sysApprovalSysId = current.sysapproval;
record.addQuery('sys_id', sysApprovalSysId);
record.query();
if (record.next())
{
if ( record.cat_item.name.toString() == 'Email Distribution Lists' && record.variables.new_or_change == 'New')
{
gs.log('Email Notification for: Email Distribution List: '+record.cat_item.name.toString()+'\nStatus: True','Email test');
answer = true;
}
else
{
gs.log('Email Notification for: Email Distribution List: '+record.cat_item.name.toString()+'\nStatus: False','Email test');
answer = false;
}
}
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2023 05:19 PM
Hi, I don't have anything in the conditional builder. I just added the code into the advance conditional. But is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2023 05:25 PM
Hi, now is working. Thanks for your help.