BR to copy a field to a referenced table

catia_alves
Tera Expert

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 

*****************************************

(function executeRule(current, previous /* , g */ ) {
    var itInvestmentRequest = new GlideRecord('u_it_investment_committee_request');
    itInvestmentRequest.addQuery("sys_id", current.sys_id );
    itInvestmentRequest.query();
    if (itInvestmentRequest.next()) {
        itInvestmentRequest.u_ic_id = current.u_ic_id2;
        itInvestmentRequest.update();
    }
})(current, previous);

***********************************
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.


1 ACCEPTED SOLUTION

catia_alves
Tera Expert

The solution was to use the document_id

itInvestmentRequest.addQuery("sys_id", current.document_id); 

View solution in original post

6 REPLIES 6

ccurtis
Tera Contributor

Than you so much for your post, you do not know how many hours I spent on this, thank you again

You are very welcome 😄