f.falomir@ube.es

Forms: Parent / Child structure using List view Control

Blog Post created by f.falomir@ube.es on Sep 30, 2017

parent child forms listviewcontrol beginner

 

Me

First of all, excuse my english, please.

I'm not an expert, but I would like to share with you my first significant development using Nintex Forms. It could be easy, but I'm very happy with it  

 

I have just developed a Parent / Child structure using List view control to show child list inside Parent Form. The idea is to have child data in a independent list in order to manage the elements properly.

I'm not satisfied with the repeating section to do it, because data is not easy to manage later, for example if you want to do tasks for each child element using workflow, or to make a report downloading the lists to Excel file and working with Power Pivot.

 

My targets are:

- To have the child data only in one place (not in XML in the parent list and the duplicate in a child list)

- To have the parent "primary key" in the child list to have the relationship in the reporting system (in my case Excel and Power Pivot functionality)

- To allow the update of the created child items when you want

- To use workflow to create / manage tasks using the child elements

 

The example:

In this case the parent child has data about process events in a Chemical Industry, and the child list has actions to do by the staff related with each event in the parent list.

 

The process:

Let me show my parent form. I use "tabs" to distribute and organize data using the wise advices learned in the forum 

 

The red mark shows the "primary key" of the parent element, generated using workflow when the element is created.

 

The tab "Acciones" has the list view control with the child items. You can see the primary key in the first column:

The list view control is filtered using a calculated control in the form, who stores the "primary key"

So, only the actions related with the parent item appears 

 

 

(Be careful here, you can filter and sort the list using the list headers. If you do it, filter values could be removed. I'll show you how to avoid it later on)

 

New child item

To create a mew child item, I have prepared a button on the top of the list.

 

 

 

The button is "save and send" type, and I use URL redirection property to point to the child form with the parent ID at the end of the URL string:

 

http://xxxxxxxxxxxxxxxxxxx/Lists/I_OP_Acciones/NewForm.aspx?ParentID=ID 

 

I'm not using the list "Add new item" link (by default it appears in the Sharepoint list) because I don't know how to pass the ID variable to it. In fact, I just remove the link to avoid troubles. I'll explain how to do it later on.

 

In the child form, I get the ID to update the key item. Let me show how:

 

I use a calculated control to geet the ID value from the URL string, using the following formula:

 

buscar("Incidentes_Operacion","ID",fn-GetQueryString(ParentId),"Num_Incidente")

 

Buscar (in spanish here) is Lookup the parent  list "Incidentes_Operacion" to get the parent primary key "Num_Incidente"

 

fn-GetQueryString is the function to get the variable from the URL string (Thank you very much Marian Hatala )

 

Now, you connect the calculated control with the appropiate child column and the relationship is done 

 

Updating an existing child item

In case of you want to update an exisiting child item, yo don't need to pass the key, because the child item get it when it was created. So, you can use the update action from the child list menu in the list view control in the parent form:

 

 

Back to the parent form from the child form when you finish edition:

By default, when you save the child form, Sharepoint come back to the list. So you need some code to return to the parent form (and to the related parent item). I use the following strategy:

 

The button "GUARDAR" is save and continue button. The user click on it to save data. The button Volver is not a button, is a calculated field with an hyperlink (there are  examples in the community of how to do it):

The formula that I'm using to back to the parent form is:

 

"<a href=\" http://xxxxxxxxxxxxxxxxxx/Lists/Incidentes_Operacion/EditForm.aspx?ID="+CC_Parent_ID+" \">Volver</a>"

 

CC_Parent_ID  is the calculated field I use to get the parent ID from the parent list using lookup formula and using the child column with the "primary key" as an argument. So, using this link you navigate back to the parent form.

 

This method has to advantages:

- You came back to the parent form from both new item action or updating action 

- The parent form is UPDATED with the new data when opens 

 

Finishing

 

Removing "add new item" funtonality in the chil list view and header filter / sort functionality:

 

As commented, you need to remove "add new item" and "header filter / sort" functionality from the child list into the parent form to avoid mistakes.

 

To do it, you must to edit the page when the parent form is alocated and include a web part selecting "Command sequence Editor" (I think is something like that, in spanish is "Editor de Secuencias de Comandos":

 

Then you must include the following code fragment:

 

The first fragment is to remove the add new link

The second one to remove header funtionality, in this case in the primary key column

 

Save the changes and the work is finished. 

 

Thank you for your attention. Any comment will be wellcome.

 

BR

Outcomes