How to remove items from the Repeating Group using script

Question

How to remove items from the Repeating Group? 

Answer

The following script demonstrates the removal of all items from the repeating group except the first one:

if (Document.HasField("SectionName\\RepeatingGroupName"))
{​​​​​​
          while (Document.Field("SectionName\\RepeatingGroupName").Items.Count>1)
        {​​​​​​
              int itemsCount = Document.Field("SectionName\\RepeatingGroupName").Items.Count;
              Document.Field("SectionName\\RepeatingGroupName").Items.Delete(itemsCount-1);
        }​​​​​​
}​​​​​​

Note: the script is only for demonstration purposes and needs to be modified in accordance with the desired workflow. 

 

See also: 

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.