Business Rule script to populate a reference field from a string field

Kev McLeod
Kilo Contributor

Hi all

 

I have a String field "u_wrnumber" that is populated from the email body using a business rule

 

i need to populate a Reference field "Parent" from the u_wonumber fiild and have tried the following script in a business rule that is not working

These are the two fields on the form

find_real_file.png

 current.parent=current.u_wrnumber;

find_real_file.png

i can manually put the WR Number in the Parent field as it exists in the task table

could anyone please assist with how i populate the parent field

 

Thankyou

 

9 REPLIES 9

Chandra Rawat
Kilo Contributor

Hi Kev,

 

Please use this code:-

 

 current.setDisplayValue('parent',current.u_wrnumber);

 

please mark helpful if it solve your issue

Kev McLeod
Kilo Contributor

Hi all

we are so close 🙂 many thanks for all the advice

current.setDisplayValue('parent',current.u_wrnumber);

The above Scipt that you have suggested is working with one minor hiccup. it doesnt work on insert but if i set the business rule to run on insert and update it updates the field after i have opened the form and saved it again

 

do you have any suggestions on how to get the form to update on insert?

find_real_file.png

find_real_file.png

 

 

Hi Kev,

I don't think you can update the form when it is inserted. Don't you have that value before insert itself?

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Kev McLeod
Kilo Contributor

Hi Ankur

 

The u_wrnumber field is populated as part of an inbound email action, im not sure if that means the value is avaialble before the business rule runs though

 

Regards Kev

Chandra Rawat
Kilo Contributor

use Glide Record and by using Glide Object you can update like gr.update();

 

 

Please mark helpful if it solve your issue