Expression in a condition - application studio

I am looking to use application studio to convert a BPM to application studio
The BPM does a salesorder.update and when saving it checks if the shipby date is in a weekend or not. using the following very basic code in the Method directive:

dsOrderRelRow.ReqDate.HasValue &&
(dsOrderRelRow.ReqDate.Value.DayOfWeek == DayOfWeek.Saturday ||
dsOrderRelRow.ReqDate.Value.DayOfWeek == DayOfWeek.Sunday)

or alternatively as used in a datadirective:

ttOrderRelRow.ReqDate.HasValue &&
(ttOrderRelRow.ReqDate.Value.DayOfWeek == DayOfWeek.Saturday ||
ttOrderRelRow.ReqDate.Value.DayOfWeek == DayOfWeek.Sunday)

I now want to use the condition widget in Application studio to basically do the same, but I struggle to fill the expression of the condition with the correct syntax.

The actions and hooks are clear to me in application studio, I know which events I want to use (not when saving this time, but after a field changes, before saving)

Anyone able to help convert this?

Hey Patrick, welcome to the forum!

When you’re working in application studio events and you want to use the value in a dataview you have to use curly brackets in the format {dataview.column} so in your case {OrderRel.ReqDate}. Anything that isn’t numerical seems to also need quotes around that: “{OrderRel.ReqDate}”.

From there I just did some trial and error (and looking at existing system events using the browser debug tools) along with some chatgpt because I’m not a coder and got this expression to work.

"{OrderRel.ReqDate}" !== null && [0, 6].includes(new Date("{OrderRel.ReqDate}").getDay())

Let me know if you end up needing any help with the event hooks.

1 Like

Super! It worked thanks !
I had taken the ChatGPT route as well, but could not get the correct syntaxis there.

I basically got the not null part to work on my own and then told chatgpt that that syntax worked, then it spit out the weekend check part in the right syntax.