Technical Articles
Fiori Launchpad: Display Background Send Mail Workflow Task with Decision Step in My Inbox and Notification Center
This blog post is to share solution of the recent problem I faced in SAP Fiori My Inbox App and Notification Center with all of you
Presumptions
- My Inbox Fiori App has been configured
- Notification Center (if required) has been configured
Problem
I faced this problem when I used the Send Mail step to send Notification in a Workflow.
In SAP GUI it was working perfectly. These get displayed in Unread Documents/Documents Category of SAP Business Workplace (SBWP) –
But these were missing in the My Inbox app and also the Notification Center. While trying to find a solution for this, I saw the SAP Note shown below and came to this conclusion –
My Inbox app and Notification Center in Fiori Launchpad do not support the Background Tasks of the Workflow. Only the workitems of User Decision dialog steps/tasks are shown there.
Solution
Go to the Control Tab of the Workflow Step and open the Task –
To make it a User Decision Task, Uncheck the Background Processing Checkbox and Check the Confirm end of Processing as shown below –
Confirm end of Processing will provide the decision step button called “Complete Workitem” in SAP Business Workplace (SBWP). The name itself clarifies that this button is used to complete the Workitem. Hence, after user action, workitem will be moved out of the Open Workitems Category in SBWP (Though it will be still in Documents category).
After making this change, the workitem will start appearing in My Inbox and Notification Center. And we have achieved our 1st milestone. 🙂
As you can see in the screenshot below, the User Decision button “Complete” is missing in Fiori My Inbox app –
Because of this Send Mail Workitems will never move out of My Inbox, as a result it will get too much of load. So, let’s start the next step.
What we need to do is a small configuration to get the Decision Step Button in My Inbox app. Go to –
SPRO -> SAP NetWeaver -> SAP Gateway Service Enablement -> Content -> Workflow Settings -> Maintain Task Names and Decision Options
Enter the Workflow ID and Step ID of the Send Mail Task in Workflow. Then, mark the entry and select “Decision Keys” –
Enter these values now –
- Decision Key – Numeric value. This we will get back in return after user action
- Decision Text – Use any Description for the button which is suitable as per Users
- Nature of the Decision – Positive/Negative/Neutral, this will manage the color of the button
I have configured it as “Complete” –
Now the “Complete” Button will start showing in My Inbox –
But pressing this button will not give any result as of now. For that, we need to implement a BADI – /IWWRK/BADI_WF_BEFORE_UPD_IB. In this, we get the “Decision Step” taken by the user and it can be processed as per requirement.
BADI Implementation – Z_MYINBOX_NOTIF_WF
Filter values in the BADI Implementation should be filled with the Workflow ID and Step ID of the Send Mail Task in Workflow, so that it gets executed only for these –
There is only one method, /IWWRK/IF_WF_WI_BEFORE_UPD_IB~BEFORE_UPDATE, available which is sufficient for our requirement –
Code Snippet –
METHOD /iwwrk/if_wf_wi_before_upd_ib~before_update.
*&--------------------------------------------------------------------&*
*& Revision Log &*
*& Date : 05-Jun-2020 &*
*& Author : Harsh Bansal (BANSAL) &*
*& Revision Tag : Initial Version &*
*& Description : Complete Workitem in MyInbox after User Decision &*
*&--------------------------------------------------------------------&*
* Local Data Declaration
DATA: lv_subrc TYPE sy-subrc,
lv_status TYPE sww_wistat.
CLEAR: lv_subrc,
lv_status.
IF iv_decision_key EQ '0001'.
* Status: Ready to Committed Status
CALL FUNCTION 'SAP_WAPI_WORKITEM_COMPLETE'
EXPORTING
workitem_id = is_wi_details-wi_id
IMPORTING
return_code = lv_subrc
new_status = lv_status.
IF lv_subrc EQ 0
AND lv_status NE 'COMPLETED'.
CLEAR: lv_status.
* Status: Committed to Completed Status
CALL FUNCTION 'SAP_WAPI_WORKITEM_COMPLETE'
EXPORTING
workitem_id = is_wi_details-wi_id
IMPORTING
return_code = lv_subrc
new_status = lv_status.
ENDIF.
ENDIF.
ENDMETHOD.
To complete the workitem and move it out of the My Inbox app when user presses the “Complete” button, we have to call the FM – SAP_WAPI_WORKITEM_COMPLETE
As you can see it has been called twice, that’s because after running one time, it just changes the status of workitem from “READY” to “COMMITTED” only. That’s why it has to be called again and now after execution, status of the workitem gets updated to “COMPLETED” and workitem will be moved out of My Inbox app
Note – Check on Decision Key value is based on the configuration we did earlier
Conclusion
Changes to be done –
- Uncheck Background Processing and Check Confirm end of Processing in Send Mail Task
- Configuration to get the Decision Step Button in My Inbox
- BADI Implementation to complete the workitem after user action
That’s it, now every time this workflow will be triggered, it will be available in SAP Business Workplace (SBWP), Fiori Launchpad My Inbox app and Notification Center. After user action SAP_WAPI_WORKITEM_COMPLETE in BADI will change the status of Workitem to “COMMITTED” and then “COMPLETED“. Finally, it will be cleared out from all the platforms.
Voila! We have reached our goal 🙂
Thank You !!
Hello Harsh,
This is very helpfull document, keep it up.
Thanks a lot Venu 🙂
what if we make a a fork in the WF.
one arm is the mail and the other arm is the task with same same logic as the batch job.
that task will automatically run.
that would be less performance intensive.
maybe in that we can get the workitem for which we want as we will have the workflow id as well.
Hello Siddharth,
Thank you for your suggestion.
Actually we don’t need it in either Background Job or Workflow. Today while trying to make the solution better, I implemented an easier and much better one. I have updated the same in the blog post. Please try to go through it again.
Regards,
Harsh Bansal
Good one Harsh.
I was also trying to build this since the FIORI launch pad was not responding to background tasks of the workflows. This really helps.
Thanks
Thank You Varun.
Good to know that it helped ?
Regards,
Harsh Bansal
Hi Harsh,
Thank you for really helpful blog, One thing I am trying to figure out with my Inbox app to have more information while approvals. for example a previous PO approval app gave lot of details in Info tab .But My inbox does not give that much information . any idea how we can enrich info tab in My inbox app to provide information like previous specific approval apps (e.g PO approval, Pr approval apps ).
Regards,
Hitesh
Hi Hitesh,
I am getting following details in info Tab of My Inbox -
Regards,
Harsh Bansal
Hi Hitesh,
You have to configure the Task into SWFVISU Tcode otherwise it does not display Header/Item display into My Inbox.
You need to provide required OData service, Entity set and Annotation Model with link to Document. Refer standard Task of PO into SWFVISU, you will understand required steps to follow.
Regards
Samir
Thank you for that very interesting blog.
I am wondering if you could achieve the same result with less effort if you did it this way:
I haven't used Fiori My Inbox much, but I would expect the following result:
Am I hoping/expectng too much? I will try this myself when I have a chance! 🙂
Hi Paul,
Actually I had tried that way also but couldn't achieve 100% result as per project requirement. So, had to play around with Mail Task itself 😉
Regards,
Harsh Bansal
I tried this and it works. The only drawback is that the workflow will wait for that step, it is not like a mail but a decision so workflow will halt at that step.
But it works with minimal effort.
Very helpful blog.
Thoughts of of Paul and Samir is highly appreciable.
Thank you Suresh 🙂
Hello Harsh,
I am facing the same issue, mail step showing mail in SBWP but not in my Inbox App. I followed the exact steps which you have mentioned above but now the workflow get stucks at email step. With message 'Error while sending email'. Can you please guide me here?
Hello Pravin,
Sure, I will be happy to help if possible. Can you please share more details of error and some screenshots if possible.
Regards,
Harsh Bansal
Hello Harsh,
Thank you for your post!
I have a doubt: how can I know what's the name of my Workflow? I have this problem but I don't know if I need to create a new Workflow or if I have one like yours. I suppose that I already have one because the messages are displayed in SBWP like yours.
Regards,
André
Hello Andre,
You will have to check the Workflow Log to know the name of Workflow and relevant Task
Regards,
Harsh Bansal
Hello Harsh.
great blog. One question. We are facing a similar problem. We want to send from a transaction (CC02) a message as express mail. In SWBP everything is fine, but could you give me a hint how to integrate this standard functionality in Notifications and the My Inbox?
I wrote also a question with a detailed description from the requirements (Integrate express Mail in Notifications and My Inbox)
Kind regards
Sigi
Hello Sigi,
I tried to test the scenario you mentioned to understand it. Unfortunately, in this standard procedure no Workflow/Task is triggered so no workitem is getting created. Hence, my approach can not be followed here. To achieve that, a Userexit/Enhancement will be required to trigger the Send Email Task and then to show the generated Workitem in My Inbox and Notifications of Fiori Launchpad.
Regards,
Bansal
Thank you Bansal for your work
Regards
Sigi
Hello Harsh.
Thanks for sharing this blog. It is very helpful.
I also have a question. When I only send Notification in MyInbox to particular person, why all users received the Notification in MyInbox?
It is related to the Agent Assignment or wrong Recipients fetch?
Workflow
Thanks and Regards
Andrea
Hello Andrea,
The receiver parameter should be of type, for example SWRTAGENT, to have the User ID(s) instead of the email address.
Can you please try with this.
Regards,
Bansal
Hi Bansal,
Thanks for your reply.
Do you mean change the RECEIVER parameter type for Method(SENDTASKDESCRIPTION2)? Original RECEIVER type is 'BOR Object Type'.
Or the 'EMAIL_RECEIVER' I defined in Workflow?
Additional, if I set Recipients Expression as '&EMAIL_RECEIVER&', it will bind the 'ADDRESSSTRINGS' automatically. It that correct? The &EMAIL_RECEIVER&' will pass the user ID like 'USxxxx'.
Thanks and Regards,
Andrea
Hi Andrea and Harsh,
I am facing the same issue. I have set the task as General task and passed the userid concatenate with 'US' in the recipients. But the task is getting sent to all users.
Could you please help me understand if I am missing anything?