Add additional quote / order lines from Configurator Inputs

Hi @Josh_Hudson,

I have a Configurator UDMethod for adding additional order lines based on configurator inputs. Simply call this UDMethod from the document rules if your conditions are met.

Example of the document rule syntax:

if ( Inputs.bool_AddMyPart.Value )
{
    UDMethods.AddOrderLine( "MyPartNum", 1.00m );
}

Below is the code for the UDMethod:

/*== AddOrderLine v2.0 =======================================================

    Configurator User Defined Method | Server-side | Return Type = void

    Parameters:
        string  - NewPartNum
        decimal - NewPartQty
    
    Purpose: 
        Pass in Part Number and Quantity from Configurator UI Selections
        Add OrderDtl Line from parameters after Configuration

                --Kevin Veldman <RFPTSolutions@gmail.com>
============================================================================*/

//
// Check if PartNum is Empty
//
    if ( NewPartNum == "" || NewPartQty == 0 ) return;

    int OrderNum = Context.OrderNumber;

//
// Use this section to ensure new line is not added on re-configuration
//
    var PartLineExists = Db.OrderDtl.Any(x => x.OrderNum==OrderNum && x.PartNum==NewPartNum);

    if ( PartLineExists ) return;


//
// Call SalesOrder BO to add new Order Lines
//
    using ( var svc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db) )
    {
        // NOTE: Erp.Contracts.BO.SalesOrder.dll Assembly Reference added
        
        var tsOrder = svc.GetByID( OrderNum );
        svc.GetNewOrderDtl(ref tsOrder, OrderNum);

        var odX = tsOrder.OrderDtl.Select( x => x ).LastOrDefault();

        bool lSubPartsExist = false;
        string sUOM = "EA";

        if (odX != null) 
        {
            odX.PartNum = NewPartNum;
            odX.SellingQuantity = NewPartQty;

            var OrderDates = Db.OrderHed.Where(x => x.OrderNum == OrderNum)
                                        .Select(s => new {s.OrderDate, s.RequestDate, s.NeedByDate})
                                        .FirstOrDefault();

            odX.RequestDate = OrderDates.RequestDate ?? DateTime.Today;
            odX.NeedByDate  = OrderDates.NeedByDate  ?? DateTime.Today;
        }

        svc.ChangePartNum( ref tsOrder, lSubPartsExist, sUOM );
        svc.Update( ref tsOrder );
    }