Record Producer_HRSD > > where is the variable data stored
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2024 03:17 PM - edited 12-09-2024 04:10 PM
Scenario: HR Service and appropriate Record Producer is configured. Employee submits all the details on the record producer and submits. HR Case is created.
1. If an HR Agent/ Manager/ Admin wants to view the Variable input data what the EE had submitted, how can they view it (especially if its not mapped to any field in HR Case - New/Existing field is not created and there is no Record producer script) Is there a way to see the Variable value for HR Service Record Producer within the HR Case form (Variable Editor? does that work with HR Cases?)
2. if HR agent has to create the same case for an Employee but from the platform view (Admin View - Create a HR Case), how can they capture the record producer variable values in this scenario when using the platform view?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2025 07:39 AM
Sure thing, that should be the latest one:
(function executeRule(currentRecord, previousRecord /*null when async*/) {
var dynamicProducer = currentRecord.hr_service.producer; // Set the record producer dynamically based on the current HR case
var uniqueRecordKey = currentRecord.sys_id.toString();
var currentTableName = currentRecord.getTableName();
/* Retrieving Variable Set Data */
var varSetList = []; // Array to store the sys IDs of the variable sets linked to the respective record producer
// Query the variable sets linked to the current record producer to include them in the variable search for item_option_new
var grVarSets = new GlideRecord('io_set_item');
grVarSets.addQuery('sc_cat_item', dynamicProducer);
grVarSets.orderBy('order');
grVarSets.query();
while (grVarSets.next()) {
// Add each variable set sys ID to the array
varSetList.push(grVarSets.getValue('variable_set'));
}
/* Retrieving Variables */
var varList = []; // Array to store all the variables (both directly attached to the record producer and inherited from the variable sets)
// Query for variables directly linked to the record producer as well as those inherited from the variable sets
var grVars = new GlideRecord('item_option_new');
var grVarsQuery = grVars.addQuery('cat_item', dynamicProducer); // For instance, "Create Incident" on PDI testing
// Add an OR condition to fetch variables inherited from the variable sets of the current record producer
if (varSetList.length >= 1) {
grVarsQuery.addOrCondition('variable_set', 'IN', varSetList.join()); // Get inherited variables based on the sys IDs of the variable sets
}
grVars.addActiveQuery();
grVars.orderBy('order');
grVars.query();
while (grVars.next()) {
// Check if the variable belongs to a variable set and get its order
var parentVarSetOrder = "";
var hasParentVarSet = false;
if (!grVars.variable_set.nil()) {
parentVarSetOrder = grVars.variable_set.order.toString();
hasParentVarSet = true;
}
// Add each variable’s sys ID and order to the array for later use when creating new records
varList.push({
"sys_id": grVars.getValue('sys_id'),
"order": grVars.getValue('order'),
"has_parent_vs": hasParentVarSet,
"parent_vs_order": parentVarSetOrder // Store the parent variable set order (if available)
});
}
/* Creating question_answer Records */
for (var i = 0; i < varList.length; i++) {
var grQARecord = new GlideRecord('question_answer');
grQARecord.newRecord();
grQARecord.question = varList[i].sys_id;
var orderIncrement = 10; // Define the gap between sibling variables in the order
// Adjust the order if the variable has a parent variable set
if (varList[i].has_parent_vs && varList[i].parent_vs_order !== "") {
var parentOrderValue = parseInt(varList[i].parent_vs_order);
var childOrderValue = i * orderIncrement; // Adjust child order based on its position among siblings
var finalOrderValue = parentOrderValue + childOrderValue;
grQARecord.order = finalOrderValue;
} else {
// For top-level variables or those without a parent variable set, apply a basic order with incremental gaps
grQARecord.order = parseInt(varList[i].order) + i * orderIncrement;
}
grQARecord.table_name = currentTableName;
grQARecord.table_sys_id = uniqueRecordKey;
grQARecord.insert();
}
/* Creating sc_item_produced_record */
// Create a new record in sc_item_produced_record to ensure that UI Policies are triggered correctly
var grProducedItem = new GlideRecord('sc_item_produced_record');
grProducedItem.newRecord();
grProducedItem.record_key = uniqueRecordKey;
grProducedItem.task = uniqueRecordKey;
grProducedItem.record_table = currentTableName;
grProducedItem.producer = dynamicProducer;
grProducedItem.insert();
})(currentRecord, previousRecord);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 09:10 AM
Hi,
Here are instructions needed to configure the variable editor for a task-extended table:
After you configure the default variable editor for a task-extended table, you can view and edit the values of questions specified by the requester in the record producer. Applicable only for records generated by a record producer.
Before you begin
Role required: admin
Procedure
Create a formatter for the task-extended table.
Navigate to System UI > Formatters.
Click New.
On the form, fill the fields.
Field Description
Name The name of the formatter that is displayed in the form of the task-extended table.
Formatter The file name of the formatter. In this case, specify com_glideapp_questionset_default_question_editor.
Table The table that uses the formatter.
Active Specifies if the formatter is active.
Type The type of the formatter. In this case, specify Formatter.
UI formatter
Screenshot for the UI formatter.
Click Submit.
Add the formatter to the form of the task-extended table.
The formatter is displayed on the form according to your selections.
From the Additional Actions Icon for additional actions. menu on the form, select Configure > Form Layout.
Use the list to select the display order for the formatter field.
Add a formatter to a form
Screenshot for adding a formatter to a form.
Click Save.
The default variable editor is available on the form.
Default variable editor
Screenshot for the default variable editor.
Product Doc link below:
