Using the ParentListName method
A new method called ParentListName was added in the latest version of PowerForms HTML. This method can be called from a form used inside a ListAndForm control and will return the list name of the form containing the actual ListAndForm control.
In order to call the new method, use:
form.ParentListName();
The method is best used when a list is required to show information to one or more lists which contain ListAndForm controls and maybe needs to show that information in a different manner, based on the parent list.
For example let’s assume we have two lists, Test1 and Test2. Test2 contains a ListAndForm control which uses a ListQuery to return information from the Test1 list. Test1 contains a Button control which executes a custom script when pressed. The script uses the ParentListName method, stores it in a variable and then presents the information to the user using an Alert pop-up. The code is listed below:
var theListName = form.ParentListName();
alert(theListName);
Following below is an image showing an attempt to add a new item to the Test2 list. We’ve already selected an item in the ListAndForm control which shows information from the Test1 list.
Pressing the Button control Button 1 will cause a pop-up message to appear which will show us the name of Test1’s parent list.