
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 02:51 PM
I'm using a Business Rule to take the comments from an Approval record and copy them to the corresponding Contract record.
I have it set to run when the Source Table is ast_contract, the approval state is requested, and the Comments changes.
It runs after an update. Here is my code. However on the resulting contract record, I get the following (see screenshot below).
(function executeRule(current, previous /*null when async*/ ) {
var comments;
current.comments = "Test Comment";
if (current.comments != '') {
comments = current.comments;
} else {
comments = current.comments.getJournalEntry(1);
}
var gr = current.document_id.getRefRecord();
if (comments !='')
{
gr.comments = "Approval Comments: \n\n" + comments;
gr.update();
}
else{
gr.update();
}
gr.update();
})(current, previous);
I have checked over and over, but not sure why it's only passing the dates from the contract into the comments field on the contract. I just want it to show the notes.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2023 12:43 PM
Hi @Aaron Duncan ,
Create an after-update a Business rule on the Approval table. Please find the below screenshots of my code and Business Rule(Change the state condition as per your requirement)
Code:-
var gr = new GlideRecord('ast_contract');
gr.addQuery('sys_id',current.document_id);
gr.query();
if(gr.next())
{
gr.u_comments = current.comments.getJournalEntry(1);
gr.update();
}
Please mark my solution as helpful, if it helps!!
Please try the below code
var gr = new GlideRecord('ast_contract');
gr.addQuery('sys_id',current.document_id);
gr.query();
if(gr.next())
{
gs.addInfoMessage("Entered into the if");
gr.u_comments = current.comments.getJournalEntry(1);
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2023 12:43 PM
Hi @Aaron Duncan ,
Create an after-update a Business rule on the Approval table. Please find the below screenshots of my code and Business Rule(Change the state condition as per your requirement)
Code:-
var gr = new GlideRecord('ast_contract');
gr.addQuery('sys_id',current.document_id);
gr.query();
if(gr.next())
{
gr.u_comments = current.comments.getJournalEntry(1);
gr.update();
}
Please mark my solution as helpful, if it helps!!
Please try the below code
var gr = new GlideRecord('ast_contract');
gr.addQuery('sys_id',current.document_id);
gr.query();
if(gr.next())
{
gs.addInfoMessage("Entered into the if");
gr.u_comments = current.comments.getJournalEntry(1);
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2023 08:00 AM
On the query, I just made a minor adjustment and it worked great!
grContract.addQuery("sys_id", current.getValue('document_id'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2023 01:39 PM
Hi Aaron.
Please have a look at my post. It might be helpful.