Approvals Application [Marketplace][4.5]

Posted by Simon Tregloan-Reed on 02-Jun-2017 04:03

Hi all,

I've been working with the approvals application, trying to adapt it to an application of mine but I've run into an issue.

My issue is that I need to have 2 approval processes, run one after the other, so that I have records signed off by 2 or even 3 levels of security before they are finalized.

My idea was to have a trigger on the work flow status field that would automatically start the next approval process when the last person had finished approving the previous process step. The trigger contained this bit of code that I found "rbv_api.startApproval(objName, objId, actionId)" but unfortunately it won't work because starting the approval process prompts the user to select the list of approvers from the default list.

A problem I have is that I don't understand why the function exists if the approval process won't allow me to utilize it because I am unable to turn off the function of picking a list of approvers at run time. With the application being a manual process, it defeats the purpose of what I'm trying to design.

Any help would be appreciated.

Regards,

Simon Tregloan-Reed

Posted by Shiva Duriseati on 09-Jun-2017 12:03

Hi Simon,

Thanks for the details.Yes like you said with every increase in the level of approval additional work need to be done using triggers. Its good idea to have control over setting than relying on them. I would suggest you to provide your inputs on the areas of improvement  in "Approvals" application so that our product management can finalize and include them in Rollbase future releases.Use this link to submit your inputs.

community.progress.com/.../rollbase

Regards,

Shiva

All Replies

Posted by Shiva Duriseati on 09-Jun-2017 06:04

Hi Simon,

Apologies for delay in getting back.

You mentioned that "Starting the approval process prompts the user to select the list of approvers from the default list."

If your record has to be approved by two users then you need to create two "Workflow Actions" of type "Start Approval Process" with default user selection respectively. After creating these two wf actions two triggers need to be created which will start above two processes.Now the main wf action of type "Run selection triggers" would make these triggers start the process.

There is no direct way to have 2 level or 3 level of approval but still you can do it by making use of existing API'S.

Following are the steps which I've performed for two level approvals. Whenever a record is created it will display "Start Approve Process" once user clicks then it will send it to User1 for approval once User1 approves the record then email will be sent to User2 for his approval after approve came from user2 then only the status changes to "Approved" until then the status would show "Approval In Process"

1)Create two users user1 , user2 and make them as approvers.
2)Create two "Workflow Actions" of type "Start Approval Process".

  •  "StartApprovalProcessFromOne" in which selected approver should be user1.
  •  "StartApprovalProcessFromTwo" in which selected approver should be user2.

3)Create a picklist field(SamplePicklist) with values "YES" and "NO".(Sole purpose of this field is to determine current update made from user in other words it is used as  a "Flag")


4)Create a trigger(ex:StartUserOneApproval) of type "Object Script" without enabling timing options and use the following code.


rbv_api.updateRecord("SampleObject", {!id}, {"IsApprovedFromUserOne":"YES"});
rbv_api.startApproval("SampleObject", {!id}, "Pbc0kXgTSxuEei_EchM-Tw");


5)Create another trigger(ex:StartUserTwoApproval) of type "Change Workflow Status", enable "After Update" timing option and use following code.From trigger properties change workflow status to "Approval In Progress"


if("{!SamplePicklist#value}"==="YES" && "{!status#value}"==="Approved"){
rbv_api.updateRecord("SampleObject", {!id}, {"IsApprovedFromUserOne":"NO"});
rbv_api.startApproval("SampleObject", {!id}, "Z_pSZw9rQGOgbC_O0SLjOw");
}


6)Now create a workflow action (ex:Start Approval Process)of type "Run selected triggers" and from the available triggers select "StartUserOneApproval" trigger

The above process works as follows:


Whenever a record is created and a user clicks on "Start Approval Process" then trigger "StartUserOneApproval" gets executed which sends an email to "user1" for approval,at the same time it will change the picklist value to "YES" and workflow status to "Approval In Progress". Now when "user1" approves the record the status has to be changed to "Approved" but we need to restrict it because until "user2" approves we shouldn't update the status hence another trigger "StartUserTwoApproval" which will verify for flag(in our case it is picklist) and Status accordingly it will start approval process for "user2". Finally status change to "Approved" only after getting approved from "user2"

Please let me know if need any assistance on this.

Regards,
Shiva

Posted by Simon Tregloan-Reed on 09-Jun-2017 10:25

Hi Shiva,

Thanks for your reply, I've spent quite a bit of time on the approval process and was finally able to get it to work, earlier this week, by setting up a similar process to what you've suggested. I had to change the trigger to run on any field update, instead of on workflow status change, which allowed me to have a multiple step process that flowed seamlessly between each step. Is that a bug with the process?

Getting this to work meant I needed to use some hard-coding which, I think, would cause installation issues between tenants. For each step I decided to code one trigger to run a different action, by calling the original ID, and checking the current flag of the record. If flag = 2 then run step 2 with this action else if flag = 4 then run this action instead etc.

I also found, on the approvals object, that I couldn't change the page the user used when approving or rejecting an approval record. I disliked how many approval records could be created during a multiple step process with a mixture of 10 or so approvers. I was looking into creating 1 approval record which would be updated multiple times and then would approve or reject the parent record when the last person had responded. This would work well for sequential approval records and could be adapted for the other types as well. This way I could see a new approval record for each step not each approver, from an admins point of view this would be easier to manage.

Over all I think it would be better if you had more control over the settings without relying on that trigger function and hard-coding the steps. It would be good to setup multiple steps and what approvers to use for each step, instead of creating different actions to handle this aspect of the process.

Also havng the ability to turn off the manual setup of picking approvers when the user clicks the "Start Approval Process" action button would help.

Are there any plans to update this application in the future?

Regards,

Simon Tregloan-Reed

Posted by Shiva Duriseati on 09-Jun-2017 12:03

Hi Simon,

Thanks for the details.Yes like you said with every increase in the level of approval additional work need to be done using triggers. Its good idea to have control over setting than relying on them. I would suggest you to provide your inputs on the areas of improvement  in "Approvals" application so that our product management can finalize and include them in Rollbase future releases.Use this link to submit your inputs.

community.progress.com/.../rollbase

Regards,

Shiva

Posted by Simon Tregloan-Reed on 14-Jun-2017 11:04

Hi Shiva,

Thanks for the feedback, I'll look at compiling my ideas for improvement and publish them in the approvals application section you mentioned.

Regards,

Simon Tregloan-Reed

This thread is closed