- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2021 12:13 AM
Hi,
Below is the workspace client script which I am using on a UI action,
function onClick(g_form) {
var fields = [{
type: 'reference',
name: 'u_duplicate_incident',
label: getMessage('Duplicate Incident'),
mandatory: true,
reference: 'incident',
referringTable: 'incident',
referringRecordId: g_form.getUniqueValue()
}];
g_modal.showFields({
title: "Provide Duplicate Incident",
fields: fields,
size: 'sm'
}).then(function(fieldValues) {
g_form.setValue('close_code', 'Duplicate Incident');
g_form.setValue('close_notes', 'This is a duplicate Incident');
g_form.setValue('short_description', "Duplicate Incident -" + g_form.getValue('short_description'));
g_form.setValue('u_duplicate_incident', fieldValues.updatedFields[0].value);
g_form.save();
});
}
Right now I use g_form save() to save the form which I don't recommend to do that. I need to resolve the incident from ui action once client script job is done.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2021 02:43 AM
It worked.
Rather than calling g_form.getActionName() we can directly pass the action name.
g_form.submit('action_name');
In my case below is the final code,
function onClick(g_form) {
var fields = [{
type: 'reference',
name: 'u_duplicate_incident',
label: getMessage('Duplicate Incident'),
mandatory: true,
reference: 'incident',
referringTable: 'incident',
referringRecordId: g_form.getUniqueValue()
}];
g_modal.showFields({
title: "Provide Duplicate Incident",
fields: fields,
size: 'sm'
}).then(function(fieldValues) {
g_form.setValue('close_code', 'Duplicate Incident');
g_form.setValue('close_notes', 'This is a duplicate Incident');
g_form.setValue('short_description', "Duplicate Incident -" + g_form.getValue('short_description'));
g_form.setValue('u_duplicate_incident', fieldValues.updatedFields[0].value);
g_form.submit('validate_check_duplicate');
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2021 12:35 AM
Hi Vikram ,
You can use the g_form.submit to run the server side of ui action
g_form.submit(g_form.getActionName());
It will resolve the issue
Please mark the answer correct / helpful if it helped you.
Regards,
Amit Gujarathi
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2021 02:19 AM
Hi Amit,
Thanks. I did try that but it's not working. State is not changed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2024 03:59 AM
Hi @Amit Gujarathi ,
I want to pass a value from client ui action to server ui action may be by using g_form.getActionName().
Could you please help on this?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2021 02:35 AM
Hi,
using g_form.save() it is working fine right?
if yes then what's the issue using that
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader