I have a requirement to create incident record from HR case, I was trying the below logic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I have create new UI action with below logic in UI action with client box checked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
in your UI Action, your server-side logic (the setRedirect() function with GlideRecord) is not wrapped inside the if (g_form.submitted()) or if (action == 'hr_create_incident').
That’s why it’s never triggered.
// This runs client-side when the UI Action button is clicked
function hr_create_incident() {
if (g_form.getValue('cmdb_ci') == "") {
g_form.setDisplay('cmdb_ci', true);
g_form.setMandatory('cmdb_ci', true);
g_form.showFieldMsg('cmdb_ci', 'Please select the appropriate CI', 'error');
return false;
}
g_form.showFieldMsg('cmdb_ci', 'Appropriate CI is selected', 'info');
// Submit to server-side part of this UI Action
gsftSubmit(null, g_form.getFormElement(), 'hr_create_incident');
}
// This runs ONLY on the server side
if (typeof window == 'undefined') {
if (action == 'hr_create_incident') {
gs.info('executing server side script');
var inc = new GlideRecord('incident');
inc.initialize();
inc.short_description = current.short_description;
inc.caller_id = current.subject_person;
inc.insert();
}
}
try this .. and if it doesn't work you can make separate script include and call it in ui action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
@garimakharb - This still doesn't seems to be working