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.

approve button link to reply-to email window

Servicenow10
Kilo Guru

hi 

i have designed a notification which looks like this:

 

find_real_file.png

 

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

 

 

find_real_file.png

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!!

1 ACCEPTED SOLUTION

Omkar Joshi
Giga Guru

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.

View solution in original post

16 REPLIES 16

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();
}

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();

}

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

Service_RNow
Mega Sage

Hi,

Refer the following link.

Creating a pop-up using a GlideDialogWindow

GLIDEDIALOG WINDOW EXAMPLE

Mark if Correct/Helpful

Thank You

Service_RNow
Mega Sage

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