- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2024 06:35 AM
Hello all,
Good evening.
I have created a button on Incident form.
UI action name: Escalate
So, the user should be able to click the button only twice.
SO, I have created a field "Escalation count" (u_escalation_count) of type integer on the Incident form.
So, once the user clicks on the button for the first time, the count has to be updated by 1.
When the user clicks the button for the second time, then count has to be updated by 2.
For this I have written a code, but the problem is,
The count is getting updated with 1 for the first time, but the second time, the value is updating with 2 but when I refresh the form, the value is again getting back to 1.
Please help me.
My Code:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2024 12:33 PM - edited 11-12-2024 12:57 PM
The following worked for me.
function doEscalate(){
var ec = g_form.getValue('u_escalate_count');
alert('doEscalate: ec = ' + ec);
if(ec==0){
g_form.setValue('u_escalate_count',1);
}
else if(ec==1){
g_form.setValue('u_escalate_count',2);
}
alert('doEscalate: submitting record, u_escalation_count = ' + g_form.getValue('u_escalation_count'));
g_form.submit();
current.update();
action.setRedirectURL(current);
}
That is, if the default value of your custom field is 0. If null, it doesn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2024 06:54 AM - edited 11-12-2024 06:55 AM
Hi @Pallavi65,
did you tried to understand by putting the logs. I think the setRedirect(); function may be not calling in the other case when ec==1. Please put some logs and check once this setRedirect(); function is calling or not.
and also try to inspect the browser and see if you are getting any errors. if Isolate script check box is checked in the UI action then please uncheck and see once.
Best Regards,
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2024 06:56 AM - edited 11-12-2024 06:58 AM
The line:
gsftSubmit(null,g_form.getFormElement(),'escalate_now');
does nothing that I can see, try:
g_form.submit();
see:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2024 07:41 AM
Hi Bert,
Yup. It's working fine. But it is navigating to Previous page once I click that button.
But it should stay on the same page.
Regards,
Pallavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2024 12:13 PM - edited 11-12-2024 12:25 PM
You'll need to provide more context. I get an error with the ui action in my PDI
As you can see, where is 'escalate_now' defined? Post screenshots as I have done.
And you never call the setRedirect() function in your code.
An example from searching UI Action records where 'script', contains, detRedirectURL shows:
action.setRedirectURL("export_update_set.do?sysparm_sys_id=" + sysid + "&sysparm_delete_when_done=true&sysparm_is_remote=false&sysparm_ck=" + gs.getSessionToken());
from the "Export to XML" UI action.