So I found that I can call a function in Kinetic from another function in the same library. Nice. I recall being told that Kinetic would not allow this.
Even better when creating the code that calls the function it gives you a line skeleton with blank spaces where the parameters are and you can preview what the parameters are in the nav bar to the left. So far so good.
I made a logging function to go along with my dashboard to write scanner logs to a UD table. I have this working in classic so I attribute this to my lack of knowledge on tablesets. Now the parameters are good, I have them going back to a form and can see them on screen. I am not getting errors. It is not giving exception messages. Its either failing silently or for some unknown reason it is not calling it. So I am missing something.
using (var context = Ice.Services.ContextFactory.CreateContext<ErpContext>())
{
using (var svc = Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.UD10SvcContract>(context))
{
Ice.Tablesets.UD10Tableset tblUD10 = new Ice.Tablesets.UD10Tableset();
svc.GetaNewUD10(ref tblUD10); // Doesnt seem to make a difference if I comment this out
// DataRow ud10Row = tblUD10.UD10.Rows[0]; this is an instant error from the customization that does the same thing
Ice.IceRow ud10Row = tblUD10.UD10.NewRow();
string jobNum = this.JobNum;
string empNum = "";
try
{
empNum = this.EmpNum.ToString();
}
catch {}
ud10Row["Key1"] = "GTValidation";
ud10Row["Key2"] = this.GTIN;
ud10Row["Key3"] = DateTime.Now;
ud10Row["Key4"] = empNum;
ud10Row["Key5"] = this.LotNum;
ud10Row["ShortChar01"]= this.GTINIdentifier;
ud10Row["ShortChar02"]= this.GTIN;
ud10Row["ShortChar03"]= this.DateIdentifier;
ud10Row["ShortChar04"] = this.Date;
try
{
DateTime dt = DateTime.Parse(this.PackagingDate);
// DateTime dt = (DateTime)this.PackagingDate;
ud10Row["Date01"] = dt;
}
catch {}
ud10Row["ShortChar05"] = this.LotIdentifier;
ud10Row["ShortChar06"] = this.LotNum;
ud10Row["ShortChar07"] = this.CaseIdentifier;
try
{
ud10Row["Number01"] = this.UnitsPerCase;
}
catch {}
ud10Row["ShortChar08"] = jobNum;
ud10Row["ShortChar09"] = empNum;
ud10Row["ShortChar10"] = this.FoodDate;
ud10Row["ShortChar11"] = this.SuccessOrFail;
ud10Row["Character01"] = this.Message;
ud10Row["ShortChar12"] = this.type; // shpType.EnabledCaption;
ud10Row["ShortChar13"] = this.PartNum;
ud10Row["Character02"] = this.PartDesc;
string userID = callContextClient.CurrentUserId;
ud10Row["ShortChar14"] = userID;
svc.Update(ref tblUD10);
}
}
You’re not setting the “Company” field in that code. So if you’re not getting any errors it is probably creating the records with Company ID blank, and therefore when you’re trying to retrieve them you’re not finding them.
This should return a dataset with one record with the defaults set, but you then create a new row (that doesn’t get any defaults - hence the blank company) and update that row:
Ice.IceRow ud10Row = tblUD10.UD10.NewRow();
I don’t think that’s necessary with the GetANewRow:
If I remember correctly, on the UD Tables all the keys are of DataType String. In your first example you are assigning data of type Date, but in the second example you chain ToString() which converts the Date to a String, which would be the correct data type for being stored in Key3 of a UD Table.
However it works in a Classic Customization. (And still does, we are using it every day). I pulled the bulk of the function code out of a customization that I wrote years ago to verify barcode swipes. This function is to help replace it when Classic sunsets.
The original issue with it not blowing up is quite odd as it would have had to process the error line too. It just wasn’t saving anything or erroring out.