- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2016 04:55 PM
Hi all,
I am trying to set the value of document ID type field using script.
I tried to assign the sys id directly but its not working.
can someone throw some light?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2016 06:06 PM
A sys_id is useless without a knowing what table the record resides on.
Alas, a Document ID field needs to be coupled with a Table Name field.
First you will need to create a 'Table Name' field (let's say 'u_table').
Once you have done that,open the Dictionary entry of your Document ID field and set the dependent field to 'u_table'.
Then you can write the following code
current.u_table = 'incident';
current.u_doc_id = SYS_ID;
current.update();
Or set in via the UI, setting the u_table field first.
I hope this helps
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2016 06:06 PM
A sys_id is useless without a knowing what table the record resides on.
Alas, a Document ID field needs to be coupled with a Table Name field.
First you will need to create a 'Table Name' field (let's say 'u_table').
Once you have done that,open the Dictionary entry of your Document ID field and set the dependent field to 'u_table'.
Then you can write the following code
current.u_table = 'incident';
current.u_doc_id = SYS_ID;
current.update();
Or set in via the UI, setting the u_table field first.
I hope this helps
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2016 06:06 PM
It needs a source table. I did it in approval like this:
var appr = new GlideRecord('sysapproval_approver');
appr.initialize();
appr.source_table = 'change_request';
appr.sysapproval = 'a9e9c33dc61122760072455df62663d2';
appr.document_id = 'a9e9c33dc61122760072455df62663d2';
appr.insert();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2016 06:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 04:01 AM
if i want to map any value to doucment Id in transform map, then??