How to set value in document_id type of field from transform map?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2023 04:46 AM
Hi all,
There is this field 'Parent ID' of document_id type on 'knowledge category' table.
If you click magnifying glass of Parent ID, one dialog will pop up showing two fields, viz Table Name and Document.
Table name has choices knowledge base and knowledge category and based on what u selected of them, you will get values in 'Document' field.
so based on what u have selected, parent id will be as Table name: Knowledge Category
I have created one transform map, where from onAfter transform script, i am getting values for this document we can say. But i was not sure that how we can set value of that document_id field as Table Name: Document.
I hope you got me, attaching screenshot and transform script as well, please let me know how can i make this work
Thanks in advance!!
OnAfter transform script:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var s = source.u_parent;
gs.log("source value..." + s);
var z;
var gr = new GlideRecord("kb_knowledge_base");
//gr.addQuery("title",s);
gr.addEncodedQuery("active=true^title=" + s);
gr.query();
if (gr.next()) {
z = gr.sys_id;
}
//Knowledge Base: Retail C4- Knowledge Base
gs.log("log message,,,,." + z);
var d= "Knowledge Base"+z;
// target.setValue("parent_id",d );
//target.update();
target.parent_id = z;
target.update();
//f28989b52f596110186bf21df699b6df;
})(source, map, log, target);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2023 05:08 AM
Hi @akshayp ,
To set the value of the document_id field based on the selected values of the "Table Name" and Document fields in the pop-up dialog, you can modify your transform script as below
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var tableName = source.u_parent.u_table_name; // Get the selected Table Name value
var document = source.u_parent.u_document; // Get the selected Document value
// Construct the parent ID value as "Table Name: Document"
var parentId = tableName + ": " + document;
target.parent_id = parentId; // Set the value of the document_id field to the parent ID
target.update(); // Update the target record with the new value
})(source, map, log, target);
Regards,
Shravan
Please mark this as helpful and correct answer, if this helps you
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2023 05:24 AM
@Sai Shravan Thanks for replying, i tried this but still Parent ID shows empty.