Referencing a decimal UD field in a Kinetic Postprocessing Method directive

Hello,
I’m trying to get the value from a UD field and I’ve tried 3 different ways and they are not working. When I run a BAQ, the field appears as a UD field just fine.
I’m working with the rcvdtl table and my method works excepts for the UD field reference which is from the temp table…
var rcvdtlRel = ds.RcvDtl;
foreach( var rel in rcvdtlRel)
{
I’m trying to ref the field via rel…
thx
mc

Hi Michael,

Generally UD Fields are referenced in BPMs like this: table["UDfield_c"]

For example, this is from a BPM changing a UD field “TariffCode_c” in ttOrderDtl in one of my BPMs

var dtlRow = ttOrderDtl.FirstOrDefault(x => x.RowMod == "A" || x.RowMod == "U");

dtlRow["TariffCode_c"] = "90119390";

I would do the following:

foreach(var rel in ds.RcvDtl)
{
   //do your work here...

   decimal val = rel.UDField<decimal>("FieldName_c");

   //do your work here...

  rel.SetUDField<decimal>("FieldName_c", val);

   //do your work here...

}

Doug,

I’ve seen that example on other posts and I’ve checked my syntax 10 times and it doesn’t work.

We are using Kinetic SAAS 2022.2.11

The field does show on my BAQ though.

Thanks

mc

Can you do it via the image widget?

Doug,

This is my 1st BPM so I really don’t know whats possible.

I found a couple different ways to ref the UD field and none work.

Thx

Mike

This is definitely the way it should be done!

When was this field added, and has the data model been regenerated?

1 Like

Kev,

Ya, I was thinking about having that redone.

Thx

mc

The UD decimal field was coming in blank. I checked for blank or null and all is good.

Thanks!

Just when I thought I had the answer, I don’t.

This is in a postprocessing method and all of the other field ref work with the rel.xxxxx

I’m trying to ref the UD decimal field and I get an error.
When I look in the BAQ, the field has a 0 or number like it should.
The statement below gives me an error.
NumOfPallets2Pro = rel.UDField<System.Decimal>(“NumberofPallets_c”);

This does not error, but there is nothing in the field.
string NumOfPallets2Pro2 = rel.UDField<System.String>(“NumberofPallets_c”);

Help before I pull out the rest of my hair.
thx
Mike

what error it gives you?

I’d write it like the below, but I think the key thing to add to your code is the FirstOrDefault() to your DS. ds.RcvDtl.FirstOrDefault();

var rcvdtlRel = ds.RcvDtl.FirstOrDefault();

foreach( var rel in rcvdtlRel )
{
    decimal NumOfPallets2Pro = Convert.ToDecimal(rel["NumberofPallets_c"]);
}

Olga,
The bpm crashes and if i replace that with
NumofPallets2Pro =3;
It works fine.
Thanks
Mike

what is the type of NumOfPallets2Pro ? where it is set?
If BPM crashes, then probably some additional info can be found in the server logs

Olga,

I’m kinetic in the cloud so how do I check the server logs?

ask support?

You can request to have them turned on.
After that they will appear in your ServerFileDownloads folder.

1 Like

Epicor told me to use a data directive instead. I did and now I’m having a data type conversion issue from ttrcvdtl.sysrevid( byte[]) to rcvdtl.sysrevid( long ).
thx
Mike

long myLong = BitConverter.ToInt64(someBytes, 0);

byte[] myBytes = BitConverter.GetBytes(someLong);