Increase the Max Length hof Condition in UI Action

thisisauniqueus
Giga Expert

Hi ,

Just wondering if its ok to increase the Max Length of Condition field in the UI Action?

find_real_file.png

Regards

1 ACCEPTED SOLUTION

Hi John,



For easier maintainability, keep the condition as short as possible. If the computation is complex, it is difficult to read and understand. Rather than increasing the field length, consider putting your logic in a script include. For example, rather than something like this...



current.active && current.canRead() && (current.state == 4 || current.state == 5 || current.state == 7) && (current.u_requester.department.getDisplayValue == 'Marketing' || current.u_requester.getDisplayValue() == 'HR') || gs.hasRole('admin')



It could look something like this:



new myConditionCheck().ApprovalUIAction(current);



and your script include becomes a thing of beauty to maintain and extend.



var myConditionCheck = Class.create();


myConditionCheck.prototype = {


      initialize: function() {


      },



  ApprovalUIAction : function(gr) {


  var isAdmin = gs.hasRole('admin');


  var canRad = gr.canRead();


  var isActive = gr.active;


  var isGoodState = (gr.state == 4 || gr.state == 5 || gr.state == 7);


  var dept = gr.u_requester.department.getDisplayValue();


  var isGoodDept = (dept == 'Marketing' || dept == 'HR');



  if (isActive && canRead && isGoodState && isGoodDept || isAdmin)


  return true;



  return false;


  },



      type: 'myConditionCheck'


};



Andrew and I covered this in our video a while back:


Script Includes


View solution in original post

13 REPLIES 13

mrswann
Kilo Guru

used advanced script instead


Abhinay Erra
Giga Sage

As far as I know, there should not be any issues


Abhinay Erra
Giga Sage

But I usually prefer to use script include in the condition field and do all the dirty work in the script include and return true or false


can you pl give me an example