/ Development  

Discover the ultimate simplicity feature every case management solution requires

Hi there AppWorks fans,

Welcome to a new installment of AppWorks tips.

OK, I was just thinking about the approach for this “Favorite cases” feature post; Looks like it’s a little harder as expected in the first place. I thought about simply adding a Boolean flag on the case, showing a nice favorite icon, and based on this flag we show a favorites list…Sure, that’s one way to do it; if you’re the only user in the platform! 🤣
We have off-course multiple users that all want to have their list of favorite cases and when we follow that route it smells to me like a ‘toMany’ relation BB on a “customized” ‘User’ identity entity; Or better the ‘Preferences’ entity of the identity package! We fill that relation data with a “smart” action BPM “Add to favorites” on the case with some logic to not show it again until action rule “Remove from favorites” executes. Ohw, let’s not forget about that smart list to show favorite cases for the current user!? You see how quickly a simple change on the use-case will have a dramatic impact on the low-code implementation, but let’s see…We just build it from scratch and learn as we go…How hard can it be; right!?

After a sleepless night 🤯, I dreamed about the holy grail…Well, I did some pre-configurations to see what would be possible as I find the initial thoughts too complex! Why not simply keep track of the user IDs (‘toMany’ relation to the identity ‘User’) on the case itself! Hmmmm, this way we don’t require a customization of the identity entities, and we can create a favorites ‘List’ BB on the case (where it belongs in my opinion) with a smart filter! AHA…that will be the way for this post!


Let get right into it…

It’s a great sunny Saturday here in the Netherlands, kids are at work or watching Netflix/YouTube, and my wife doing her woman stuff…The perfect time to build something great with all the Tips & Tricks you can expect from every post at “AppWorks Tips”…Have fun!

Boot up your AppWorks machine and dive into your workspace with a basic project. You know I always use a snapshot that gives me a head start on project initialization with a standard folder structure…You will see it passing by in the screenshots below.

Let’s start the creation of a new entity. Smooth and slowly with just one property, generating the default building blocks of the initialization wizard, putting a bit of naming convention flavor, and you get something like this as a first start:

favorite_001

Now we create a new ‘Relation’ BB with name to_many_user; As easy as this:

favorite_002

After this relation, we will add two new action type of ‘Rule’ BBs.

  • “Add to favorite”
    • Name: a_add_to_favorite
    • Icon: https://www.compart.com/en/unicode/U+2606
    • Condition (watch the extra !): !(item.to_many_user[].Properties.UserId).contains(User.Properties.UserId)
    • Start BPM: bpm_add_to_favorite
  • “Remove from favorite”

This is how it looks like for the first one (the other one speaks for itself):

favorite_003

Notes:

  • You need to copy the icon image itself; Not the Unicode! Read more here.
  • First create the rule with a “normal” label (as required!); You can update it to the icon in the rule properties afterward (in the right panel of the entity BB overview!)
  • You can initiate the BPMs already with a one-step activity; We implement the rest later. Make sure it’s short-lived and nicely saved in the bpms folder of the project.
    favorite_004

This is what we have so far for an overview in between:

favorite_005

Time to grab a drink! 🥤

Tip: if you already tried out some stuff it can help to add the to_many_user relation as grid to the ‘Create’ form!

Next, we add the ‘Web service’ BB with the enablement of these operations:

favorite_006

Because these operations depend on a service container of type ‘Application Server’, we create a new one from the ‘System Resource Manager’ artifact with this input:

  • Connector: Application Server Connector
  • Group name: sg_appserver
  • Web Service Interfaces: Mark the Method Set Entity case (you must have published it once!)
  • Service name: sc_appserver
  • Startup automatically
  • Assign to the OS process (as recommended for each service container by OpenText support!)

Comment below if you don’t have a clue what I’m talking about…

Now for our lists…The “All cases” list is already in place. Let’s add another one (lst_cases_favorite) with an interesting filter value of $(User.Properties.UserId):

favorite_007

It can happen you get this error in runtime after publication on this list:
favorite_008

In that case, you need to add the to_many_user.UserId in the list as filter option!
favorite_009

“Filter” is also the only option because it’s a multi-value/repeating property! Don’t shoot the messenger here; Also not on the unclear error message!?.

Give it a go and try out the lists in runtime after a publication. I hope you followed the trick adding the to_many_user as grid on the ‘Create’ form to play around and do a solid test on the favorite cases list. Next step is to add the current user to this “hidden” relation grid with our action buttons.


BPM implementations

After a quick break and reconsideration on the BPM implementation part, I conclude it’s as simple as this pseudocode:

1
2
3
4
5
6
7
//Add to favorite
var response = GetAllUsers(UserId);
AddToToManyUser(processProperties.caseItemId, response.userItemId);

//Remove from favorite
var response = GetAllUsers(UserId);
RemoveFromToManyUser(processProperties.caseItemId, response.userItemId);

This is the first BPM to add a favorite:

favorite_010

With this consolidated view of the messagemap (watch the ‘Replace Content with Expression’ update!):

favorite_011

This expression substring-before(substring-after(instance:instanceProperties/instance:startedBy/text(), 'cn='), ',') gets its value from this input string: cn=awdev@awp,cn=organizational users,o=appworks_tips,cn=cordys,cn=defaultInst,o=awtips.com. Now you can do the math on the substring tricks.

The second BPM does the exact opposite:

favorite_012

I leave the messagemap to you; It’s a simple task after the above descriptions! Comment me if you’re dawdling around lost.

Do a publication, test around…Trust me 😇, it’s all working fine…Except for one thing! It’s looks like the action itself does not get a refresh!? Strange, as I always thought the short-lived option on the BPM solves this, but it looks like only the form get an update, but not the action bar!? #SUPPORT!

You can solve this by redirecting to the same layout after triggering the action rule. See this trick:

favorite_013

It’s what it is…as it also introduces a repeating breadcrumb bar:

favorite_014

Yes, that’s again #SUPPORT! You see that it’s always something you need to accept or play around with. The platform still has lots of things to improve, but it gets better with each release.

While reviewing this post, my brain gives a new idea! Why not place the action buttons directly on the form!? I haven’t tried it, but it might work!? Comment me if you tried it…

Ohwwww; And here are some extra free tips:

  • Use an ‘Email’ BB and mail template to evaluate your expressions for a valid outcome. Read about it here.
  • Use the application configuration entity to introduce a is_debug_mode feature flag to hide panel/sections where applicable. Read about it here.

Download the sources for this post here


Nicely “DONE”. The power of low-code shows its potential again at the AppWorks platform for us low-code developers including interesting (...).contains(...) conditions and $(...) filter options. The “favorite” feature puts us in an unthinkable situation, but BPM logic always wins in the end! Play around with the knowledge of this post and I see you in the next one…Cheerz; I’m thirsty! 🍺

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”?