Skip to Content
avatar image
Former Member

Approval Procedure

Hi,

In Business Partner Form I created an UDF for Approval Status and set a valid values as Approved and Not Approved. Default value is Not Approved.

If user creates a new vendor it will be Not Approved in Default. Only the Authorized super user can Approved the vendor. For this i created a procedure. The code follows:

IF (@transaction_type = 'A' or @transaction_type = 'U') AND @Object_type = '2'

Begin

DECLARE @usersign int, @appsts nvarchar(20)

SELECT @usersign=usersign,@appsts=U_appsts from dbo.OCRD where cardcode=@list_of_cols_val_tab_del

IF (@usersign not in (select userid from ousr where userid='1') and @appsts='A')

SELECT @ERROR = 1, @ERROR_MESSAGE = 'Only Authorized user can change the Status'

ELSE

SELECT @ERROR = 0, @ERROR_MESSAGE = 'SUCCESSFULLY UPDATED'

End

Here the problem is if User A has the rights & if a record created in user A then he is able to Approve it but User A is unable to Approve the record created by User B even though it has rights. Plz give me the solution.

Thanks in Advance,

Regards,

Madhavi

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Sep 02, 2008 at 08:53 AM

    Hi,

    does the user A has userid = '1' ?

    What is actually you want to attain here ?

    I have tested your query and I think it would better to use general authorization --> business partner --> select no authorization to user other than userid 1. If the BP master data can be save as draft, it is okay but it is not.

    Tell me what is the reason you use approval store procedure if it is actually the userid 1 that can add the new BP.

    Rgds,

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      I have a work around beside using your solution.

      I suggest to create a UDF named approver, so it will be U_Approver. Assigned this FMS :

      SELECT t1.userid from 
       OUSR T1 WHERE T1.INTERNAL_K = $[user]
      
      

      Using the above FMS, it will make the UDF to be filled with userid number. Then make the field is unable to edit in all the users except in the user manager (user id 1). This can be done using UDF settings (CtrlshiftB) --> untick the active column of the field. So, it won't be able to change by all the users.

      Use this following SP_TN :

      
      IF (@transaction_type = 'A' or 
      @transaction_type = 'U') AND @Object_type = '2'
      Begin
      DECLARE @usersign int, @appsts nvarchar(20), 
      @approver nvarchar(20)
      
      SELECT @usersign = usersign, @appsts = U_appsts, 
      @approver = U_approver from dbo.OCRD 
      where cardcode=@list_of_cols_val_tab_del
      if (@appsts = 'A' and @approver <> '1')
      SELECT @ERROR = 1, @ERROR_MESSAGE = 
      'Only Authorized user can change the Status'
      End
      
      

      So, when user id = 1 open and want to approve, it will be available to do by override the approver value.

      userid 1 can do that by shift+F2 or just type 1. After userid 1 changed the approver to be 1,, then userid 1 changes the U_Appsts to be approve. After changed, click update button.

      It will be succesfully updated.

      Rgds,