BPM Dynamic Query use

Hi
I want to use the results of a BAQ inside a BPM (PO.Update method). I think that I can use the DyamicQuery BO to call an existing BAQ. The BAQ will return a set of data (or not) and then I want to see whether the PO and Line are present in that data and do something if they are not. I can use the GetByID method to link to the BAQ but I’m not sure how to get the resulting data out? Any thoughts?

Do a trace on running your baq and replicate that in your BPM.
Search the forum for DynamicQuerySvc and you should find some examples

1 Like

you can search to find your matched record in the BPM class without the need to use DynamicQuery, can i ask why have you decided to do your requirement this way ?

This is a cross company BAQ.
What I want to do is take the PO number and line (from the company where the BPM is running) and then find the job from the other company that has those numbers in the UD fields JobHead.PO_c and JobHead.POLine_c
I then want to look at the status of that job and decide on what to do based on that status. I thought that I could only access the one company from a BPM?

You can access any company from a BPM

1 Like

OK. I’ll give that a go …

Hmmm… I must be doing something wrong. I’ve gone through some tests and established that I can’t make a query that accesses the other company

This is about as simple a query as you can make it just to see whether it can get to the other company - it can’t

Did you check this box? (We are only one company so I’m not sure that’s the solution)

Yes, the BAQ is cross company and works a treat when it is run from the BAQ form but I want to run it from within a BPM:
When a user changes a PO line (specifically either changes the Qty or the due date). The BPM needs to check the “Linked” Job in the other company to see whether it has been released etc and then stop the changes from happening in that scenario. I’ve written the Intercompany BAQ so that it finds POs where the changes are allowable. Now I want to call that BAQ from within the BPM and see whether the results include the PO/Line which is about to be modified. I could also put Parameters on the BAQ for PO and Line and see whether the BAQ returns anything at all to the BPM. But I don’t know how to do either.

I’m not sure what’s going on with the multi company thing, I can’t really test anything since I’m a single company.

But, here is how I call a BAQ from a BPM on a C# code block. This one has parameters in it, so you should be able to see how to do that for yours.

3 Likes

Does the user running the BAQ (not you) have access to that company under Company Maintenance? If there’s security on the BAQ, does the user have access?

Yes they do but I can’t get it running under my log in anyway. I’m sure I’m missing something but I don’t know what …

OK I tried that but I’m getting a syntax error:
2019-05-21%2010_05_23-Enter%20Custom%20Code
MyPONum and MyPOLine are integer variables in the BPM and JobNum is a string variable in the BPM

It’s ExecutionParameter, not ExecuteParameter

Also, in BPm you can use Ctrl+space to get some auto-complete going for you. That will help with this type of coding.

Thanks - I just saw my typo as well…

Hey - It works :smiley:
Thanks so much for the code Brandon - Still don’t full understand it but it is getting what I need!

2 Likes

I am trying to follow your code and the other posts on here to use a BAQ within a BPM. Do you have anything in the “Usings & References” area?

I keep getting this error:

Found out. For anyone else looking for this, it’s in the screenshot below. I kept not being patient enough for the full list to load after clicking add.

5 Likes

Yeah it loads those assemblies super slow. It’s always fun waiting for the list to populate!

Curse that list! Be gone with it! @Bart_Elia
8ac619720c5a59982e938b434e6311b3