dot walk in UI Action condition

pmizilin
Tera Contributor

I need to add a UI Action on sysapproval_approver.

I need to show it only if the parent of the record being approved is of a certain sys_class_name:

 

The inheritance is as follows:

 

task -> u_parent_form -> u_my_form

 

So far what I've tried in UI Action condition has not worked:

 

current.sysapproval.instanceOf('u_parent_form')

current.sysapproval.parent.sys_class_name == 'u_parent_form'

current.sysapproval.parent.getTableName() == 'u_parent_form'

current.sysapproval.parent.getRefRecord().getTableName() == 'u_parent_form'

current.sysapproval.parent.getRefRecord().getRefRecord().getTableName() == 'u_parent_form'

current.sysapproval.parent.getRefRecord().sys_class_name == 'u_parent_form'

current.sysapproval.getRefRecord().parent.getRefRecord().sys_class_name == 'u_parent_form'

 

This works: current.sysapproval.sys_class_name == 'u_my_form'

Problem is I have around 18 forms that inherit from 2 parent forms and I don't feel like creating 18x2 cases

 

Kind of at a loss at this point...Any help is appreciated

1 ACCEPTED SOLUTION

John,



Thanks for your reply; that particular condition didn't work for me; however this works:



current.sysapproval.getRefRecord().instanceOf('u_parent_form');



Apparently you need to call getRefRecord() before you attempt to use instanceOf even though you can do current.sysapproval.state == '1'



Thank you for your help guys.


View solution in original post

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

When you are dot-walking to parent, what are you meaning there? Parent is actually a field on the task table and it does not refer to the table your form is extended from.



For example, if I had an approval associated to a change task and the parent field on the change task had a reference to the change request, I could do the following:


current.sysapproval.parent.sys_class_name == 'change_request';



Is that the situation you are trying to address or are you try to reference the table that your u_my_form table is extended from?


Brad,



Thanks for your reply; in my case I need to know the table name I'm extending from.


I think you should be able to do something like:



current.sysapproval.parent.getRefRecord().instanceOf('u_parent_form');



This would look at the parent record of the task being approved, get the actual GlideRecord for that parent, and then check to see whether it is on the table 'u_parent_form' or any table extended from 'u_parent_form'.


John,



Thanks for your reply; that particular condition didn't work for me; however this works:



current.sysapproval.getRefRecord().instanceOf('u_parent_form');



Apparently you need to call getRefRecord() before you attempt to use instanceOf even though you can do current.sysapproval.state == '1'



Thank you for your help guys.