Update parent item when associated items are modified from parent item edit form

Applies to:

Crow Canyon NITRO activated sites in:

SharePoint Online and On-Premises 2013/2016/2019/SharePoint Server Subscription Edition

Description

This article describes steps to update the parent item when its child items are modified from parent item edit form, using custom script in Form Event Actions.

Sample use case:

Update the status of parent item to ‘Complete’ when all the associated child items are completed.

Detailed steps

  1. Configure ‘Form Event Actions’ on column value change event.

a) Navigate to NITRO Forms designer of the parent list -> Select the pre-configured ‘NITRO Associated Items’ column -> Column Settings -> Expand ‘On column value change event’ section -> Click ‘Add’ button.

b) Configure FEA for new and edit form.

c) Configure ‘Execute Script’ action. In the ‘Configure Execute Script Action’ window, paste the script as shown below:

Script:

var linkedColumnName = "[Associated Column Internal Name in the parent list]";
var statusColumn = "[Child list ‘Status’ column Internal Name]";

var objLinkedColumn = _ccs_FormUI.linkItemsColumnSettings[linkedColumnName];
var grid = $("#" + objLinkedColumn.ControlID).data("kendoGrid");
var gridData = grid.dataSource.data();
var itemCount = gridData.length;
var allCompleted = true;
for (var i = 0; i < itemCount; i++) {
    var objRow = gridData[i];
    if(objRow[statusColumn] != 'Completed'){
		allCompleted = false;
      break;
    }
}

if(allCompleted){
  _ccs_FormUI.setColumnControlValueByName("Status", "Closed");
}

functionCallback();

Note:

  • Use child item ‘Status’ column value in the below line like ‘Completed’ or ‘Closed’. This value can be as per the requirement.

‘if(objRow[statusColumn] != ‘Completed’){‘

  • For line ‘_ccs_FormUI.setColumnControlValueByName(“RequestStatus”, “Closed”);’, use parent form’s ‘Status’ column internal name and set the value as ‘Closed’/ ‘Completed’.

d) Click Ok to save the FEA -> Click ‘Apply’ -> Publish the NITRO Forms.

Sample output from the parent list edit form when the status of child items is set to ‘Completed’: