Reject Comments on RITM

alexcharleswort
Tera Expert

Hi all,

I was sure I had this script working somewhere before, but I can't seem to find it. This is my need:

When an approval goes out to our CEO he can click   "reject this request" link and then send an email back to SN with the response. In the email back he will indicate how many days something needs to be on hold.

Our store team will need to see that number and enter that into a value on their task. The catch is that our store team isn't too tech savvy so we are trying to make this as painless as possible.

In short, I need to get this emailed back reject reason into the description of the task. I will totally be happy if I can just get it into the description of the RITM. I just can't seem to get the script working. I figured it would be pretty easy to dot walk into the "approving" (document_id) field but that doesn't seem to cut it.

Any ideas on what my script should look like would be extremely helpful.

Thanks in advance!

1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

Hi Alex,



You can write below before update business rule on sysapproval_approver table, when state changes to Rejected.



var rec = new GlideRecord('sc_req_item');


rec.addQuery('sys_id',current.document_id);


rec.query();



if (rec.next())


{


        rec.description = current.comments;


        rec.update();


}



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

8 REPLIES 8

ccajohnson
Kilo Sage

Depending upon how universal you want this script to be will determine if you build the script into the workflow, or into a Business Rule.



I typically have more success using the hidden sysapproval field. Let us know what you have built so far so we can troubleshoot accordingly.


SanjivMeher
Kilo Patron
Kilo Patron

Hi Alex,



You can write below before update business rule on sysapproval_approver table, when state changes to Rejected.



var rec = new GlideRecord('sc_req_item');


rec.addQuery('sys_id',current.document_id);


rec.query();



if (rec.next())


{


        rec.description = current.comments;


        rec.update();


}



Please mark this response as correct or helpful if it assisted you with your question.

Hi Sanjiv,

 

I tried to add this to my developer instance however it duplicates the comments on the RITM - can you see where i'm going wrong?

 

Thanks


Steve

 

When: Before

Update

Filter Condition: State changes to Rejected

----------------------

 

var rec = new GlideRecord('sc_req_item');

rec.addQuery('sys_id',current.document_id);

rec.query();

if (rec.next())
{


         rec.comments = "Reason for rejection: " + current.comments;


         rec.update();
}

Can you try this? Make it an onAfter BR

 

var rec = new GlideRecord('sc_req_item');

rec.addQuery('sys_id',current.document_id);

rec.query();

if (rec.next())
{


         rec.comments = "Reason for rejection: " +current.comments.getJournalEntry(1);
         rec.update();
}


Please mark this response as correct or helpful if it assisted you with your question.