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