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

Can you show me what you have in your map?


My source script is,



answer = (function transformEntry(source) {


  return "25cd15c3ac6c728056e1781325626541";   //return IT Knowledge Base sys_id.


})(source);



and


traget field is parent_id


Joe McCarty1
ServiceNow Employee
ServiceNow Employee

Ok, since it looks like that ID is coming from the Knowledge bases table, make sure you have another field mapping that maps to the dependent table field (parent_table, I think you said):



answer = (function transformEntry(source) {


  return "kb_knowledge_base";


})(source);


Joe McCarty1
ServiceNow Employee
ServiceNow Employee

I should also ask if you are mapping the table name into the dependent table field.   Both fields need to be set for the Document ID field to render properly.


free
Kilo Contributor

Capture.PNG


this is my transform map. but it is not working?


in my parent_table values comes from script include.