Not able insert new approver using business rule
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 11:07 AM
Hello Community,
I'm looking to add approver in sysapproval table.I created this business rule but it isn't working.
I created two fields on ritm form.Whatever user selects in the enter approval field will be inserted in the sys approval table for coresponding ritm with state "requested".
Below is the business rule i created on ritm table on before insert update.
(function executeRule(current, previous /*null when async*/ ) {
var s = new GlideRecord('sysapproval_approver');
s.initialize();
s.sysapproval = current.sysapproval;
s.approver = current.u_enter_approver;
s.state = 'requested';
s.source_table = current.source_table;
s.document_id = current.document_id;
s.wf_activity = current.wf_activity;
s.insert();
Please suggest what is wrong with this code.All the backend names have been verified .
Thanks,
Sajal
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2024 11:18 PM
Hey @sajal_chatterje
Give this a try:
var s = new GlideRecord('sysapproval_approver');
s.initialize();
s.sysapproval = current.getUniqueValue(); //sys_id of the current record
s.approver = current.u_enter_approver;
s.state = 'requested';
s.source_table = current.getTableName(); //it gives you the current table name which is "sc_req_item" in your scenario
s.document_id = current.getUniqueValue(); // it gives you the current record sys_id
//s.wf_activity = current.wf_activity;
s.insert();
(=not tested)
BTW, what is the purpose of adding approver's manually? or are you just learning?
Thanks,
Murthy
Murthy