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

@chandukollaparthi 

Sample script below

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="hidden" 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>

Client Script:

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

function onSubmit() {
    return true;
}

Processing Script: once you click OK in system logs you should see the processing script log

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

Regards
Ankur

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

Ankur,

 

Thanks for the reply. I tried this script when I click on Cancel button also Processing script is triggering. Also can we place any redirection url after the event triggered?

 

Thanks! 

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

Thank you Ankur!

You are welcome.

Regards
Ankur

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