LineItems Removing Script

Question

How to remove all LineItems except the first one?

 

Answer

The following script will remove all instances except the first one:

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

Please use such script in Event Handler "After Document State Changed" (Project > Project Properties > Event Handlers, choose the After Document State Changed section, and press Edit Script):

Was this article helpful?

1 out of 1 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.

Recently viewed