CSS: Get the next line in a section

Discussions related to custom development with Select.
Post Reply
Posts: 982
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC

CSS: Get the next line in a section

Post by BobRichards » Mon May 25, 2020 1:59 pm

If you want to add a line to a CSS settlement, it takes two steps - if you can't find a free line among the existing ones, you need to create one. This is the procedure to follow. Also, be aware that sections only allow certain number of lines.

Code: Select all

IOrder order = ...

// Get the first CSS.
IList CSSs = (IList)order.GetProperty("CSSs");
IOrderItem css = (IOrderItem)CSSs[0];

// Look up the section from the dictionary by Section Code.
IDictionary sections = (IDictionary)css.GetProperty("Sections");
IOrderItem section = (IOrderItem)sections["CON"];

// Get the next line that has not been used already.
IOrderItem nextLine = (IOrderItem)section.Invoke("NextAvailableLine");

// Make sure we got a line since there is a maximum number the section can hold (typically around 100).
if (nextLine == null)
	// We can't add the line. Do something!

// Set description on first charge. This part is same for all examples...
IList charges = (IList)nextLine.GetProperty("Charges");
IOrderItem firstCharge = (IOrderItem)charges[0];
firstCharge.SetProperty("Description", "We created this charge");
Bob Richards, Software Developer, SoftPro

Post Reply