g_form.disableAttachment() function is corrupting attachment in CSM and SOW workspace
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
26m ago
I have configured an onLoad Client Script on the Task table to hide/disable the attachment option based on the current record’s Offering.
The script works correctly in Native UI, but I am seeing an issue in CSM/SOW Workspace:
- I open a non-restricted Offering record and can add attachments normally.
- Then I open a restricted Offering record. The attachment icon is still visible, but I cannot select or add an attachment because + icon or select attachment option is not there (it is expected)
- After that, if I open the non-restricted Offering record again, I am also unable to add attachments there.
It looks like the attachment state from the restricted record is being carried over to the next record in Workspace.
Could you please help me understand why this is happening in CSM/SOW Workspace, while the same Client Script works correctly in Native UI?
var IN_SCOPE_TABLES = [
'sn_customerservice_case',
'sn_customerservice_task',
'incident',
'incident_task',
'change_request',
'change_task'
];
// Important for CSM/SOW Workspace navigation:
// reset any attachment state carried from the previous record.
g_form.enableAttachments();
var tableName = g_form.getTableName();
if (IN_SCOPE_TABLES.indexOf(tableName) === -1) {
return;
}
var offering = g_form.getDisplayValue('u_offering');
// No offering -> attachments stay enabled.
if (!offering) {
return;
}
var recordSysId = g_form.getUniqueValue();
var requestedOffering = offering;
var ga = new GlideAjax('AttachmentRestrictionForResolverUtil');
ga.addParam('sysparm_name', 'getRestrictedOfferings');
ga.getXMLAnswer(function(answer) {
// Protect Workspace against an old asynchronous callback
// affecting a newly opened record.
if (g_form.getUniqueValue() !== recordSysId) {
return;
}
if (!answer) {
g_form.enableAttachments();
return;
}
var restrictedOfferings = answer.split(',').map(function(item) {
return item.trim().toLowerCase();
});
var currentOffering = g_form.getDisplayValue('u_offering');
// Offering changed while GlideAjax was executing.
if (currentOffering !== requestedOffering) {
return;
}
if (restrictedOfferings.indexOf(
currentOffering.trim().toLowerCase()
) !== -1) {
g_form.disableAttachments();
} else {
g_form.enableAttachments();
}
});
}
0 REPLIES 0