other than prompt what can be used to display a pop up in widget which should be non mandatory

Tabassum1
Tera Contributor

I have Approve button for Demand, so when we click on the button it should display a pop up. Approvers should have the option to add comments when approving, but this should remain optional (not mandatory). Th Approve button is implemented in a widget.

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

@Tabassum1 

is that widget custom?

If yes then you can have your own logic to add a comments box

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

Tabassum1
Tera Contributor

yes its a widget custom. I have the following code: 

if (state == 'approved') {
            if (c.data.label == 'Demand') {
                spModal.prompt("Please enter reason for Approval").then(function(acceptReason) {
                    c.data.comments = acceptReason;
                    c.data.op = state;

                    c.server.update().then(function() {
                        if (!c.data.updateID) // update failed
                            spUtil.addErrorMessage(c.data.actionPreventedMsg);
                        else
                            c.data.state = state;
                    });

                })
 
but its asking the text to enter, so how can i make the pop up non mandatory

@Tabassum1 

try this

if (state == 'approved') {
    if (c.data.label == 'Demand') {
        spModal.prompt("Please enter reason for Approval (optional)").then(function(acceptReason) {
            // Allow empty or undefined comment
            if (acceptReason !== undefined) {
                c.data.comments = acceptReason;
            }
            c.data.op = state;

            c.server.update().then(function() {
                if (!c.data.updateID) {
                    spUtil.addErrorMessage(c.data.actionPreventedMsg);
                } else {
                    c.data.state = state;
                }
            });
        });
    }
}

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Tabassum1_0-1766557008827.png

The OK button is greyed out with which we cannot approve without entering comment