Copy reference field to related list

raju51
Tera Contributor

I have a requirement to copy Change Request from problem form to change request related list on same problem form. OOTB its not getting copied in related list. Appreciate quick response.

raju51_0-1697733347012.png

 

3 ACCEPTED SOLUTIONS

Hello @raju51 

 

Use this -

(function executeRule(current, previous /*null when async*/ ) {
    var chNum = current.rfc;
    var chGR = new GlideRecord('change_request');
    chGR.addQuery('sys_id', chNum);
    chGR.query();
    if (chGR.next()) {
        chGR.parent = current.sys_id;
        chGR.update();
    }
})(current, previous);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

Thanks

View solution in original post

Hello @raju51 

 

On which table you have written BR

And in the chNum variable what you are getting

View solution in original post

Hello @raju51 

 

please use this -

(function executeRule(current, previous /*null when async*/ ) {
    var chNum = current.rfc;
    var chGR = new GlideRecord('change_request');
    chGR.addQuery('sys_id', chNum);
    chGR.query();
    if (chGR.next()) {
        chGR.parent = current.sys_id;
        chGR.update();
    }
})(current, previous);

View solution in original post

6 REPLIES 6

Hello @raju51 

 

On which table you have written BR

And in the chNum variable what you are getting

Hello @raju51 

 

please use this -

(function executeRule(current, previous /*null when async*/ ) {
    var chNum = current.rfc;
    var chGR = new GlideRecord('change_request');
    chGR.addQuery('sys_id', chNum);
    chGR.query();
    if (chGR.next()) {
        chGR.parent = current.sys_id;
        chGR.update();
    }
})(current, previous);