UI Action button is selected then pop up field for user to select project end date.

harivas
Tera Contributor

Hello,
I have a requirement on UI action button how can I configure point 3, can any one help me on this.
1. At the top of the project form I have to add  Complete Project Button.

2. when I hit on that button Pop up messsage (confirm message) Yes / No ,If no button is selected then stop process
3. If yes button is selected then pop up field for user to select project end date, Have the user submit the project end date.

Thanks,
Harivas

3 REPLIES 3

Akash4
Kilo Sage
Kilo Sage

Hello, 

Click the Client checkbox in your UI Action, use Condition field as required and add this script:

function onClick() {
    var dialog = confirm("Check the details and select Yes/No?");
    if (dialog) { //yes case
        g_form.setDisplay('project_end_date', true);
        g_form.submit();
    } else { //no case
        alert("No Action is take here.");
    }
}

 Hope this helps!
Regards, Akash
Please mark it as helpful 👍 or Accept Solution ✔️ based on the response to your query.

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.

harivas
Tera Contributor

Hi Akash, Thanks for reply

Here I need to show the dialog window when hit on button in project form. attached a doc for reference.


Akash4
Kilo Sage
Kilo Sage

Hello,

DialogWindow is deprecated from ServiceNow, instead there is GlideModal which performs similar action. For now I cannot provide you onChange basis field visibility and Date field type. This takes more effort on building a specific UI Page. On other hand, here is a sample script you can use directly on UI Action, the UI Page is available OOB:

 

function onSubmit() {

    if (g_scratchpad._action_confirmed) {
        return true;
    }

    var gm = new GlideModal("glide_prompt", true, 600);
    gm.setTitle("Confirm Update");
    gm.setPreference("title", "Enter the Project End Date in DD-MM-YYYY format");
    gm.setPreference("onPromptComplete", doComplete);
    gm.setPreference("onPromptCancel", doCancel);
    gm.render();

    function doComplete(value) {
		var store = value;
        var msg = ' wrong text entered.   Update Aborted. text=' + value;
        if (value != '') {
            g_scratchpad._action_confirmed = true;
            msg = 'You entered a value: ' + value;
			g_form.setValue("short_description", value);
            gsftSubmit(null, g_form.getFormElement(), 'inc_dialog_ak');
        }
        alert(msg);
    }

    function doCancel(value) {
        alert("The value " + value + " is not updated.");
    }
    return false;
}
if(typeof window == 'undefined')
runBusRuleCode();
function runBusRuleCode(){
action.setRedirectURL(current);
current.update();
gs.addInfoMessage('You did it!');
action.setRedirectURL(current);
}

 

 You can try it out for other fields, the above script uses Short description modification example.

 

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.