UI Action in the workspace - Ui Script or custom modal in Workspace Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 12:43 AM
Hi all,
I am trying to make a UI Script working in the Workspace Client Script.
I made the UI Page load inside the modal in the workspace, but there is no functionality on the buttons when loaded.
This is the code in the UI Action.
Script:
function assessRisk () {
ScriptLoader.getScripts(['sn_risk_advanced.AssignFormUtils.jsdbx'], function() {
sn_risk_advanced.AssignFormUtils.assignAssessorApprover();
});
}
Workspace client script
function onClick() {
var ui_page_id = '615212a0532300101bfbddeeff7b12a2';
g_modal.showFrame({
url: '/ui_page.do?sys_id=' + ui_page_id,
title: 'Add Assessor and Approver',
size: 'l',
});
}
This is how it looks in the backend and also what is wanted in the workspace
I also tried to make a custom modal, but this doesn't seem to be working as expected.
See the code for this below.
function onClick(g_form) {
var fields = [
{
type: 'reference',
name: 'name',
label: getMessage('Assessor'),
mandatory: true,
reference: 'sys_user',
value: g_form.getValue('name'),
displayValue: g_form.getDisplayValue('name')
},
{
type: 'reference',
name: 'approver_id',
label: getMessage('Approver'),
mandatory: false,
reference: 'sys_user',
referringTable: 'sn_risk_advanced_event',
referringRecordId: g_form.getUniqueValue(),
value: g_form.getValue('approver_id'),
displayValue: g_form.getDisplayValue('approver_id'),
query : "roles=sn_risk_advanced.ara_approver^active=true^EQ",
}
];
g_modal.showFields({
title: "Add Assessor and Approver",
fields: fields,
size: 'lg'
}).then(function(fieldValues) {
g_form.setValue('assessor_id', fieldValues.updatedFields[0].value);
g_form.setValue('approver_id', fieldValues.updatedFields[2].value);
g_form.save();
});
}
If anybody could help out, would be really appreciated,
Regards,
Jonas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 04:08 AM
Hi @Jonas VK ,
Can you change your workspace client script to the below and check if it works.
function onClick(g_form) {
var ui_page_id = '615212a0532300101bfbddeeff7b12a2';
yourFunction(datafromframe){
//Logic inside
g_form.submit('your_action_name');
}
g_modal.showFrame({
url: '/ui_page.do?sys_id=' + ui_page_id,
title: 'Add Assessor and Approver',
size: 'l',
callback: function (op, data) {
if (op)
yourFunction(data);
}
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 08:53 AM
We have the similar requirement however unable to make a progress. We did tried your script @Dibyaratnam however it shows ; error on the 3rd line.
is there any luck on this ask? @Jonas VK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 09:27 PM
What error are you getting, can you share screenshot ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 04:08 AM
Hi, I am trying to replicate the same "Assess Risk" button in the workspace but somehow could not do it. Any success regarding this?