Accessing parent information in a Related List UI Action button

margie_joyce
Kilo Contributor

Hi all,

I have a form with a related list, where the relationship between the main form and the list is based upon a date field on the main form. The query in the Relationship basically boils down to:

workDate >=
and
workDate <=

Users need to be able to add records to the related list. We would like to be able to restrict entry in the date field on the child form based on the date values in the parent form. I've been able to achieve this by using a Form UI action on the parent form, pulling the values I need from current.xxxx and building a URL string to bring up the child form for a new record (and storing the date values I need in a hidden field on the form). This is working quite well.

However, I would prefer to be able to use a "New' button on the Related list itself, ie create a List Action button that overries the global "New" on a related list. The only thing preventing this is that I cannot find a way of referencing the parent record in the script for the UI Action. Current now obviously references the child record. I tried (with fingers crossed) using "parent" but with no joy.

My question is ... is there any way of referencing parent record fields in a List Action button on a related list?

Thanks very much for taking the time to read this.

margie

1 REPLY 1

Mark Stanger
Giga Sage

If you right-click the related list and select 'Personalize Control' you can control when the buttons on related lists are displayed. There's a script field called 'New condition' that you can use to access the parent record and remove the 'New' button depending on the information in the parent. I'm using the following script within that field to remove the 'New' button. If the 'State' field on the parent record has a value of 7, then remove the 'New' button. Otherwise, leave it.



if (parent.state == 7){
true;
}
else{
false;
}