variables may still be populated on the generated RITM! Need to check with ServiceNow if this is a known issue > UPDATE: you need to tick the run on RITM and task checkboxes, as well as the cat item
However, another issue occurs whereby variables are blanked when you add to the cart. Referred this back to ServiceNow who came back with this update:
So in
order to fix the issue we need to create duplicate UI policy where we need to
select "clear the variable value" set to "false" and
uncheck the "on load" option from the UI policy. 6. Another UI policy
where "clear the variable value" set to "true" and check
the "on load" option from the UI policy.
====
workaround - uncheck the 'clear variable value' flags (so it also works when adding item to the cart as opposed straight checkout)
onSubmit client script code:
(g_form.isVisible only works in SP)
//--Pop this into an onSubmit client script – must use setValue “” (clearValue doesn’t seem to work)
//--loop through variables--as the ui policy action 'clear variable value' not working on the generated RITM
var emptyVariables = [];
var populatedVariables = [];
if (typeof spModal != 'undefined') {
//--loaded from Service Portal
var allFields = g_form.getFieldNames();
for (var fieldName in allFields) {
var fieldLabel = allFields[fieldName];
var fieldVal_p = g_form.getValue(fieldLabel).toString();
if (fieldVal_p == '' || g_form.isVisible(fieldLabel) == false) {
if (fieldVal_p != 'false') {
//emptyVariables.push(fieldLabel+': ' + fieldVal_p);
g_form.setValue(fieldLabel, '');
}
} else {
//populatedVariables.push(fieldLabel+': ' + fieldVal_p);
}
}
//alert('emptyVariables: ' + emptyVariables.toString());
//alert('populatedVariables: ' + populatedVariables.toString());
//return false;//--testing only
} else {
var sRT = g_form.getValue('sn_request_type'); if (sRT != 'Update') {
g_form.setValue('sn_group_type_to_update', '');
}
if (sRT != "Deactivate") {
g_form.setValue('sn_group_type_to_deactivate', '');
}
var allVariables = document.getElementById('variable_map').getElementsByTagName('item');
for (var i = 0; i < allVariables.length; i++) {
try {
var item = allVariables[i];
var itemName = item.getAttribute('qname').toString();
//alert(item.id);
var item_el = document.getElementById(g_form.resolveNameMap(itemName));
//alert(itemName + ' ' + window.getComputedStyle(item_el).display);
var iWidth = (item_el.offsetWidth);
var iHeight = (item_el.offsetHeight);
var bProceed = true;
if (sRT == 'Deactivate' && itemName == 'sn_group_to_deactivate') {
bProceed = false;
}
if (sRT == 'Update' && itemName == 'sn_group_type_to_update') {
bProceed = false; //--do not blank visible reference fields
}
if (bProceed && iWidth == 0 && iHeight == 0 && g_form.getValue(itemName) != 'true') {//--do not blank checkbox
//alert("blanking item " + itemName);
g_form.setValue(itemName, '');
}
} catch (ex) {
}
}
}
}
Comments
Post a Comment