Forms: Parent / Child structure using List view Control

  • 30 September 2017
  • 7 replies
  • 222 views

Userlevel 2
Badge +3

parent child‌ forms ‌ ‌

 

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 cool.png cool.png

 

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 wink.png

208729_pastedImage_8.png

 

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:

208730_pastedImage_9.png

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 

 

208731_pastedImage_10.png

 

(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)

208732_pastedImage_11.png

 

New child item

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

 

208734_pastedImage_19.png

 

 

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 

 

208733_pastedImage_13.png

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:

 

208735_pastedImage_21.png

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 )

 

208736_pastedImage_23.png

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

 

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:

 

208737_pastedImage_45.png

 

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:

 

208738_pastedImage_46.png

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":

 

208739_pastedImage_57.png

Then you must include the following code fragment:

 

208740_pastedImage_58.png

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. grin.png

 

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

 

BR


7 replies

Badge +2

Estimado Francisco,

Great job! thank you for sharing. I have a question regarding the "tabs" in the form. How did you create them? I am working on a long form and want to create "tabs" because it looks better for users to complete the form. Please let me know.

Saludos,

Glenda

Userlevel 2
Badge +3

Querida Glenda:

You must use "Choice" control and in the properties, adjust "Display format" to "Option Buttons", and "Display as a button" to Yes

The options list is the tabs list.

Then you must to do "rules" for each "Tab" as follow (the figure shows my "Resp. de Área" tab)

The condition is:

Tabs!='Resp. de Área'

where Tabs in the name of Choice control. Add the controls you want to show in the tab to the rule. The rule type is "format" and you must select "hide". Please note that the assigned controls to the rule is the controls you want to show in the tab

Un saludo!

 

Badge +4

Awesome work! That's very useful !  

Badge +3

Gracias por el post ‌, me ha sido de gran utilidad!

Un saludo.

Badge +1

Nice approach but there is a disadvantage.
For example, when you make some edits then click button to add items to child list, new form will be opened. From that new form when you are going back to parent form (after creating child item), you would have lost all edits that you made in parent form prior to coming to child list new form that is non-practical in certain business scenario's or large forms. Better is to open child list's new form in an SP modal, and when child item is saved, do a postback for list view control.

I have a problem using this approach, whenever I click "Edit Item" in the dropdown it gives me a blank screen, but creating a "New Items" works like a charm. 

Badge +2

What version of Nintex Forms is being used in this example?  I am still using SP2013 and not seeing all available options in the control settings drop down. Any additional info is much appreciated. Thank you.

Reply