- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2020 09:11 PM
Table = u_test_table
Fields = field1, field2
var cartId = GlideGuid.generate(null); var cart = new Cart(cartId); var item = cart.addItem('e2132865c0a8016500108d9cee411699'); var rc = cart.placeOrder();
var number = rc.number
//i want to set rc.number in field1 (BR on table u_test_table)
current.setValue(field1,number) ---- this is not working neither
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2020 11:45 PM
Hi Neha,
your BR has different field name
current.setValue('u_field1',number);
current.update();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2020 10:51 PM
Hi Neha,
Is the field name correct i.e. field1?
Is this before BR?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2020 10:52 PM
after BR, yes field name is correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2020 11:44 PM
Hi Neha,
since it is after update BR you would require to use current.update()
Is field1 a string or reference?
if it is string then use this
current.setValue('field1',number);
current.update();
if it is reference to RITM then use this
current.setValue('field1',rc.getUniqueValue());
current.update();
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2020 11:03 PM
Hi Neha,
If the field type is reference and it's referencing sc_request table then you need to set the sys_id of the field instead of number, use the code to set the value of field rc.getUniqueValue();.
Also, it seems like field1 is the column label not the column name since it's a custom field it might be starting from u_, I request you to navigate to the dictionary and check for the correct field column name. I believe it would be u_field1.
Could you please give a try with below script if the field1 is a string field:
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('e2132865c0a8016500108d9cee411699');
var rc = cart.placeOrder();
var number = rc.number.toString();
//i want to set rc.number in field1 (BR on table u_test_table)
current.setValue('u_field1',number);
OR please give a try with below script if the field is a reference field referencing sc_request table:
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('e2132865c0a8016500108d9cee411699');
var rc = cart.placeOrder();
var number = rc.getUniqueValue();
//i want to set rc.number in field1 (BR on table u_test_table)
current.setValue('u_field1',number);
Kindly mark my answer as Correct and Helpful based on the Impact.
Regards,
Alok
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2020 11:34 PM
Tried both its not working with rc.number it was returning request number with .toString its return into string but its not setting the valur in u_field1