- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2017 06:26 PM
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.
Solved! Go to Solution.
- Labels:
-
HR Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2017 06:39 PM
You need to write a Script Include to check all your conditions and call the script include method in UI action condition, like below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 05:45 PM
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'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 07:12 PM
Nicely done mate, Please mark it correct so that other people with similar issues can find the thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2019 11:57 AM
One thing that may have changed since this was written. In order for the script include to run it must be client callable.
:{)
:{)
Helpful and Correct tags are appreciated and help others to find information faster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2019 06:14 AM
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