Reject UI Action on Demand

User177031
Kilo Guru

Hi All,

Can anyone help me with the below requirement.

Create 'Reject' UI Action on demand & it should appear when demand is in deferred state.
Rejecting the demand should set the demand to inactive and state = reject. Also make a worknote required

- Thank you.

1 ACCEPTED SOLUTION

I just realized that client and server code is mixed up. Try this code.

Make sure you check the client checkbox, specify the Onclick function and add an action name for your UI action as reject_demand

Also use the actual state choice value for the Reject state and not its label.

find_real_file.png

function reject(){
	if(g_form.getValue('work_notes') == ''){
		g_form.setMandatory('work_notes', true);
		g_form.addInfoMessage("Enter Work notes");
		return;
	}
	//Call the UI Action and skip the 'onclick' function
	gsftSubmit(null, g_form.getFormElement(), 'reject_demand'); //MUST call the 'Action name' set in this UI Action
}

if(typeof window == 'undefined')
	rejectDemand();

//Server-side function
function rejectDemand(){
	current.state = '2';  //Replace with your reject state choice value
	current.active = false;
	current.update();
	action.setRedirectURL(current);
}

View solution in original post

7 REPLIES 7

Alikutty A
Tera Sage

Hi,

You can create a new Reject UI action with the following condition and script

Condition: current.state == 10

Script: 

current.state = 'reject';  //Replace with your reject state choice value
current.active = false;
current.update();

find_real_file.png

Hi Ak,

How do we make the ''worknotes'' mandatory?

- Thank you

Try this

if(current.work_notes == ''){

 g_form.addInfoMessage("Enter Work notes");

 g_form.setMandatory('work_notes', true);

}else{

current.state = 'reject';  //Replace with your reject state choice value
current.active = false;
current.update();

}

Hi Ak,

Provided script is only updating the active flag but not changing the state to rejected and not making the worknotes mandatory before updating the demand record. Please help....Refer to the attached screenshot.

- Thank you.