Create Request UI Action button on Interaction form in SOW
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2025 09:48 AM
Hi All,
I'm facing a challenge in SOW workspace in leveraging the code behind the "Create Request" UI action button on interaction form. We have a requirement to open the selected catalog item if Request category is chosen on interaction form. So, I'm writing Onsubmit Client script as shown below. I'm leveraging the same code written for OOB "Create Request" UI action workspace client script.
function onSubmit() {
var catalogItemSysId = g_form.getValue('u_catalog_item');
var category = g_form.getValue('category');
if (category === 'sc_request') {
var params = {};
params.sysparm_parent_table = "interaction";
params.sysparm_parent_sys_id = g_form.getUniqueValue();
setTimeout(function() {
g_service_catalog.openCatalogItem('sc_cat_item', catalogItemSysId, params);
}, 1000);
return true;
}
}
Once the interaction form is saved, it opens the selected catalog form in new tab within workspace and request can be submitted. Now, I'm stuck at how to relate the interaction record and the request that is created. In the workspace client script, i see the parameters are being passed sysparm_parent_table=interaction but not sure where exactly they are retrieving the url parameters and setting the "parent_interaction" field on request table. I've checked the OOB business rule on sc_request table and do not see anything related to retrieving parameters. Below is the after update OOB business rule on sc_request table. In my scenario, it is failing at the condition in the business rule and not moving further.
Condition: current.parent_interaction.changes() && !current.parent_interaction.nil()
(function executeRule(current, previous /*null when async*/) {
if (!previous.parent_interaction.nil()) {
var gr = new GlideRecord('interaction_related_record');
gr.addQuery('document_id', current.sys_id);
gr.addQuery('document_table', current.getTableName());
gr.query();
if (gr.next()) {
gr.interaction = current.parent_interaction;
gr.update();
return;
}
}
else {
var gr = new GlideRecord('interaction_related_record');
gr.initialize();
gr.document_id = current.sys_id;
gr.operation = current.operation() == "insert" ? "Created" : "Updated";
gr.document_table = current.getTableName();
gr.interaction = current.parent_interaction;
gr.insert();
}
})(current, previous);
There is a relation ship query from task table that applies to interaction table with below query and still do not see how they are retrieving the url parameters here as well.
(function refineQuery(current, parent) {
current.addEncodedQuery("SUBQUERYsys_id,document_id,interaction_related_record^interaction=" + parent.sys_id + "^ENDSUBQUERY");
})(current, parent);
0 REPLIES 0