Hi there AppWorks fans,
Welcome to a new installment of AppWorks tips.
For this week we dive into interesting expressions from the entity modeling perspective of the platform. During all my posts and knowledge-share articles, I mentioned you all about the expression chapter of the low-code guide of the platform “Chapter 12 - Using expressions”. I did a search within my own articles and found two related posts about these types of expressions (a new “Dynamic list filtering” feature, and the field validation). For this post we just continue the grind where we try other advanced expressions.
Let get right into it…
Time for a quick recap and figure out where we can even use an entity modeling expression and how we can quickly put them to the test to evaluate its value. For this I see these entrances:
- Rule BB set property field
- Rule BB condition (advanced editor)
- Security condition (behind the filter icon)
- List BB (as a filter option)
- Deadline (start/end policy)
- Activity flow (start condition)
- Lifecycle (transaction with conditional event)
- Email template!
Comment me on other entrances if I missed one? I know there is also a filter (with parameter option) on the ‘Web service’ BB when you add a new ‘Find’ operation, but I leave it out of scope for this post. It doesn’t seem to support these type of expressions like described below!
…
What I also leave out of scope is the expression editor we can find in the message map of a BPM!
Grab yourself a copy of the expression system.organization
which retrieves the current organization name as a value. In my case appworks_tips
. Have yourself an entity project
available (incl. property prj_name
) for the first entrance on Rule BB level (an event type of rule with name e_on_init_set_name
):
After a save, publication, and first test in runtime, we have our first result:
Now we’ll add a condition (our second entrance) like this:
Single quotes does the same trick:
'appworks_tips'==system.organization
. I know it’s always TRUE in my case, but it’s just to demonstrate the possibility. Try!=
or<>
🤔
Next is the ‘Security’ BB entrance on the project
entity. Add this BB, add the ‘Identity User’ as role, and mark all the options. Finally, you can add a filter condition to for example the ‘Create’ action. Like this:
The condition behind this looks like this (just like we saw before):
"appworks_tips"<>system.organization
. In this case we just made sure our account isn’t able to create new instances of the entity. Try it out yourself and make your own conclusions.
The next one is a filter on a ‘List’ BB. I use the name lst_filtered_projects
, add the prj_name
to the list and jump to the ‘Filter’ tab to do something like this:
For you to copy:
$(system.organization)
Keep in mind the previous ‘Rule’ BB and ‘Security’ BB as they might interfere if not updated correctly. I removed both of them to have a try in runtime where it works as expected when I create a project entity instance with name appworks_tips
!
Time for the ‘Deadline’ BB with name dl_generic
:
Trust me…This works exactly the same as the condition for the ‘Rule’ BB!
The ‘Activity flow’ BB with name flw_generic
?
That’s all the same! Even for the ‘Lifecycle’ BB it looks the same:
Our final entrance is the ‘Email template’. For this one we require to add the ‘Email’ BB with just a default configuration applied and without saving anything. We don’t even require a mail server as we’re not sending out any mail. When we apply the ‘Email’ BB, you can add a new ‘Email template’ BB with sample name emt_expressions
. In the body we add an expression like this:
For you to copy:
{system.organization}
To try this one out in runtime, we need to update the default view layout lyt_default
of the entity where we add the ‘Emails’ panel on the far-right side. This is the view in runtime:
Create a new mail, use the created template, and check the result:
Nice…Now what?
Other expressions
In the above examples we saw three ways of calling a variable:
- Directly in plain text:
system.organization
- Surrounded by curly brackets:
{system.organization}
- Prefixed with a dollar-sign and ‘normal’ brackets:
$(system.organization)
When to use which one, depends on the context you’re in at that moment. Just try it out!
Time to have a look at other expressions…For this exploration we’ll misuse the final created mail template. I see this is the most interesting way to build a nice list to check the results for a full-blown set of expressions!
This is a compact list of updates I did during my own expression craftsmanship:
- The
project
entity updated with extra properties likeprj_start_date
andprj_duration
. You see it passing by in the expressions below.- Creating a ‘toChild’ related
issue
entity with an Integer type of propertyisu_points
and a Boolean type of propertyisu_is_solved
; just to play around with Integer / Boolean expressions.- Adding my
awdev
developer account to a functional role calledfun_role1
. This role is just a new type of document saved in the ‘roles’ folder of the project. You can use the ‘User Manager’ artifact to apply this role to your account. You’ll find the result for this change in thetargetRoles()
call below.
Behold this everlasting list of expressions to play around with. They all work (with comments) from my 22.1 AWP environment…Just copy & paste it into your own mail template to validate:
1 | #System: |
With the result from my test-email:
That’s an interesting list for me (and you) to remember. It will for sure help somewhere in the future! 🔮
Secret “list” expression
In the above example, you saw this expression passing by:("hello;in;my;array;world").split(';').contains('my')
Works great (also on the other building blocks) but let me tell you a little secret! For conditions in the ‘Rule’ BB and ‘Security’ BB (as well as setting a property value via a ‘Rule’ BB), you can also use that same expression in another format:'my' in list["hello","in","my","array","world"]
Interesting, as I couldn’t find this list
expression in any of the documentation. It doesn’t work in the email test template from above. That’s why I made it a separate section in the post!
Nice, “DONE”, and nailed it! When I review the list again, it provides interesting expressions to play along with in your own solution. I knew expression were possible, but it looks like we’ve exposed expressions beyond the documentation with real-life examples and proven screenshots! Have a momentous week; CU next time…cheers! 🍺
Don’t forget to subscribe to get updates on the activities happening on this site. Have you noticed the quiz where you find out if you are also “The AppWorks guy”?