I’m trying to follow this example where conditionally a UDCodes record is created.
As soon as I add the line with the ServiceRenderer GetService, I get "The type or namespace name ‘UserCodesSvcContract’ could not be found (are you missing a using directive or an assembly reference?) and yes I probably am but which one? My references screen looks like this; adding these entries doesn’t seem to have helped.
And I have added these “usings” because they sometimes help with this error, but not this time:
using Ice.Tablesets;
using Erp.Tables;
Can someone point me in the direction of what’s needed here? The line of code I’m trying to get to work is:
var boUserCodes = Ice.Assemblies.ServiceRenderer.GetService<UserCodesSvcContract>(Db);
I wanted to post the final code, because I had some difficulties creating a new record in the UDCodes table. There are business object entities in place called both UserCodes and UDCodes; they seem to be used interchangeably within Epicor Kinetic. I got the deceptive error message “invalid code type” until I added the line that puts the company ID into the Company field of the updated record. Thanks Everyone!
// continue to create the UDCodes record of type MATCHPREF to store the new prefix
var boUserCodes = Ice.Assemblies.ServiceRenderer.GetService<UserCodesSvcContract>(Db);
var dsCodes_Updated = boUserCodes.GetByID("MATCHPREF");
var oNewRow = dsCodes_Updated.UDCodes.NewRow();
dsCodes_Updated.UDCodes.Add(oNewRow);
dsCodes_Updated.UDCodes[0].CodeTypeID="MATCHPREF";
dsCodes_Updated.UDCodes[0].Company = Session.CompanyID;
dsCodes_Updated.UDCodes[0].CodeID = strCodeIDprefix;
dsCodes_Updated.UDCodes[0].CodeDesc = strCodeIDprefix;
dsCodes_Updated.UDCodes[0].RowMod ="A";
// Add the new UDCodes record into the table
boUserCodes.Update(ref dsCodes_Updated);
Db.Validate(); // save changes to DB
} // end else (meaning a new prefix had to be found and stored)