Updatable BAQ Expression Editor

10.1.400.23
Hello all,

I’m building an editable dashboard to make it easy to complete and close Jobs, specifically phase jobs.

I make the JobClosed and JobComplete fields as to what is updated. No problem. I can get the dashboard to deploy and it works.

I don’t want want the user to also have to set today’s date on each. So I go the the Update Processing tab in BAQ and open Expression Editor. If I change the CompletiponDate and ClosedDate expressions from the default ttResult… to “Constants.Today” it will put todays date in the field upon update. But because it updates both even if only one if the two is selected, then I’m still not there. But it works, in general.

The Expression Editor is called “Business Object Update C# Expression”. I figure I can throw an “If” statement in there to evaluate if the specific checkbox was checked for the corresponding date. Google says the C# expression is this:

if (condition)
{
Console.WriteLine("The variable is set to true.");
}
else
{
Console.WriteLine("The variable is set to false.");
}

So I try this for the JobHead_ClosedDate:

if (ttResult.JobHead_JobClosed)
{
Constants.Today;
}
else
{
ttResult.JobHead_ClosedDate;
}

I get several errors when I try to save:

Error CS1525: Invalid expression term ‘,’ [Update.Base.##BASE##.cs(107,83)]
Error CS1002: ; expected [Update.Base.##BASE##.cs(107,84)]
Error CS1002: ; expected [Update.Base.##BASE##.cs(108,89)]
Error CS1525: Invalid expression term ‘,’ [Update.Base.##BASE##.cs(108,89)]
Error CS1002: ; expected [Update.Base.##BASE##.cs(108,90)]
Error CS1002: ; expected [Update.Base.##BASE##.cs(109,91)]
Error CS1525: Invalid expression term ‘,’ [Update.Base.##BASE##.cs(109,91)]
Error CS1002: ; expected [Update.Base.##BASE##.cs(109,92)]
Error CS1002: ; expected [Update.Base.##BASE##.cs(110,87)]
Error CS1525: Invalid expression term ‘,’ [Update.Base.##BASE##.cs(110,87)]
Error CS1002: ; expected [Update.Base.##BASE##.cs(110,88)]
Error CS1514: { expected [Update.Base.##BASE##.cs(156,18)]

Can anyone explain the syntax in that editor? I clearly don’t know how to put an “If” statement in there. I could use some guidance.

Thanks,

Ben

Ben,

The syntax is: (x) ? y : z
Meaning if (x), then y, else z.

For example,
(x == 2) ? “TWO” : “NOT TWO”

Using your example:

(ttResult.JobHead_JobClosed) ? Constants.Today : ttResult.JobHead_ClosedDate

Aaron
THANKS!

(ttResult.JobHead_JobClosed == true) ? Constants.Today : ttResult.JobHead_ClosedDate

(ttResult.JobHead_JobComplete == true) ? Constants.Today : ttResult.JobHead_JobCompletionDate

They both work!
Ben

2 Likes

Thank you.

I was about to post a topic that was very similar to this one. Glad I checked this before I did!

Now I have to figure out how to get the Complete checkbox to check when the Closed checkbox is checked…
EDIT:
For future references:
To get the JobComplete field to be checked when the JobClosed field is checked -
(ttResult.JobHead_JobClosed == true) ? true : ttResult.JobHead_JobComplete

For some reason, this ruins the JobCompletionDate that was configured above. I’ll report back if I figure out how to get this all working together

Caleb,
Are you saying that Closed is preventing Complete to be checked in an UBAQ? I’ve not experienced that.
Ben

No it wasn’t preventing it.
I was trying to get the Complete checkbox to be checked whenever Closed is checked. I updated my original post with the expression to do this.