- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2015 10:48 PM
Hi there,
Actually we have a catalog item in our instance for Employee termination. Once we submit the form by selecting an user to terminate we are deactivating that user in User table.
We have done deactivation of the user in workflow Run scripts, the script is working fine its deactivating the user. But updated by of the user record is showing as whoever is the person submits the form. I need to set updated by here as system.
Could somebody pls let me know how can we do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2015 10:02 PM
This will be a little bit of a hack, but it may work...
Dynamically creating a schedule job and add the script in there that does the update . It will be important to later have another script (perhaps in a scheduled job) that purges the schedule jobs you dynamically create.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2015 10:07 PM
Hi ashok777, do you believe we can close this thread by marking the responses as helpful/correct?
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 06:15 PM
Hello,
I know this post is marked as answered, but I found myself having to dig quite a bit to find out how to do this via a Transform Map. So Im piggy-backing this thread in order to spread some knowledge.
Edit: I have found and confirmed a very simple solution that is scalable:
I have confirmed that you can update system fields such as sys_updated_by and most other sys_ fields using a Transform Map with minimal Script. My instance is currently a Fuji release.
1. Create your Transform Map like normal with your source table, target table, and all of your fields mapped like normal.
2. Check the "Run business rules" box so that it remains unchecked.
3. Check the "Run script" box so that it remains checked.
4. In the script box make sure to add:
- //Make sure update is only done on existing records
- if ( action == "insert") {
- ignore = true;
- }
- /* Disable SN from auto updating sys_fields */
- //Needed in order to leave historical information unchanged
- target.autoSysFields(false);
- //Disable the running of business rules that might normally be triggered by SN.
- target.setWorkflow(false);
5. At the bottom left, in the Field Maps tab/list, create a new field map
Create a new mapping from your target import table to your sys_ field that you want to update
6. Save, upload your data, and run your transform.
Hope that helps someone out there!
You can also find a method using Glide Records here: https://community.servicenow.com/thread/162539