- 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 07:14 AM
I would validate a few things:
1. Your fields are actually named vendor and not u_vendor
2. Both the purchase order and vendor (on purchase order) fields have values when the form is initially loaded
3. This code is in the default value section on the dictionary entry.
Also, could you post a screenshot of the default value field on the dictionary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2016 07:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 06:31 PM
i need to make a refernce field default to loggedin user
can anyone help me out plz?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2016 12:23 AM
Hi Kiran,
If you want the field to show the name of the person who created the record then the easiest thing to do is to personalise the dictionary on the sys_user reference field, select the Advanced view, click the 'Default Value' tab, tick 'Use dynamic default' and select 'Me'.
Cheers,
Charles

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2016 05:27 AM
FYI -
A few days ago I noticed on a brand new Istanbul instance that "Me" wasn't available as a default value, only as a filter. If you don't see "Me" as an option for your default value, navigate to System Definition> Dynamic Filter Options, find "Me" and check the box that allows it to be used for a default value.