Document ID transform Map

free
Kilo Contributor

Hi,

How can i map any value to document Id type field in transform Map?

1 ACCEPTED SOLUTION

Joe McCarty1
ServiceNow Employee
ServiceNow Employee

I'm not certain why we are calling the script include and querying the dictionary at all as we already know the tables because they are being used to generate the query.   If the intent is that I don't know what table my id is for so I want it to try multiple tables then you can do something like the following untested script:



var tables = ['kb_category','kb_knowledge_base'];


var id = "25cd15c3ac6c728056e1781325626541";



for (var i = 0; i < tables.length; i++) {


        var gr = new GlideRecord(tables[i]);


        if (gr.get(id)) {


                  target.parent_table = tables[i];


                  target.parent_id = id;


                  break;


        }


                 


}



But if you know the table, it should be as simple as:



target.parent_table = "kb_knowledge_base";


target.parent_id = "25cd15c3ac6c728056e1781325626541";


In either case, I would remove the field mapping entries in favor of the on before script to guarantee ordering.


View solution in original post

18 REPLIES 18

Joe McCarty1
ServiceNow Employee
ServiceNow Employee

The document id is usually just the sys_id, but it is paired with another field indicating the table.   Unfortunately, the name differs from table to table.   Look for a field labeled 'table', 'target_table', 'source_table' or something similar.   Or if you don't like guessing, look up the dependent field on the document_id dictionary entry for the table in question


free
Kilo Contributor

i have parent_id as a document_id and it depends on parent_table. In which format should I return the value in document_id field.


Joe McCarty1
ServiceNow Employee
ServiceNow Employee

The value of the document_id field is a sys_id.   The display value is then built using the label of the dependent table field + ':' + display value of the target record with that sys_id in the target table.   But when assigning the value to document_id in a script it should just be the sys_id.


so should I return the sys_id of document field of document_id field? I tried this but it is not working.