In Volker Drees‘ recent blog How to set up an easy Material Master creation Workflow for Duet or Alloy you’ve seen how to create a custom SAP Business Workflow that exposes its user decisions to Duet or Alloy.
Let’s expand this scenario for Alloy and create a customized Notes form, that’s able to display the master material data.
After you’ve implemented the steps Volker describes in this great How to set up an easy Material Master creation Workflow for Duet or Alloy, your SAP Business Workflow will expose 5 material values (ZMaterialNumber, ZMaterialText, ZMaterialSizeDimensions, ZMaterialEAN, ZMaterialEANCategory) to Alloy.
You can see those 5 values (in the Document properties) coming along with your user decision Note, that asks the Lotus Notes user to Approve or Reject the newly created material.
Those 5 values are now prefixed with WorkflowContainer00, but as you can see in the screenshot above, they’re all there. So let’s expose those values to the user…
Please note, that we’ll use slightly different material values in this example than Volker used. We’ll use ZMaterialNumber, ZMaterialText, ZMaterialGroup, ZMaterialNetWeight, ZMaterialWeightUnit as example values.
First let’s try to understand how Lotus Notes and Lotus Domino handle generic workflow Notes coming from SAP. You might have already seen the Alloy workflow configuration on Lotus Domino.
The magic happens in those two values at the bottom: Bound item type and Form name. Those values tell Lotus Domino, that if there’s an Alloy Note coming in that contains a field called BoundItemType with the value Alloy.MaterialWorkflow.ApproverTask use the (hidden) Lotus Notes form ERPApprovalForm to display this Note. (Keep in mind the BoundItemType value. We’ll need that later…)
Knowing that, let’s open Domino Designer and have a look at this ERPApprovalForm.
You’ll find this form in the master mail template of your Domino Server which has been merged with the Alloy mail template.
Please note: Changing the Lotus Domino master mail template can cause severe problems on your Lotus Domino and Lotus Notes system.
The default ERPApprovalForm is quiet simple. It contains a header, a comment section and a body.
We could now simply add some fields into this form, which would display our custom material values. But with that ERPApprovalForm would loose its generic character, as ERPApprovalForm would always try to display material values, even if you’re using ERPApprovalForm in some totally different workflow as well.
A better way to handle this is to embed a computed Subform into ERPApprovalForm. Let ERPApprovalForm compute (based on the field BoundItemType) during runtime which concrete Subform it should embed.
Check the box Insert Subform based on formula and click OK
This will cause Lotus Domino to check the value of a field BoundItemType (which is contained in every Alloy workflow Note) and use the values’ name to determine which Subform should be embedded. So if the value of BoundItemType is myForm, Lotus Domino will try to embed a Subform called myForm.
Having explained that, we know now what to do next: create a Subform which will display our material values.
As explained above ERPApprovalWorkflow form will seek for a Subform that name matches the value of the BoundItemType field. Remember what I said earlier? Keep the BoundItemType value in mind, as we now need it as name for our new Subform.
Create a table in that Subform that we can use to display our custom material values.
The last row of the above given table might surprise you. This row should later contain the name of the user that requested the approval for the new material. We’ll have a look into this later…
First make sure that the material fields contain the corresponding custom material values.
Now look into the SAP Business Workflow Builder (Transaction: swdd) to see the custom material fields again.
As seen at the very beginning of this blog, the workflow container elements will arrive in Lotus Notes with a prefix called: WorkflowContainer00.
For each of your material fields, enter the workflow container name (which will arrive in Lotus Notes) in the corresponding value field.
This will fill the table fields during runtime with the values of the corresponding custom workflow container fields.
Save the new subform and you’re done.
But wait what about this requester field we put in addition to our table?
As said above, the intension of that field is to display the workflow initiator name (the name of the person who requested the material approval).
As this person most probably will also be have a Lotus Domino user account, and maybe even a Lotus Sametime account, let’s not only display the persons name in that field, but show also his/her Lotus Sametime status.
But what should we enter in the fields’ value? Where do we get the requesters’ name from?
The requester name is also part of the Notes document send by Alloy. The field is called RequesterName but it contains the SAP username of the requester and not the full qualified Lotus Domino username we require for Lotus Sametime integration.
So we need to map the SAP username to the Lotus Domino user somehow.
The following script will do this mapping for us in a very simple manner. (Note the limitation comments in the script)
The script will try to lookup the SAP username in the Lotus Domino Directory and map it to the requesters’ Lotus Domino username.
Save the Subform and you’re done!