CDF: Get the next line in a section

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

CDF: Get the next line in a section

Post by BobRichards » Fri May 22, 2020 3:22 pm

If you want to add a line to a CDF 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. If you exceed the limit, an exception will be thrown. This example can be used on sections: A, B, C, E, F, G, and H.

Code: Select all

IOrder order = ...

// Get the first CDF.
IList CDFs = (IList)order.GetProperty("CDFs");
IOrderItem cdf = (IOrderItem)CDFs[0];

// Get the next unused line in the "ServicesNotShoppedFor" section.
IOrderItem nextLine = (IOrderItem)cdf.Invoke("NextAvailableLine", CDFSectionType.ServicesNotShoppedFor);

// 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 else!
    return;
}

// Set description on first charge. Line will inherit the description if only one charge.
IList charges = (IList)nextLine.GetProperty("Charges");
IOrderItem firstCharge = (IOrderItem)charges[0];
firstCharge.SetProperty("Description", "Our charge");
Bob Richards, Software Developer, SoftPro

Post Reply