Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Workspace client script UI Action is not working

Rekha20
Tera Contributor

Hi All,

 

I have created a client callable UI action which is not wokring for workspace. Workspace client script code is below:

 

function onClick(g_form) {
var currentRecordSysId = g_form.getUniqueValue();
var caseNumber = g_form.getValue('number');
alert(caseNumber);
var assignedTo = g_form.getValue('sys_created_by');
var assignmentGroup = g_form.getValue('assignment_group');
var shortDescription = g_form.getValue('short_description');
var description = g_form.getValue('description');
var account = g_form.getValue('account');
var urgency = g_form.getValue('urgency');
alert("Clicked on the UI action");
var query = '';
query = query + '^u_parent_case=' + g_form.getUniqueValue();
g_aw.openRecord('sn_customerservice_sdm_management_task', '-1', {
'query': query
});

alert("After opening the record"); // Added for debugging purposes

var win = g_aw.openRecord();
alert(win); // Added for debugging purposes
win.onload = function() {
alert("Clicked on the UI action under the function");
var sdmTaskForm = win.g_form;
alert(sdmTaskForm);

sdmTaskForm.setValue('u_parent_case', currentRecordSysId);
sdmTaskForm.setValue('assignment_group', assignmentGroup);
sdmTaskForm.setValue('assigned_to', assignedTo);
sdmTaskForm.setValue('short_description', shortDescription);
sdmTaskForm.setValue('description', description);
sdmTaskForm.setValue('u_account_name', account);
sdmTaskForm.setValue('urgency', urgency);
sdmTaskForm.setValue('u_choice_8', '1');
sdmTaskForm.setValue('u_type', 'reactive');
sdmTaskForm.setValue('u_time_worked', '1');
sdmTaskForm.setValue('u_sdm_action_taken_to_address_issue', 'test');
sdmTaskForm.setValue('u_sdm_outstanding_pending_nextactions', 'test');
sdmTaskForm.setValue('u_action_being_requested_of_sdm', 'test');

var glideAjax = new GlideAjax('CustomUtils');
glideAjax.addParam('sysparm_name', 'getEscalationNumbers');
glideAjax.addParam('sysparm_source_record_sysid', currentRecordSysId);
glideAjax.getXMLAnswer(function(response) {
var escalations = response.split(',');

sdmTaskForm.setValue('u_mod_escalation', escalations.join(','));

sdmTaskForm.save(); // Trigger form submission
});
};
}

 

 

This is not triggering alert alert(win);

 

please help me with this.

 

Thanks,

11 REPLIES 11

Hi @Karan Chhabra6  Thanks for answering, Then how should I do that. I need to set value from parent record to child record. New form that is opening when clicking on button created on parent record. and child record has a field u_parent_case which refers to parent record.

 

Please help me with this.

Ram118
Mega Guru

Hi @Rekha20  

DId you got any solution for this ?

I am also facing similar kind of issue. If you got any solution, please let me know