E10 - Print BAQReport from C#

@JKage what I meant to say is that my report has Options. I can see that they are stored in the Option01 - 04 fields in the report params. I see this when doing a trace on the report run, but when I try to add those in there my report does not run as expected. It is not filtering on those options.

Any ideas?

@JKage

I see this line in your code rptDs.BAQRptOptionFld[0].FieldValue… It looks like I need to use it for my report options.

@josecgomez any ideas?

You could replace .FieldValue with some of the field names that i listed in the earlier posting. Such as “Character01”, etc. Just set that field to the data you want to use. IE: rptDs.BAQRptOptionFld[0].Character01 = “MyParameter” or you could set up a variable in the code and set the field value to it so it’s dynamically set.

@tfenwick11 Do you think a BAQ report would work for your needs?

It would help in the sense of calling a custom SSRS report but for calling two at the same time and referencing that in a autoprint job per a save action or print upon material queue is the tricky part.

Why does this have the ! in front?
Wouldn’t this say "If agentID has something, then change to “SystemTaskAgent”?
If you are doing that, then why bother pulling AgentID?

I do have an issue of where I need to pass the report some type of filtering parameters.
I am running this from a dashboard and it prints everything the dashboard pulls up.

Is there a way to pass a selected rows fields to the report as options?

OrderDtl_OrderNum
OrderDtl_OrderLine
OrderRel_OrderRelNum

string.IsNullOrEmpty returns a true of false boolean. the “!” inverses the value of the boolean, so that statement reads as “If that string is not null”.

That is what I indicated. That means if there is an agentID pulled, it overwrites it with “SystemTaskAgent”, right?

If so, what would be the point of pulling an ID if you then overwrite it?

I think the intention there is to ensure it isn’t null - that could cause exceptions

If so, then shouldn’t it just be:

if (string.IsNullOrEmpty(agentID)) { agentID = “SystemTaskAgent”; }

That tells me, If empty, use SystemTaskAgent.

Am I crazy?

Yes you’re crazy :wink:
It’s saying that if the agent ID isn’t null, meaning it has no value, then we want to hard code in “SystemTaskAgent”. It’s just a way to check the agentID variable before passing it, since he is receiving it from the GetDefaultTaskAgentID method, rather than assuming that the method returned a value.

I put a MessageBox before it to show the AgentID mine pulled. It was ‘TaskAgent’.
I also had a MesageBox after the line and it told me it was ‘SystemTaskAgent’.

Then it errored out with:

image

Why did it change it if it was not empty?

I know it was typed correctly because it was a straight copy from here.

I then ditch the ! and it works fine.

Sorry about getting off topic, my actual question was:

If anyone can help, it would be appreciated.

1 Like

Why did it change it if it was not empty?

Because the method says IsNullOrEmpty. By using the !, you are saying Not Null [or] Not Empty

So you are saying if agentID had something in it before this line of code, it should change it to be SystemTaskAgent?

Why should it do that?

I feel like we are having a circular argument here, lol. :grin:

Try that piece of code the way it is originally and put a MessageBox on either side of it to monitor the variable.

With the !(not) on IsEmptyOrNull, that tells me if IsEmptyOrNull is true (nothing there), then make it false (something there).

That means unless the TaskAgent was empty, it will change it. If it is empty, it will ignore it.

I feel like that is the reverse of the intention.

Please double check me and let me know if I am wrong.

I hate to keep on about it but no one has convinced me otherwise, especially since I am running it with the logic in front of my eyes and it is doing what I am saying.

had something in it before this line of code, it should change it to be SystemTaskAgent?

Yes.

But also if it had nothing in it i.e a blank string “” then Yes.

I think you are misunderstanding what null means. It means does not exist, so you can’t set something that doesn’t exist.

TaskAgent = “” is not the same as TaskAgent = null

@JKage @josecgomez @shobdy I also have the same question, how do we pass in the parameters?

When I do a trace I see that they are Option1 Option2 and Option 3 and when I set them the report takes FOREVER to run because it is not using the parameters in the query. That results in the report displaying info for a completely different Job / Order because I am using aggregates on the parameters. Not sure how to pass them.

If anyone has any idea please let me know.

Guys the code to print BAQReport in the UI customization will work the same way in a BPM?

Thank you