UI Action condition too long

matt v_
Mega Expert

I am facing an issue where the Start Work button is not showing up for HR Tasks once the case enters a new state that we created.   I need to add an OR condition here to take into account this new parent state, but there isn't enough room in the field.   Checking against my personal instance, we are using the default UI Action and condition:

current.state==10 || current.state==16 || current.state==17) && current.parent.state == 18 && (new StateFlow().validFlow(current, '81a3c4f8df93210068c37a0d3df26316', 'manual'))&&(current.hr_task_type.isNil()||(gs.hasRole('hr_task_writer')));

It looks like it's capped at 254 characters, but the line I'm shooting for would be 274 with my:

(current.state==10 || current.state==16 || current.state==17) && (current.parent.state == 18 || current.parent.state == 21) && (new StateFlow().validFlow(current, '81a3c4f8df93210068c37a0d3df26316', 'manual'))&&(current.hr_task_type.isNil()||(gs.hasRole('hr_task_writer')));

I see towards the end they started omitting some of the spaces, probably to save room.   If I were to condense further, I'm still at 258:

(current.state==10||current.state==16||current.state==17)&&(current.parent.state==18||current.parent.state==21)&&(new StateFlow().validFlow(current,'81a3c4f8df93210068c37a0d3df26316','manual'))&&(current.hr_task_type.isNil()||(gs.hasRole('hr_task_writer')));

Is there another way to condense these OR conditions instead?   I tried something like (current.state == 10 || 16 || 17) and it didn't like that.   I have read that changing the field character limit could be problematic.

I'm still learning as I go, so please forgive my ignorance if I'm way off base.

1 ACCEPTED SOLUTION

nthumma
Giga Guru

You need to write a Script Include to check all your conditions and call the script include method in UI action condition, like below


scriptincludecondition.png


View solution in original post

8 REPLIES 8

nthumma
Giga Guru

You need to write a Script Include to check all your conditions and call the script include method in UI action condition, like below


scriptincludecondition.png


Thanks for the response.   This got me researching more and I've created a new Script Include, but it's not working as intended.   Not sure where my error lies, but then again, I'm not sure what all of the parts are doing.   I'm just piecing this together from what I've read.   Here's what I came up with:



UI Action condition (really not clear on whether a semicolon is required at the end or not):


new hr_taskUtils().checkStartWorkAccess(current) == true;



I've tried changing little things in the above condition, but I either get no button at all, or it shows up regardless of any of the conditions in the Script Include.



New Script Include:


var hr_taskUtils = Class.create();


hr_taskUtils.prototype = {


      initialize: function() {


      },



      checkStartWorkAccess: function(){


      if((current.state==10 || current.state==16 || current.state==17) && (current.parent.state == 18 || current.parent.state == 21) && (new StateFlow().validFlow(current, '81a3c4f8df93210068c37a0d3df26316', 'manual')) && (current.hr_task_type.isNil() || (gs.hasRole('hr_task_writer'))));


      {


      return true;


      }


      },



      type: 'hr_taskUtils'


};


Please pass current in your function on line 6, like below


checkStartWorkAccess:function(current).


I made the change you suggested, but I'm still not getting it to work.   Could my IF statement be set up incorrectly?



var hr_taskUtils = Class.create();


hr_taskUtils.prototype = {


      initialize: function() {


      },



      checkStartWorkAccess: function(current) {


      if((current.state == 10 || current.state == 16 || current.state == 17) && (current.parent.state == 18 || current.parent.state == 21) && (new StateFlow().validFlow(current, '81a3c4f8df93210068c37a0d3df26316', 'manual')) && (current.hr_task_type.isNil() || (gs.hasRole('hr_task_writer'))));


      {


      return true;


      }


      },



      type: 'hr_taskUtils'


};