How to auto-populate the user Company and Cost center code in the "x" variable of catalog item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2024 08:09 AM - edited 07-13-2024 08:10 AM
Hi All,
I want to auto-populate the Company and Cost center code of the "requested for" user without writing client script/ UI policies. I want update on the variable level. I tried by providing the default value as "javascript:gs.getUser().getCompanyID();". But, I'm just getting the SysID of the Company. Tried by giving alternative value as well, like CompanyName.. but not working
Can anybody please help me to get the correct value of the Company and cost center code together. As I don't have idea, which backend value to be provided under "Default"
Example., Netherland - NL
Thanks in Advance!
Regards,
Kruthika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2024 08:27 AM
Hi Kruthika BM!
You can try to compose a GlideRecord to get the actual company record like this:
javascript:new GlideRecord('core_company').get(gs.getUser().getCompanyID())
javascript:new GlideRecord('core_company').get(gs.getUser().getCompanyID()).name
Best regards,
Gabriel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 09:17 AM
Thank you, Gabriel, for the quick response. I try with this solution and if anything, else is needed, will get back to you.
Regards,
Kruthika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2024 08:57 AM
Hi @Kruthika BM
javascript:var u = gs.getUser(); var c = new GlideRecord(‘core_company’); c.get(u.getCompanyID()); c.name;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 09:18 AM
Thank you, Deepak, for the quick response. I'll try to implement the provided solution and if anything, else is needed, will get back to you.
Regards,
Kruthika