BPM Dataset Name dsOrderDtlRow not working

I am trying to access the field PartPlant.MinimumQty field in a Post Process BPM on Erp.BO.SalesOrder.ChangePartNumMaster.

I have used a piece of code I found on this site (care of @timshuwy C# question about retrieving fields - #6 by timshuwy) and edited it to the my requirements

int jgrTargetStock = Db.PartPlant.Where(x =>
    x.Company == dsOrderDtlRow.Company &&
    x.PartNum == dsOrderDtlRow.PartNum ).Select( x=>x.MinimumQty)
   .FirstOrDefault() ?? "@@@";

When I check the syntax of the code it gives me the following error

CS0103 The name ‘dsOrderDtlRow’ does not exist in the current context. I have found the ‘dsOrderDtlRow’ when I looked at setting a variable

image

I have tried other variations but nothing works, so I hope someone can explain what I am doing wrong.

Thanks in advance.

Sometimes the method doesn’t populate the dataset, or only partially does so (e.g. it only includes modified rows). Even more infuriating is that some methods populate the dataset on pre proc, but not post proc (or vice versa).

You can run BL Tester or REST Swagger to check the specific method you’re trying too use to see what exactly is happening. Workarounds vary based on what datapoints you have available.

Generally, using the method parameters (instead of the DS) is more reliable. PartNum looks like it’s available for this method and you can grab Company from the Session.

1 Like

@jtownsend Thanks for the reply. Unfortunately, this is a little beyond me. Do you know of any tutorials or guides where I can learn more about this?

You can either right click in the Editor window or (depending on the exact widget) see all parameters and other objects in the tree menu on the left side of the window.

image

You query should look something like this:

int jgrTargetStock = Db.PartPlant.Where(x =>
            x.Company == callContextClient.CurrentCompany &&
            x.PartNum == partNum)
   .Select(y => y.MinimumQty)
   .FirstOrDefault() ?? "@@@";

There may be some differences since you’re on a newer version. The gist of what I’m saying is that you have access to other objects within a BPM than just DS.

Question: are you intentionally trying to throw an error on null results? It’s not going to like you trying to assign “@@@” to an integer.

3 Likes

The interface doesn’t work correctly as far as I know when referencing fields inside of datasets. “dsOrderDtlRow” is not really available in code, you have to build it. Something like:

OrderDtlRow dsOrderDtlRow = ds.OrderDtl.Where(r=>!r.Unchanged()).FirstOrDefault();

Thanks, everyone. With your help, a little trial and error and ChatGPT to eliminate the errors I have a working solution.

1 Like