Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Page trigger Processing script

chandukollapart
Tera Contributor

Hi,

I want to create UI page. In that UI page client script want to display confirm dialog box. When users click on "Ok" trigger 

 

 
1 ACCEPTED SOLUTION

Hi,

when you click cancel you are redirecting to new page and form will stay there only

add this

function onCancel() {
var uri = 'home.do';
g_navigation.openPopup(uri);
return false;
}

after processing script is triggered you can redirect to whichever url you want as below

runprocessCode();

function runprocessCode(){

gs.info('Processing script triggered');

// ensure you give valid object for your event queue current won't work here
gs.eventQueue('sendNotification',current, gs.getUserID());

var url = 'your URL here';
response.sendRedirect(url);
}

Let me know if I have answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

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

View solution in original post

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

@chandukollaparthi 

please share what you have tried so far?

Regards
Ankur

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

Hi Ankur,

 

This is the script I tried it. Please let me know

Client script:

var ans = confirm("ATTENTION!! \n\n clicking OK for the to move further.\n\n Click Cancel to move home page.");
if(ans == false){
var uri = 'home.do';
g_navigation.openPopup(uri);
}
else{
runprocessCode();
}

 

function runprocessCode(){
gs.eventQueue('sendNotification',current, gs.getUserID());
}

Hi,

in order to run the processing script you should be using <g:ui_form> tag

Sample HTML

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g:ui_form>
        <table border="0" width="100%">
            <tr>
                <td>
                    <input type="text" name="reason" id="reason"></input>
                </td>
            </tr>
            <tr>
                <td>
                    <g:dialog_buttons_ok_cancel cancel="return onCancel();" ok="return onSubmit();"/>
                </td>
            </tr>
        </table>
    </g:ui_form>

</j:jelly>

Regards
Ankur

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

Ankur,

 

I tried this sample html by removing <table> content. Confirm popup is coming but Cancel and Ok actions are not working.

 

Thanks!