- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 02:32 AM
I created a BR to copy a field value from a custom field in sysapproval_approver to another field in a custom table. For some reason when I query for the sys_id the BR does not work, only if I hard-code a sys_id.
After, Update BR, Order 100, table: sysapproval_approver
Field to be copied: u_ic_id2
Target table: u_it_investment_committee_request
Target field: u_ic_id
*****************************************
***********************************
I also tried itInvestmentRequest.addQuery("sys_id", current.itInvestmentRequest.sys_id ); and other ways to get the sys_id but none of them worked.
Can anyone help, please?
Thank you a lot in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 03:06 AM
The solution was to use the document_id
itInvestmentRequest.addQuery("sys_id", current.document_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 02:40 AM
I have made small change in your script please try
(function executeRule(current, previous /* , g */ ) {
var itInvestmentRequest = new GlideRecord('u_it_investment_committee_request');
itInvestmentRequest.addQuery("sys_id", current.u_it_investment_committee_request.sys_id); // Use the correct reference to sys_id
itInvestmentRequest.query();
if (itInvestmentRequest.next()) {
itInvestmentRequest.u_ic_id = current.u_ic_id2;
itInvestmentRequest.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 02:45 AM
Hi Harish,
It did not work either.
Thank you for your reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 03:01 AM
(function executeRule(current, previous /* , g */) {
var sourceValue = current.u_source_field; // Replace with your field name
var customTable = new GlideRecord('u_custom_table'); // Replace with your table name
customTable.addQuery('sys_id', current.u_custom_table_reference);
customTable.query();
if (customTable.next()) {
customTable.u_target_field = sourceValue;
customTable.update();
}
})(current, previous);
please put field name correct and table name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 03:06 AM
The solution was to use the document_id
itInvestmentRequest.addQuery("sys_id", current.document_id);