Creating a UI Action where based on a choice field answer need to pop up a UI Page

Mishu
Tera Expert

Created a UI Action where based on a choice field answer (Yes/No) needs to perform the next action, i.e. if the answer is Yes it should bring a UI Page as a pop-up and insert the record in a particular table.

If no, the record should be inserted in another table.

I wrote the below script but when I select yes and save form nothing happens..instead after saving if I click again then the UI action works. Please let me know what's wrong here.??

 

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);
    }
}

 

 

 

 

1 REPLY 1

JenniferRah
Mega Sage

The way I have achieved this is by doing something like this: 

  • Give your UI Action a unique Action name. This will come into play in the code.
  • Make sure Client is checked in the UI Action.
  • Make sure List v2 Compatible is checked in the UI Action.
  • For the Onclick field, put your client side function that shows the dialog box.

 

function clientfunction() {
    if (condition for showing your modal) {
        var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
        var dialog = new dialogClass('glide_confirm_basic');
        dialog.setTitle(new GwtMessage().getMessage('Confirmation'));
        dialog.setPreference('title', new GwtMessage().getMessage("Add your message here."));
        dialog.setPreference('onPromptComplete', serverSideCallbackFunction);
        dialog.render();
    }
}

function serverSideCallbackFunction() {
    gsftSubmit(null, g_form.getFormElement(), 'THIS MUST BE THE ACTION NAME OF THIS ACTION');
}

//Add the rest of your code here. This is server-side code.

 

I hope this helps.