- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2022 11:39 AM
I am trying to write a script that will set the Opened For user when a case is submitted. This is what I want it to do: if the logged in user is a member of the specified group, the Opened For on the case should be equal to the Position Manager value (a variable on the record producer).
Below is what I have before but it keeps telling me a user is not found. I think it has to do with the variable being a Single Line Text Variable and not a reference, but I'm not sure. Is this even possible to accomplish?
if (gs.getUser().isMemberOf("f65370019f22120047a2d126c42e705c")) {
current.opened_for = producer.employee_details_position_manager.user;
}
new sn_hr_core.hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 07:03 AM
Hi,
you can query sys_user table with the field against which the value is entered
what does the position manager show? user_name or name of the user?
Based on that you can query and get the sys_id
For example I am querying with name field
if (gs.getUser().isMemberOf("f65370019f22120047a2d126c42e705c")) {
var gr = new GlideRecord("sys_user");
gr.addQuery("name", producer.employee_details_position_manager);
gr.query();
if (gr.next()) {
current.opened_for = gr.getUniqueValue();
}
}
new sn_hr_core.hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);
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
05-27-2022 11:55 AM
Hi there,
It looks like your position manager is a single line text? Then dotwalking will never work.
Can you explain functionally where that .user should come from?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 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
05-31-2022 06:58 AM
Yes, it is a single line text. The position manager will populate based on the employee/position that the user chooses when submitting the case. I want the opened for to match what populates in that box, but I'm not sure how because it isn't a reference field. Any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 07:03 AM
Hi,
you can query sys_user table with the field against which the value is entered
what does the position manager show? user_name or name of the user?
Based on that you can query and get the sys_id
For example I am querying with name field
if (gs.getUser().isMemberOf("f65370019f22120047a2d126c42e705c")) {
var gr = new GlideRecord("sys_user");
gr.addQuery("name", producer.employee_details_position_manager);
gr.query();
if (gr.next()) {
current.opened_for = gr.getUniqueValue();
}
}
new sn_hr_core.hr_ServicesUtil(current, gs).createCaseFromProducer(producer, cat_item.sys_id);
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
05-31-2022 12:46 PM
Thank you so much, that makes sense and it worked!