Page 1 of 1

CDF: Get the next line in a section

Posted: Fri May 22, 2020 3:22 pm
by BobRichards
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");