'undefined' value is populating on string fields when are copied from other record.

kirthi1
Tera Contributor

'undefined' value is populating on string fields when they are copied from other records.

When the record producer related to purchase request catalog item is submitted from the portal, the 'undefined' is not seen.

But when the record is submitted from the application, the 'undefined' field is seen as below.

find_real_file.png

When the 'New' button is clicked under the funding code the new record copies fields from the first record.

find_real_file.png

This is code that copies the field values on the Funding code from first inserted record to the second inserted record.

find_real_file.png

10 REPLIES 10

asifnoor
Kilo Patron

Hi,

Few things to check.

1. Is this Br display BR? If yes, then you need to have a client script which is used to cpature the values of your scratchpad.

2. I see that in your BR, you are checking for current.u_po_line_item. Are you getting the value of the previous record or the current record? If you click on new, i assume you get here the current record value which is still not inserted into the DB. so you will not get any values and hence you might be seeing undefined value on your form.

3. Also add logs in your if condition in your Br and check if its entering the control or not.

Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.

Regards,
Asif
2020 ServiceNow Community MVP

 

Kunal Varkhede
Tera Guru

Hi,

 

First thing remove g_scratchpad from if block(line no 3) in onLoad() client script.

use Display business rule and onLoad client script because Display business rule works on previous records not current.

Make sure that g_scratchpad object contain some value.

 

Please mark correct/Helpful answer if it help you.

Thanks and Regards,

Kunal.

kirthi1
Tera Contributor

Thank you all for the reply, 

I got this to working by adding the red lines on the business rule.

find_real_file.png

Hi Kirthi,

 

If your issue get to resolved then please mark it correct answer so that this thread will be available to others.

 

Thanks and Regards,

Kunal.

 

did you also make the changes in client script ? which i had suggested earlier ? 

 

glad you solved it. kindly select the correct answer, and close this thread. 

 

Thanks for participating on community .