- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 06:54 AM
Hello all,
Hopefully a quick one. On our Purchase Order Line Item table, we need to set the default value on the Vendor field to be the same as the Vendor field on the parent Purchase Order. Both fields are references to the same 'Company' table, but we can't seem to get the selected vendor on the PO record to appear when a new line item is opened.
In the Default value section, we are using 'javascript:current.vendor = current.purchase_order.vendor.toString()', which we thought would pass the sys_id of the value, but it does not.
Any suggestions?
Thanks,
Charles
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 07:29 AM
If you still cannot get the default value to work another alternative is to use a display business rule to save the sys_id and display value of the vendor in the g_scratchpad, then populate it with an onLoad client script.
Example BR:
When: Display
g_scratchpad.vendorID = current.purchase_order.vendor;
g_scratchpad.vendorName = current.purchase_order.vendor.getDisplayValue();
Example CS:
function onLoad() {
g_form.setValue('vendor', g_scratchpad.vendorID, g_scratchpad.vendorName);
}
http://wiki.servicenow.com/index.php?title=Client_Script_Best_Practices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 06:57 AM
'javascript:current.vendor = current.purchase_order.vendor.toString()'
should this be 'javascript:current.vendor = parent.purchase_order.vendor.toString()'
since you said "we need to set the default value on the Vendor field to be the same as the Vendor field on the parent Purchase Order."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 07:10 AM
Hi there,
Thanks for the help. The field 'purchase_order' is on the Line Item form, which is why we were not using 'parent'. We tried this suggestion anyway but this does not work either.
Ch

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 06:58 AM
Hi Charles,
All you need in the default value section is: javascript:current.purchase_order.vendor.toString();
The default value is basically asking you for a value, not for you to assign it through js if that makes sense.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 07:10 AM
Thanks Brad - unfortunately this is not working for us.