Show Mandatory fields and alert from UI Action

pardhiv
Tera Contributor

I have a UI Action to cancel record ,that needs to make 2 fields as mandatory[hidden by default] and once they are filled , then show an alert message.Is this possible ? Apart from the clicking of button , there is no other scenario that I can use to do this via UI Policy ?

 

function cancelTicket() {

g_form.setMandatory('cancelrecord', true);
        g_form.setMandatory('closure_comment', true);
		
    var answer = confirm("Confirm you wish to cancel the record");

    if (answer == true) {

        gsftSubmit(null, g_form.getFormElement(), 'cancel_record'); //MUST call the 'Action name' set in this UI Action

    } else

    {
        return false;

    }

}


if (typeof window == 'undefined')

{

    current.stage = 'Cancelled';
    current.status = 'Closed';
    current.update();

    //Cancel workflow context

    var grWf = new global.Workflow();
    grWf.cancel(current);
    action.setRedirectURL(current);
    gs.addInfoMessage('The current audit request has been cancelled.');

}

 

1 REPLY 1

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You can also sue onchange client script to trigger the alert. 

in the script check both fields are populated. You will need 2 onchange client scripts (one for each field), in both you will check the value of both fields and if they are both filled in then you trigger the alert.

2 Scripts are needed because you cant be sure what field will the user fill first, so you have to check on both

-Anurag