Call a UI Action from a Client Script to open a Change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2012 08:15 AM
**I'm sure this has been done, before just can't find anything on the forum so I'm asking.**
I am trying to call a UI Action from a Client Script. I have a onChange Client Script running from the Incident table that if the 'confirm' value is True I'd like to automatically open a related Change record. But it's not working...thoughts?
Here's the code that I wrote that's not working.
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '7' && !isLoading && g_form.getValue('rfc')=='') {
var rfc = g_form.getReference('rfc');
var answer = confirm('Was this Incident resolved by a Change? If yes press OK to create a Change Record. If No press Cancel.')
//force the Resolved by Change to Mandatory if OK
if (answer == true)
gsftSubmit(null, g_form.getFormElement('name'), 'Create Change');
else
g_form.setMandatory('rfc', false);
return;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2012 09:50 AM
Is your action name called, 'Create Change' or something like 'create_change'?
Here's a call oob that does what your looking for;
(source demo20)
gsftSubmit(null, g_form.getFormElement(), 'resolve_incident'); //MUST call the 'Action name' set in this UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2012 10:07 AM
I tried what you mentioned but it still isn't working. ANd yes the action is 'create_change'. I've tried it both ways but it only returns me to the Incident queue. Not sure what I'm doing wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2012 05:24 AM
Does it create the change record?
If you want to redirect the user to the newly created change record you would do something like this in your UI action.....
//creating the change record
var ch = new GlideRecord('change');
....
....
....
ch.insert();
action.setRedirectURL(ch);// to redirect the the user to the newly created change record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2012 10:22 AM
I tried adding it to the client script and it doesn't work.