RP + current

caucau
Kilo Explorer

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.

14 REPLIES 14

Valor1
Giga Guru

For related lists, you have to use "parent", not "current"



Your condition would become:


!RP.isRelatedList() && parent.u_state == "Created"


Hello Valor,



thank you for reply, but it does not help me. I am not testing parent record for the u_state, I am testing the records on the list. If you add a condition on the UI action as a choice list, when you select some checkboxes on the list, then when you click the "Actions on selected rows", it checks the condition for all of the rows *on the list* (as current) and tells you how many satisfy that condition.



I need to have the current condition in there for restricting the rows of the list (and I don't want to even display the UI action for related lists, so that's why there is the RP.isRelatedList() condition).



Is it now clear where the problem lies?


Hi JiÅ™í­,



If you simply want to restrict the records appearing the list layout of the related list, you can simply specify it in the Relationship itself. In the Query with field, you can mention



current.addQuery('u_state','Created');



This way only those records will be shown whose State is "Created". Then in the UI action you can simply put the RP condition and execute whatever is the code you want to run on click of it.



Thanks & Regards,


Hari


Hi Harikrishnan,



the current condition is not used for displaying items on the list, but for restricting UI action (bottom list button) to work only for certain items on the list. This won't do.



Cheers,



Jirka N.