Jarvis Pizzeria: Workaround for XSD list-element issue in WebForms

In a previous blog we have made notices that it is not possible to create a Webform based on a xsd-type that contains a list elements. In our case a list of pizza ingredients.
In this post we will give an alternative way to create a webform that displays the data, including the list of ingredients. For this we have created a new form IngredientsWebForm.
As we tried before, It does not work to drop the full business object on the canvas. Therefore, we have now made up the form of separate components. 4 input text components, of which 2 are listed in a table component and a number component that is also displayed in the table. This results in the following format.
This is the form we will use for all different presentation (one of our next posts will be about different presentation of one and the same WebForm), but first we will use it in its default. In the top left corner you see that this is the main presentation which is also the default. It is quite logically that it is the default, because it’s the only one :-)
After saving the WebForm we go back to the process to update the various tasks.
For each task we have switched the form reference to the new IngredientsWebForm. The below example shows this for the ‘Prepare Pizza Crust’ task. The example also shows that the Main presentation is selected for the task.

The next thing to do is to fix the data association between the process and the WebForm. For this, we open the Data Associations for the first task. On the input side we make the mapping of the incoming data (via the Business Object) with the fields on the IngredientsWebForm. On the output side we go the opposite way.
But first the input side.
As you can see only the transfer of source to destination is not sufficient. There is a sub-transformation required. Luckily in PCS that is not very difficult. By clicking on the redbox a menu appear with currently one option (transform). Select this.
This brings the following screen.
Click Create to create a new transformation.
Specify the name for the transformation and click Create again.
Create the mapping / transformation.
Save the transformation. This brings us back to the parent transformation. Now the redbox disappeared and the equals sign is replaced by a multi-arrow sign.

For the output side something similar is needed. We suffice with giving a couple of screenshots of one of the implementations.

The table transformation
We have repeated the association between the process and the tasks for all 4 tasks.

Now it’s time to see if this solves the issue. So let's run a test. We deployed the application and executed a SOAP test. As can be seen below, now all Ingredient details are visible.
All 4 HumanTasks in the process use the same WebForm and they all show the same data in the same way. In another post we will describe how to implement different presentations for the same WebForm in a way that every task has it’s own dedicated appearance.

When testing this functionality we ran in a minor issue in the PCS version we used (17.2.3).
On the ‘Track Instance’ page we see the newly started instance.
Select the ‘>’ sign on the right to view the details. The ‘Prepare Pizza Crust’ activity is running.
Launch the Form to see the created WebForm and then ‘APPROVE’ it, or directly select ‘APPROVE’. Both is possible. It doesn't matter which one you choose to get the problem visible.

In the image below you can see that the Graphical view moved on to the next task in the process flow, while the open activities is still on the first task.

A simple refresh is required to get the right task available. It is just a tiny problem but quite annoying in use. So hopefully it will be fixed in the next release.

Jarvis Pizzeria: Human Tasks: Design First WebForms in PCS

To create simple Human Tasks we use web forms in Process Cloud Service (PCS). Within the Delivery Process of the Jarvis Pizzeria, we are going to implement the HT for ‘Try Contacting the Customer’. This human task should become available after we have checked that the Customer is not a member and we do not know his email address.  
Try contacting the non-regular / member from Jarvis Pizzeria, in the swimlane of the CallCenter.

We will take the Design First approach, meaning we will design the form and know what data objects we need afterwards, instead of looking at the data we need for the Human Task first.
This means we can start by creating a new web form.

In the properties window from the task we click the add ‘+’ icon next to the Form.

We want to, but also only can select the ‘New Web Form’ option, the basic form is the old form used in previous versions of PCS. It is still available in the engine for backwards compatibility. Selecting this option will open the ‘Create New Web Form’

After filling in the fields, we click the create button. Because the ‘open immediately’ checkbox is selected, this will bring us to the designer of the web form. We will create the web form by simply dragging and dropping the components from a pallet to the page. This page will show all available data from the order / customer that is available and needed for the task.

For the date & time that the customer is contacted, we want to use the current dateTime as the default value. When selecting a component or after dropping it on the page the properties will be displayed. In the properties we select that this value is a computed value and click the edit button.

This brings up a configuration screen, in here you can select several predefined functions. In our case we select the current date time function for the contactTime field.

Besides computed & default values, it is also possible and quiet easily so to call integrations for data. Within the web form we want to make it possible to select a favourite pizza for the potential customer, so we know what pizzas the customer likes.
After selecting the dropdown box that is on the page with the name ‘favourite pizza’ we scroll to the section where we can select a source in the properties. Here we can choose an already existing connector that we have already defined.
In this case we select the Rest connector FavPizzaRC, after doing that we can see the available resources on this connector. Once we have selected the FavPizzas resource we can select the operation of which we want to expose the data in the dropdown.

After selecting the source, the response options can be selected with help from the properties as well. When selecting the ‘Options List’ it autocompletes the response location. The same goes for the label and value binding, you can select the values if you have correctly configured the steps above.

Now that we have created the default value and the dropdown, lets press the Preview button to find out how the web form looks.
Within PCS, the preview modus of the web form is started and you can select different devices on which you want your form to be shown. In our case we want to have a look how it will be presented on a tabblad.
You can see that the current date time is inserted as defaultValue for contactTime.

Even in preview modus, when selecting the Favourite Pizza dropdown, the Rest service will actually be called and you can see the data that is returned from the service.
This is how easy it is to create a simple human task with the help of the web form technology within PCS. You can do even more advanced stuff within the form, but for most use cases an extra Rest call or populating some default data should be sufficient.
So we choose to cover and focus on these functions within the web form.  

Jarvis Pizzeria: Handle SOAP Faults within PCS

