Get field value of Record Producer field in Business Rule

Andrew122
Mega Expert

Hello,

I have a Record Producer that has a couple of custom fields that aren't on the Record that it is creating.  Is there a way to get the value of what is in that Record Producer field through a Business Rule?

So if I have a "Test" field that is on the Record Producer but not on the table with a name of "u_test" could I get the value of that field in a Business Rule and push that value into a Short Description field?

1 ACCEPTED SOLUTION

Andrew, 

 

       I think I follow this requirement, let us explore this request more through real table names because I think you referenced the wrong table at the end. 

You have a Record Producer with a Variable (u_test) the Record Producer generates an Idea Record on Submit. You need to take the Idea Record Variable and write it to an existing Incident Record Field (u_number). I am not sure how you will query the Incident table to target the correct record because I do not follow how the Incident Record will have a reference to the Idea Record through the number field as you stated.

The method could be an after insert BR but this will only pass the Record Producer Record Variable (u_test), on the 'Idea Table' to all Incidents without a value in the Incident.u_number field on the Incident table. 

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

     var rec = current.variables.u_test.toString();
     var gr = new GlideRecord('incident');
     gr.addQuery('u_number','');
     gr.query();
     while (gr.next) {
          gr.u_number = rec;
     }

})(current, previous);

 

Thanks, 

 

Derrick Johnson

View solution in original post

7 REPLIES 7

Andrew, 

 

       I think I follow this requirement, let us explore this request more through real table names because I think you referenced the wrong table at the end. 

You have a Record Producer with a Variable (u_test) the Record Producer generates an Idea Record on Submit. You need to take the Idea Record Variable and write it to an existing Incident Record Field (u_number). I am not sure how you will query the Incident table to target the correct record because I do not follow how the Incident Record will have a reference to the Idea Record through the number field as you stated.

The method could be an after insert BR but this will only pass the Record Producer Record Variable (u_test), on the 'Idea Table' to all Incidents without a value in the Incident.u_number field on the Incident table. 

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

     var rec = current.variables.u_test.toString();
     var gr = new GlideRecord('incident');
     gr.addQuery('u_number','');
     gr.query();
     while (gr.next) {
          gr.u_number = rec;
     }

})(current, previous);

 

Thanks, 

 

Derrick Johnson

That works!  Thanks!

My pleasure 🙂