Using the Custom Approver Feature

App Portal 2021 R1

If the built-in feature of selecting approvers using workflows does not satisfy your requirements, you can define a custom query to select approvers based on the Active Directory attributes of logged-in end users. To implement the ability to specify custom approvers, perform the following steps:

To use the custom approver feature:

1. Enable the custom approver feature by executing the SQL query below:

update WD_AppSettings set Value = 'True' where KeyName = 'UseCustomApproverSearch'

Note:If you want to pass the user name of the logged in user to the stored procedure, then you need to use the sAMAccountName as the custom variable:

update wd_appsettings set Value = 'sAMAccountName' where KeyName = 'CustomApproverSearchVariable'

2. Define the AD user property that will be used to filter the approvers.
The value of this property for the currently logged in user is passed to the custom stored procedure.
The default attribute is Department.

This means that if the feature is enabled, and the end user chooses the custom approval option, App Portal will load all the users in the department that the user belongs to.

3. To switch the AD property that App Portal needs to use, change the SQL below accordingly:

update WD_AppSettings set Value = 'Department' where KeyName = 'CustomApproverSearchVariable'

4. Restart IIS or go to the Admin > Settings view and click Save to reload the cache.
5. Verify that the stored procedure sp_Search_Custom_Approver exists.

If needed, you can use the following SQL to create the stored procedure:

IF EXISTS (

    SELECT *

    FROM sysobjects

    WHERE id = object_id(N'[dbo].[sp_Search_Custom_Approver]')

    )

BEGIN

    DROP PROCEDURE [dbo].[sp_Search_Custom_Approver]

END

GO

 

CREATE PROCEDURE [dbo].[sp_Search_Custom_Approver] @Variable VARCHAR(500), @Level int, @ApprovalTemplateID int, @TotalCost float

AS

BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from

    -- interfering with SELECT statements.

    SET NOCOUNT ON;

 

    -- Insert statements for procedure here

    SELECT DISTINCT ADSPath, UserName, Department, Office, FullName FROM vUser where Department LIKE '%' + @Variable + '% '

END

GO

6. Edit the stored procedure as needed.
7. Create a new approval workflow and choose the Allow requester to define workflow option.

 

8. Create a new workflow step, assign a default approver, and choose the Allow Approval Level User Edit and Force Approval Level User Edit options.

 

9. Attach the approval workflow to a catalog item. When you checkout the software, you will see the following screen with the option to specify the approver:

10. Clicking on the Specify Approver button will call the stored procedure and pass in the value of the approval property defined in Step 2 to the stored procedure, which will return the results accordingly. In this case, it will return all the users in the Department of Schaumburg.