As we are very optimistic developer we started out with modeling and testing the happy flow of our Jarvis pizzeria. But as experience learns it is the big bad world that obliges us to deal with both expected and unexpected failures. This blog post we will look into the handling of SOAP faults that PCS has to offer out-of-the-box.

As a starting point we have created a basic process with one service call:
This SOAP Fault service is connected to mockable.io service that is configured to throw back a remote fault, i.e. the invoked service endpoint cannot be reached. Let’s deploy the process, start an instance and see in the workspace what has happened.
Note: to use the OOTB error handling leave the fault policy checkbox marked during deployment:

The graphical view shows that that the process, as expected, ran into a faulted state:

Luckily for us the engine indicated the SOAP fault as “Faulted recoverable”:

First take a look at the tree structure of the process:

The “Instance has started the activity” shows the following request message:
All the “Instance error” show the following message:

The service has been called three consecutive times with intermediate breaks of 5 and 10 seconds respectively. The process now can be fixed with the buttons that have been discussed in a previous blog post.

Now lets deploy the exact same process but without the fault policies.
Running the process show the exact same graphical view as the one above:

However, the details section of the failure shows different data:

Note that the Status is different, without the fault policies the process is in an exception state.
Looking at the tree structure of the process we see the following:

Does this mean the process is dead right now? Well yes, more or less it is. We have two options to choose from:

Both of these options won’t bring back this process instance back to life.

The handling of SOAP faults within PCS is extremely powerful, given that you have turned on the fault policies. When the process encounters a runtime error it automatically tries to recover the fault while at the same time there is an extensive set of tools at one’s disposal to get the instance recovered. One can simply retry the service call, change instance variables, simply continue or skip the faulted activity or suspend the instance temporarily. Be aware that these powerful tools can also work adversely when using them wrong. But as always...with great power comes great responsibility.

Are there any scenarios conceivable where a developer should turn off the fault policies? The disadvantage of turning on fault-policies is that the fault policies are turned on for the entire application. If one - for whatever reason - wants to build a proprietary error handling framework than this feature should be turned off. Maybe we can see in the nearby future an opportunity to configure the fault policies in a more fine grained manner, to make this feature more powerful. Then again, compared to the on-premises error handling we’d have to say that this is a big leap forward again!

Jarvis Pizzeria: Test against the Development or Production environment

Within PCS there are actually two different environments, a development environment and the production environment. Once you have deployed your application it is available in the production environment as a certain version of the application. However, you might want to test your application before you deploy a new version. You can also test your environment against the so called ‘development environment’.

The blue button bar has a Test as well as an Deploy button on the top right.

The Deploy button takes you to the normal deployment screen.
In here you can deploy a certain version of your application, start an instance and see how it behaves. However, this is the production version of you application, calling real integrations.
We have already shown in previous blogs how to start an instance in production.

In this example a REST call, as a result instance #283 has been started.

However, when we press Test instead of Deploy on the top right blue bar, this takes us to a different screen.

We see that we can try our application in the Workspace. When pressing the green button that opens up the following home screen.
You can see that on the top there is a blue bar which says ‘Testing Mode’, you can toggle between the testing (or development environment) and the production environment.
On the center you can start to track instances by clicking the right blue ‘Track Instances’ button.
You can start instances of your application if you have a form start on the left, however, we use a message start. So how do we start an instance in the development mode while we use a message start?
For this we need to set a header in our request, the param ‘pcs_mode’ needs to be set to ‘dev’ in the header to get the information from development instead of production! Here we do a call again to the process-definitions to find out the processDefId for the development instance. For a more detailed explanation of how the REST call works against PCS, see this previous blog entry.

Once we got the processDefId, you can see it has player~ in front of it in this case, we do a call just like we are used to for the production instances. As we can see from the screenshot below, instance #277 is started in the development environment.

So now that we have started the instance, we will go to the ‘track instances’ page. If we switch testing off on this page, it means that we see production data. As expected, we see our instance #283 that we started earlier.
Also notice how the bar on the top of our screen is now green, instead of the blue we saw earlier.

When we switch testing on, we go into the testing mode and see the data from the development environment.

As you can see here, we see our instance #277 that we created in the development environment!

VBCS: Action Handlers, send an email

Within VBCS, Virtual Builder Cloud Service, you can add custom actions in menus or on buttons. We will explore this feature in this blog by allowing people who visit our Tech17 application to send an email to a speaker.

Within the REST service, I added the email field, so it does now come back in the collection as well. I changed the extension and business objects accordingly, I will not cover that in this blog post.

The result of the service now looks something like this.

On the existing Speakers page, from the common section, I drag & drop a button into the list view item. On the right hand side, I select the Action tab, the hand with the arrow next to the pointing index finger.

When clicking the green ‘Add Action’ button, you see a couple of predefined actions. However, we want to do a custom action, so we click the ‘Add Custom Action’.

This brings us to the custom action screen, in where we can choose out of a lot predefined custom actions. Using this actions you can define a flow of actions that you want to happen when pressing the button. Under Miscellaneous, there is and ‘Compose Email’ option, which I drag and drop into the center.

The ‘Compose Email’ dialog will appear.

In the dialog, I can either enter data myself or we can select it. When clicking the data icon, I select the Speaker Business Object, after which the E-mail field is automatically selected, because it is configured as mail property.

It will be selected and entered in the inputfield.

After this, I add the ‘Message about the nlOUG’ as subject. I want to have a convenience in the body, by starting with the Speakers name, which I can select again from the business object.

After this, pressing Done on the top right will bring us back to the speaker page.

Now that the page is done, we can press the run icon and run the page to test our new functionality.

Pressing the ‘Send Email’ button next to my own name, opens the email client on my laptop and start a new email. It will fill the To, Subject and even the name in the start of the body!