Save leading Zeros from nvarchar Serial Number in dataset

Epicor Version: 10.2.300.0
Issue: We have Serial Numbers with leading zeros. The SQL field type for SerialNo.SerialNumber is nvarchar(40). When I make a call to the SerialNo BO, it strips the leading zero(s). I have found several ways to keep the leading zeros, but only with standard SQL queries that I control, not using a call to an Epicor BO that loads a dataset. The number of leading zeros and serial number length may vary, so I don’t believe that padding is an option.

Excerpted code:

using (session = new Ice.Core.Session(epicorLoginUsername, epicorLoginPassword, currentAppServerURL, userLicenseType, clientConfigFile))
{
    oTrans = new Ice.Lib.Framework.ILauncher(session);
    int absolutePage = 0;
    int pageSize = 0;
    string whereClause = string.Empty;
    var serialNoBO = Ice.Lib.Framework.WCFServiceSupport.CreateImpl<Erp.Proxy.BO.SerialNoImpl>(session, Erp.Proxy.BO.SerialNoImpl.UriPath);
    whereClause = string.Format("Company = '{0}' AND SNStatus <> 'FORMAT' AND PartNum = '{1}' AND JobNum = '{2}' BY SerialNumber", companyID, assemblyNumber, epicorJobNumber);
    pageSize = 100;
    var serialNoDS = serialNoBO.GetList(whereClause, pageSize, absolutePage, out bool morePages);

By the time I retrieved serialNoDS, the first SerialNo.SerialNumber went from ‘0418340427’ to ‘418340427’. Anyone have any tricks up their sleeve?

Thanks in advance.

So GetList returns them truncated? That’s very strange. What about GetRows?

I guess that would be the next logical step. Lemme check…

If you debug the code, the dataset already dropped off the zero? I don’t think GetList do any conversion to string values.

Do you have the code where you assign the SerialNumber to a variable?

Got the same results with GetRows. I knew the result should be a Dataset which should return all objects. So in digging deeper, of course I find out it is programmer error…kinda. I was debugging the code and looking at the box with the barcode we had loaded the Serial Number table from in the beginning, instead of checking the actual database. Our original load of the Serial Number was truncating the zero. So I was getting the correct incorrect value from the table. Thanks for jumping in guys, hopefully next time I will have a real problem. :stuck_out_tongue:

1 Like