Update approvals

Community Alums
Not applicable

Hi,

I have created a business rule on sysapproval_approver table to update approval history of ritm to additional comments. I have tried below code but its not working

(function executeRule(current, previous /*null when async*/) {

    // Add your code here

  if(current.source_table == 'sc_req_item'){
    var ritm = new GlideRecord('sc_req_item');
    ritm.get(current.sysapproval.sys_id);
    var message =current.source_table.approval_history;
    ritm.comments = message;
    ritm.update();
  }

})(current, previous);
4 REPLIES 4

Kiran_45
Giga Guru

Hello @Community Alums :

Since you're writing thr BR on the Approval table, there must be any data base operation that needs to be taken place on approval table in order to run your BR. So instead if you need approval history on demand

1)  Create an UI action in RITM table(Visible based pn specific condition).

2) Glide to approval table and bring the approval history and update.

 

Hope this will solve your issue. Please accept the solution or mark the answer as helpful if it helps in anyway.

 

Thanks,

Kiran

Runjay Patel
Giga Sage

Hi @Community Alums ,

 

Use below code, it will work.

var ritm = new GlideRecord('sc_req_item');
    ritm.get(current.document_id);
    var message =current.comments.getJournalEntry(1);
    ritm.comments = message;
    ritm.update();

RunjayPatel_0-1731595771319.png

RunjayPatel_1-1731595800849.png

 

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

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

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

Community Alums
Not applicable

Hi Runjay, Thanks for your response. I tried this but additional comments are not getting added.

GraceBishop
Giga Contributor

Hello everyone. I am new here.

https://ukwritings.com/coursework-service coursework service for the first time and was thoroughly impressed. The writer assigned to my coursework was highly knowledgeable in the subject and delivered exceptional work.