UI Action in the workspace - Ui Script or custom modal in Workspace Client Script

Jonas VK
Tera Guru

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

JonasVK_0-1700642425320.png


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

6 REPLIES 6

Dibyaratnam
Tera Sage

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);
			}
    });
}

 

Harpreet Walia
Tera Contributor

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 

What error are you getting, can you share screenshot ?

Bharti Choudhar
Tera Contributor

Hi, I am trying to replicate the same "Assess Risk" button in the workspace but somehow could not do it. Any success regarding this?