Calling a function of UI Action into UI page

labandar
Tera Contributor

Hello everyone, I'm currently working on Change module. For a specific requirement I need to call a method of 'Request Approval' UI Action [onAssess] into a UI Page to do come Calculation. The method I need to call from the UI Action is 

invokeRiskAssessment() the action name of the UI Action is 'state_model_request_assess_approval' it's on click method is moveToAssess();

Firstly is it possible to call an UI Action method into the client script of UI page? If possible can someone help me out here.
6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@labandar 

yes it's possible.

check this link has an example, enhance it as per your requirement

Call a specific function of UI Action from UI Page 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar  I have already come across that solution but that solution included adding an option to the form, but I need to call a popUp which is in the done by a function in UI Action.

Here is the Client script I'm using in the UI Page for your reference:

function save(shouldAssess){
    var gdw = GlideDialogWindow.get();
    if(shouldAssess == 'yes'){
        var complete = gdw.getPreference('onRiskCalculate');
        if(complete == 'yes'){
            invokeRiskAssessment();
            g_form.setValue("state", "-4");
                        gsftSubmit(null, g_form.getFormElement(), 'state_model_request_assess_approval');
        }
    }

        gdw.destroy();  
}

In the above code 
invokeRiskAssessment(); is the function I'm trying to call from the UI action 'state_model_request_assess_approval'.
 

@labandar 

you want to call a function present in UI page client script from UI action script?

OR

it's other way?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar  Other way, here invokeRiskAssessment() is a method present in UI Action. I want to call this method in UI Page Client script.