Can you add a variable editor from a parent to child record?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 09:26 AM
This question has been asked a few times over the past few years but I don't see a definitive answer.
Scenario:
1) You have a Case record producer that generates a Case.
2) The agent determines an Incident needs to be generated and creates a child Incident
3) We want the child incident record to have the original variable editor as the case does so all the information from the original form is visible

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 04:27 PM
You could potentially clone the com_glideapp_questionset_default_question_editor ui macro and create a new one where instead of using "current.getUniqueValue()" you pass in the sys_id of the parent record for the incident.
I had a similar requirement recently, and what I did instead was
- Fire a custom event "map_producer_vars_to_child_record"
- Use a script action to copy the question_answer, sc_multi_row_question_answer, and sc_item_produced_record entries...effectively duplicating them to the child record
This would have a momentary delay, but allowed for the incident to appear as if the record producer created it.
Example script, will need to adjust for your needs
(function mapVars(current /**Case Record**/, childTable , childSysId){
var tableName = current.getTableName();
var childRecordGR = new GlideRecord(childTable);
if(!childRecordGR.isValid())
throw new Error(gs.getMessage("Invalid Table provided for variable mapping.\n Case: {0} \n Child Table {1} , Child ID {2}" , [current.getDisplayValue() , childTable , childSysId]));
if(!childRecordGR.get(childSysId))
throw new Error(gs.getMessage("Invalid Record ID provided for variable mapping.\n Case: {0} \n Child Table {1} , Child ID {2}" , [current.getDisplayValue() , childTable , childSysId]));
var qaMap = {};
var qaGR = new GlideRecord("question_answer");
qaGR.addQuery("table_name" , tableName);
qaGR.addQuery("table_sys_id", current.getUniqueValue());
qaGR.query();
while(qaGR.next()){
var existingVal = qaGR.getUniqueValue();
qaGR.setValue("table_name" , childRecordGR.getTableName());
qaGR.setValue("table_sys_id" , childRecordGR.getUniqueValue());
var newVal = qaGR.insert();
qaMap[existingVal] = newVal;
}
var mrqGR = new GlideRecord("sc_multi_row_question_answer");
mrqGR.addQuery('parent_table_name' , tableName);
mrqGR.addQuery('parent_id' , current.getUniqueValue());
mrqGR.query();
while(mrqGR.next()){
mrqGR.setValue("parent_table_name" , childRecordGR.getTableName());
mrqGR.setValue("parent_id" , childRecordGR.getUniqueValue());
var qaNew = qaMap.hasOwnProperty(mrqGR.getValue('question_answer')) ? qaMap[mrqGR.getValue('question_answer')] : mrqGR.getValue('question_answer');
mrqGR.setValue('question_answer' , qaNew);
mrqGR.insert();
}
var itemProducedGR = new GlideRecord("sc_item_produced_record");
itemProducedGR.addQuery("task" , current.getUniqueValue());
itemProducedGR.setLimit(1);
itemProducedGR.query();
if(itemProducedGR.next()){
itemProducedGR.setValue("task" , childRecordGR.getUniqueValue());
itemProducedGR.setValue("record_table" , childRecordGR.getTableName());
itemProducedGR.setValue("record_key" , childRecordGR.getUniqueValue());
itemProducedGR.insert();
}
})(current, event.parm1 , event.parm2);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2022 11:22 AM
I have question here. Variables are not read only... Are those variables editable from child record? I tried but it's not updating when edit and save.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2023 01:35 AM
Thanks for posting , it's really helpful we can modify OOTB UI Macro(line 9) to add our child record as -catItemProducedGr.addQuery("record_key", current.getUniqueValue()).addOrCondition("record_key", current.parent.getUniqueValue());
No Impact.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2024 07:29 AM
My Company just had to do this. I created scoped application extended from the task table. When a record producer is used to create a ticket and then may need to be split off into child tasks.
Mine works with multi row variables (MRVS) too. We have multiple MRVS that need to be passed into the child task.
Steps
1. Create a ui macro - based off the default question editor
3. add the variable editor to your form from configure form option