Default value to auto-populate cost center of Requested for user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2021 07:05 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2021 07:06 AM
Hi there,
Should this happen onLoad or onChange?
For onLoad:
var gr = new GlideRecord('sys_user');gr.get(gs.getUserID());gr.getValue('cost_center');
For onChange:
Catalog Data Lookup Definition on any table, eliminating Catalog Client Scripting
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2021 07:12 AM
I believe I want it to happen onLoad when the form loads. The requested for automatically populates to the signed in user. I want this variable to automatically populate with the signed in user's cost center.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2021 07:13 AM
Hi,
this should work fine and would store the logged in user's cost center
if the user is changed then you would require onChange client script to populate cost center as well.
Either use getReference with callback method or GlideAjax to populate the Cost center in the onChange client script of Requested For
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
04-26-2021 07:25 AM
Hi Ankur,
It doesn't appear to be working for any of my items. Would you happen to know why?