- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2019 10:02 PM
hi
i have designed a notification which looks like this:
now what i need to do is once i click on approve button it open a reply-to email window. Just Click 'Send' to forward the email back to ServiceNow and approve the request. The reply email is linked directly to the approval request in ServiceNow and it will look like below image
how can i achieve this through email script or any other way......please explain me in detail as am new to now and scripting
thanks in advance!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2019 10:25 PM
Hi,
Use the below code in email script
(function runMailScript(current, template, email, email_action, event) {
var apButStr = '<div><a href="mailto:dev11111@service-now.com?subject=re:' + current.number + ' - approve&body='+ current.number + ' - approve' +'"><br /><img style="align: baseline;" title="Click this button to mark approved" src="/approveButton.pngx" alt="Approved" width="142" height="41" align="baseline" /></a>';
var rejButStr = '<a href="mailto:dev11111@service-now.com?subject=re:' + current.number + ' - reject&body='+ current.number + ' - Reject' +'"><img style="align: baseline;" title="Click this button to mark rejected" src="/rejectButton.pngx" alt="Rejected" width="142" height="41" align="baseline" /></a></div>';
var full = apButStr + rejButStr;
template.print(full);
})(current, template, email, email_action, event);
Note:Use your instance URL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2019 02:21 AM
Use the below script
var number = email.subject.substr(3,11);
var item_id='';
var item=new GlideRecord('sc_req_item');
item.addEncodedQuery('number='+number);
item.query();
if(item.next())
{
item_id=item.getValue('request');
}
var apr=new GlideRecord('sc_request');
apr.addEncodedQuery('sys_id='+item_id);
apr.query();
while(apr.next())
{
if(email.subject.indexOf("approve") > -1)
{
apr.approval='approved';
}
else if (email.subject.indexOf("reject") > -1)
{
apr.approval='rejected';
}
apr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2019 02:26 AM
Use the below Code:
[remove previous script and add below script]
var number = email.subject.substr(3,11);
var item=new GlideRecord('sc_req_item');
item.addEncodedQuery('number='+number);
item.query();
if(item.next())
{
if(email.subject.indexOf("approve") > -1)
{
item.approval='approved';
}
else if (email.subject.indexOf("reject") > -1)
{
item.approval='rejected';
}
item.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2019 03:48 AM
hi omkar
i used your above code and am able to get the first part as after click on approve and reject it opens a email window but
it generates the ritm number which is already closed or if i hard code the value then also it generates the different ritm
and also when i click the send button it does not approve/reject the approval column in ritm...
please suggest do i have to make any chnages in outlook or in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2019 02:06 AM
Hi,
Refer the following link.
Creating a pop-up using a GlideDialogWindow
Mark if Correct/Helpful
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2019 02:14 AM
Hi,
You can write inbound actions to approve or reject emails.
In inbound actions, you can specify the conditions like subject contains, field ...etc.
Depending upon the conditions it will update on the target table.
By using watermark service now instance will identify to update that on which record.
Refer the below links may help to you
.Approve or Reject Change Request via Email
Single click on email link to accept/reject a record
Buttons within Email Notifications
I hope those links are helpful.
Mark if Correct/Helpful
Thank You
