- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2016 10:32 PM
Hi ,
Just wondering if its ok to increase the Max Length of Condition field in the UI Action?
Regards
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 06:05 AM
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2016 10:41 PM
I suggest to call a script include from the condition field instead of increase length of this field.
Thanks,
Mihir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2020 07:21 AM
how to do that?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2020 05:56 AM
Build out the complex logic in a Script include function to return a truthy or falsy answer. Example:
var myConditionCheck = Class.create();
myConditionCheck.prototype = {
initialize: function() {
},
myFunction : function(gr) {
// gr is a GlideRecord, typically 'current' from the UI action condition
// now you have access to a lot of valuable information in one nice package
// Your function also has access to all the other server-side objects like
// GlideSystem (ex: gs.getUser), GlideAggregate, etc.
// Do some special logic here and return true/false
return true;
},
type: 'myConditionCheck'
};
In the UI action condition, it would be called like this:
new myConditionCheck().myFunction(current);
If the function returns true, your UI action is presented on the screen and you can run it with a click. If it returns false, no UI action is shown.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 05:04 AM
Hi John,
Please go through below thread.You will get idea how to call script include from condition of ui action.
How to call script include from the "condition" section of a UI Action?
Thanks,
Mihir