Need help in UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 02:32 AM - edited 12-17-2024 03:35 AM
Hello Experts,
I created a UI Action where the answer for a choice field is Yes it should bring a UI Page as a pop-up and insert the record in a particular table.
Below is the script i wrote, my script is not reading the value yes or no in the choice field.
Could somebody please advice what is wrong in below script?
function CheckReversal() {
g_form.setMandatory('reversal_error', true);
gsftSubmit(null, g_form.getFormElement(), 'reversal');
}
if (typeof window == 'undefined')
DoReversal();
function DoReversal() {
if (current.getValue('reversal_error') == 'yes') {
var tableName = "x_nuv_rejection_details";
var sysID = g_form.getUniqueValue();
var prd = g_form.getValue('period');
var seg = g_form.getValue('segment');
//Create and open the dialog form
var dialog = new GlideDialogForm('Rejection Details', tableName); //Provide dialog title and table name
dialog.setSysID(-1); //Pass in sys_id to edit existing record, -1 to create new record
dialog.addParm('sysparm_view', 'Default View'); //Specify a form view
dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
dialog.setLoadCallback(function(iframeDoc) {
// To get the iframe: document.defaultView in non-IE, document.parentWindow in IE
var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
dialogFrame.g_form.setValue('nuv_ticket', sysID);
dialogFrame.g_form.setValue('period', prd);
dialogFrame.g_form.setValue('segment', seg);
dialogFrame = null;
});
dialog.render(); //Open the dialog
} else {
var reversalRec = new x_nuv_rejection_detailActivitiesUtil().createReversal();
action.setRedirectURL(reversalRec);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 01:43 AM - edited 12-18-2024 02:43 AM
The above alerts are coming , but the condition -- > if(g_form.getValue('reversal_error') == 'yes') is not getting executed after saving the form thats why the dialogue box not appearing when the value is Yes.
@Ankur Bawiskar
The below condition is not working,
I am trying multiple times but not sure why the 'if ' condition is not working ...i have used the correct field and choice value names although.. just when we put the alert inside the 'if' condition it doesnt show up...otherwise if i remove this 'If' statement it will appear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 05:37 AM
what came in the value for that field when you did alert?
use that same value to compare
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 02:54 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 02:57 AM
This did not work for me unfortunately ..i tried multiple times.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 09:07 AM
OnClick is only ever calling CheckReversal(), try moving your call to DoReversal() inside CheckReversal() after your mandatory check