Adding Business Object Calls into Custom C# Method Directive code

,

Steve, trying to use your coding method I am trying to add a record into the UDCodes table with a specific CodeType (in this case “NEXT” and a CodeID of “CUST_XXX” where the XXX is defined from the Customer Name. This allows the table to be used to classify a Customer’s ID from a 3 digit identifier - for example IPN and as sequential number taken from the lookup in the UDCodes table from the description field (See “CUST_IPN” record with 6 in the description field. This description field is updated by 1 for the next Customer that is allocated the identifier “IPN”.followed with the number 006 making up a Customer Id of IPN006 with the 006 in the UDCodes “CUST_IPN” record being updated to be 7.

If the records in the UDCodes table exist then my procedure runs faultlessly but when an new identifier not in the table is specified. However I cannot for the life of me seem to add a new record into the UDCodes table. Here is the code I am using which is in line C#. I have tried to call the BO Object GetNewCodes method using the Widget but this also doesn’t seem to work.

     // We need to create another UD Code record
    nNextCustNum = 1;
    cShort_Id = "IPN";
    cPrefix = "CUST_";

    var bo=Ice.Assemblies.ServiceRenderer.GetService<UserCodesSvcContract>(Db);
    var dsCodes_Updated = bo.GetByID("NEXT");

    var oNewRow = dsCodes_Updated.UDCodes.NewRow();
    dsCodes_Updated.UDCodes.Add(oNewRow);

    dsCodes_Updated.UDCodes[0].CodeTypeID="NEXT";
    dsCodes_Updated.UDCodes[0].CodeID = cPrefix+cShort_Id;
    dsCodes_Updated.UDCodes[0].CodeDesc = string.Format("{0}",nNextCustNum+1);
  
    // Add the new UDCodes record into the table
    bo.Update(ref dsCodes_Updated);

Unfortunately the above code compiles syntax wise fine but refuses to generate a new UDCode “CUST_IPN” with a description contents as “1”