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 11:29 PM
are you sure you are using correct variable name for requested_by
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:33 PM
yes that is correct. tho the requested by field is on a variable set (core_opened_by_for).
So I tried to do it like:
task.sys_created_by = current.variables.core_opened_by_for.requested_by.user_name;
But it didn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2023 01:57 AM
you need not use variable set name while accessing variable value
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-14-2023 01:12 AM
I just used BR for this concern. Now the Created by is correct.
Anyway, thanks for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 10:33 PM
Hi @ss123 ,
Try using ,
task.sys_created_by = current.variables.requested_by;
Thanks and Regards,
Rahul