RP + current
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2014 06:46 AM
Hey there,
I'm having a problem with specifying a condition for a UI action (bottom list button and choice list).
If the condition equals !RP.isRelatedList(), then the UI action correctly does not display on related lists. If the condition equals current.u_state == 'Created', then when selecting some items of the list via checkboxes, clicking on the "Actions on selected rows..." triggers succesfully that condition and if, say, i chose 5 items from which 2 are in state created, it says "UI action (2 of 5)" and after confirmation sends only those records satisfying that condition. So far so good.
But.
When the condition equals: !RP.isRelatedList() && current.u_state == 'Created', the relatedList condition stops working (the UI action is displayed on related lists). The condition for restricting states on a list works correct.
On ServiceNow wiki is a note, that when using "current" object where it is not defined it is ignored. My assumption is that not only the single statement is ignored, but the whole condition field? So that current.u_state causes the RP condition to be ignored? How to solve this? Should I refactor these conditions to a script include and call it in the condition field?
Thx for help,
Jirka N.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2014 02:05 AM
Yes on that you are right, but of course I would have to pass the current object too (otherwise it is not defined in the script include and it always returns false).
function AWTSCheckCreatedworklogs(isRelated, current) {
if(!isRelated && current) {
if(current.u_state == 'Created') {
return true;
} else {
return false;
}
} else {
return false;
}
}
But this script call is again ignored in the condition field if current is not defined there - which seems as erroneous behaviour to me already...
AWTSCheckCreatedworklogs(RP.isRelatedList(), current)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2014 12:44 PM
Hi Jirka, did you manage to resolve this issue? Let us know if you need more help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2014 05:29 PM
If you're calling a script include from the same script context where RP is available, it will be available in the Script Include as well.
In other words, RP is a global variable, and inside a Script Include you would have access to any global variables in context.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2014 02:25 AM
Hmm... You are right, I didn't consider that! Have you tried using the "javascript:" prefix in your UI Action condition? Here you can test for the existance of current and return false if it's not there, then run the script include if it is. Something like this maybe:
javascript:if(current) { AWTSCheckCreatedworklogs(RP.isRelatedList(), current); } else { false; }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2014 02:28 AM
Also I forgot to mention, if you want to raise this as a call you can by logging on to hi.service-now.com. You'll need to register if you haven't already, so you may need to speak to your account manager if you've never been on before.