Carl Fransen1
Kilo Sage

Hi Team,

Recently I needed to create a new button on my HR Portal and came across this wonderful link to New Rocket where Nathan had documented an easy way to create buttons in the Portal.

I needed some specific configuration to be done to my behaviour and worked on this with a web developer in-house.  He helped simplify some of the coding which is much easier to write and read, so figure I'd share it with the community.

First case is where I'm checking for the input action to be a specific one, then perform an update back to the ticket, an HR Case in this example.  The updated code also allow more actionss to be added without requiring an 'if' section for each.

Original code was:

	if (input && input.action) {
	     var action = input.action;
 
		if (action == 'reapprove') {
		// Re-approve HR Case
		      gr.setValue('u_re_approve2', true);
		      gr.update();
		}
			//if (action == 'cancel') {
			//	// Do something else
		//	}
		}

Updated Code is:

switch (input && input.action) {
			case 'reapprove':
				gr.setValue('u_re_approve2', true);
				gr.update();
				break;
			// case 'action2':	
		}

 

The second place where the code was simplified was for a condition we had to show our new button.  We have added the (ng-if="data.showButton") to our HTML to conditionally show the button if the value is true.  Now we needed to perform a check, in our case for a particular status, but could be anything and return true or false.

Original code was:

if(gr.state == 6){
data.showButton = true;
} else {
data.showButton = false;
}

Updated Code is:

data.showButton = grld.state == 22;

 

Hopefully the above is of some use to the community, if you have a better way of doing things please also share - I'm still learning every day!

 

Cheers

Carl.

Version history
Last update:
‎07-24-2018 08:00 PM
Updated by: