How to get the user id of the Opened by to Created by in sctask (in workflow script)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 08:44 PM
Hi everyone,
I would like to check if how can I get the user id of the Opened by in SCTask to Created by field.
Here's a screenshot for reference.
The script i'm using in workflow catalog task is not working:
task.sys_created_by = task.opened_by.user_id;
Thanks in advance!
- Labels:
-
ITSM
-
ITSM: General
-
scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 08:51 PM
opened_by will be the logged in user? i.e. the user in whose session the workflow activity runs
if yes then do this
task.sys_created_by = gs.getUserName();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 10:22 PM
No, the Opened by is from the variable "Requested by"
I need to get the user_id of the Variable Requested by / Task.opened_by and place it to the Task.sys_created_by
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 11:04 PM
then do this
task.sys_created_by = current.variables.requested_by.user_name;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 11:14 PM
Still not working 😞