- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 11:32 PM
Hi Community,
I have a requirement, in catalog form there is a field called "cost center for shipping" (single line text) in this field the cost center of the logged in user need to be populate in the field.
In user form there is field called cost center that value needs to be populate in the field.
user form:
Thanks in advance
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 01:38 AM - edited 11-22-2023 01:41 AM
Can you try below
javascript:gs.getUser().getRecord().getDisplayValue('u_cost_center');
Please note that getValue will give you sys id of the cost center so if you want the display value, use getDisplayValue() instead.
also in above reponse of yours to get record you should not dot walk with .getUserID(), that is to return the sysID of logged in user specifically.
Hope that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 11:42 PM
Hi @suuriya ,
Go through this thread and you should be able to write a similar script for autopopulating cost center from the required table.
https://www.servicenow.com/community/developer-forum/populate-field-value-based-on-another-field-usi...
Thanks,
Sonam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 12:41 AM
HI @Sonam_Tiwari ,
Thanks for the reply i checked but all are based on onchange script but i need to populate cost center of the logged in user and not based on changing value of the field.
i tried something like this in default value of the cost centre field/variable
javascript:gs.getUserID().u_cost_center();
but it is not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 01:22 AM
Hi,
You can use it like:
gs.getUser().getRecord().getValue('u_cost_center')); // u_cost_center is backend field name
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 01:38 AM - edited 11-22-2023 01:41 AM
Can you try below
javascript:gs.getUser().getRecord().getDisplayValue('u_cost_center');
Please note that getValue will give you sys id of the cost center so if you want the display value, use getDisplayValue() instead.
also in above reponse of yours to get record you should not dot walk with .getUserID(), that is to return the sysID of logged in user specifically.
Hope that helps.