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

Ah, I figured it out.   My return was screwed up.   Here's the new script that is currently working:



var hr_taskUtils = Class.create();


hr_taskUtils.prototype = {


      initialize: function() {


      },




  //OOB condition for hr_task Start Work UI Action with added state '21' for HR Tasks Complete on Onboarding


      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;


      }


      else {


      return false;


      }


      },



      type: 'hr_taskUtils'


};


Nicely done mate, Please mark it correct so that other people with similar issues can find the thread.


One thing that may have changed since this was written.  In order for the script include to run it must be client callable.

:{)

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

john_s_valentin
Giga Contributor

Script include is good, and this 'is not one of' pattern scales well to long lists, especially useful if you have limited space in your Condition:

['14', '12', '3'].indexOf(current.state.toString()) == -1

Alternatively, the 'is one of' pattern:

['14', '12', '3'].indexOf(current.state.toString()) > -1