Options

approval management

AmaraaAmaraa Member Posts: 153
Hello,

When I try to send approval request it is giving me error that User xxx doesn't exist in User Setup table.
Then I went to code and I found out this in codeunit 439.

How could this ever can be possible? (Right me if I am wrong).
And it is default code.
UserSetup.SETRANGE("User ID",UserSetup."Approver ID");
IF NOT UserSetup.FIND('-') THEN
  ERROR(Text005,USERID);

And now what shall I do get rid of the error?!

Thanks,
Amaraa

Answers

  • Options
    BeliasBelias Member Posts: 2,998
    you can insert the user "xxx" in the "user setup" table :wink:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    AmaraaAmaraa Member Posts: 153
    Belias wrote:
    you can insert the user "xxx" in the "user setup" table :wink:
    Yes, I already did.
    I have setup the user in User Setup table.

    However, the system gives me the error.
    So, that's why I needed to go to the code. (Sorry for the brief introduction).
  • Options
    BeliasBelias Member Posts: 2,998
    oh, this is funny...
    UserSetup.SETRANGE("User ID",UserSetup."Approver ID");
    IF NOT UserSetup.FIND('-') THEN
      ERROR(Text005,USERID);
    
    you can notice that the error returns the System variable "USERID", but the filter is done with the value of UserSetup."Approver ID"...try to check (with a message, for example) if USERID and "Approver ID" has the same value.
    EDIT: the easiest solution to check the value is to change this
    ERROR(Text005,USERID);
    
    to
    ERROR(Text005,UserSetup."Approver ID");
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    AmaraaAmaraa Member Posts: 153
    Belias wrote:
    oh, this is funny...
    UserSetup.SETRANGE("User ID",UserSetup."Approver ID");
    IF NOT UserSetup.FIND('-') THEN
      ERROR(Text005,USERID);
    
    you can notice that the error returns the System variable "USERID", but the filter is done with the value of UserSetup."Approver ID"...try to check (with a message, for example) if USERID and "Approver ID" has the same value.
    EDIT: the easiest solution to check the value is to change this
    ERROR(Text005,USERID);
    
    to
    ERROR(Text005,UserSetup."Approver ID");
    
    and the funny thing is is setting range in the table that already has setrange, isn't it?
  • Options
    BeliasBelias Member Posts: 2,998
    :-k i'm not sure to understand you...what do you mean?probably tha:
    it's not common to use a value of a field of the table we're filtering as a filter value, but it's useful sometimes...i think that it is used to group records with the same user id field, but i've never took a deep look at this codeunit...
    and what about your problem?did you solve it?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    AmaraaAmaraa Member Posts: 153
    Belias wrote:
    :-k i'm not sure to understand you...what do you mean?probably tha:
    it's not common to use a value of a field of the table we're filtering as a filter value, but it's useful sometimes...i think that it is used to group records with the same user id field, but i've never took a deep look at this codeunit...
    and what about your problem?did you solve it?
    not yet. when I try to send approval it is giving me error that the user is not in the user setup table. but I'm sure that the user is in the table and not misspelled. ;)
  • Options
    BeliasBelias Member Posts: 2,998
    did you try my previous suggestion?
    the error tells you that USERID does not exists, but the check is done with a value of a field in a table, not on the USERID...you should try to change the error text as i told you and check if the user does exist
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    AmaraaAmaraa Member Posts: 153
    Belias wrote:
    did you try my previous suggestion?
    the error tells you that USERID does not exists, but the check is done with a value of a field in a table, not on the USERID...you should try to change the error text as i told you and check if the user does exist
    yes, and the user does exist.
  • Options
    BeliasBelias Member Posts: 2,998
    check the filters that are set on the user setup table before the find('-'), you're probably missing some filter that excludes the user even if it exists
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    chengalasettyvsraochengalasettyvsrao Member Posts: 711
    Did you place the checkmark in Unlimited approval field for the approver?
  • Options
    AmaraaAmaraa Member Posts: 153
    Did you place the checkmark in Unlimited approval field for the approver?
    It worked. But why?
    Thanks
  • Options
    vaprogvaprog Member Posts: 1,118
    It worked because the User ID is in your table, but no entry for the user with Approver ID (or Approver ID of Approver ID ...). The system searches along the chain of User ID .Approver ID=User ID ... until it finds a user that has an Approval Limit >= the amount to be approved.

    If a user has the the checkmark in Unlimited approval, the search terminates (the Amount Approval Limit field is ignored in this case).

    Since, without setting the checkmark, you still got the error some user does not exist, and from what you write you think the user is there, you probaby did not make the correction Belias proposed:
    Belias wrote:
    the easiest solution to check the value is to change this
    ERROR(Text005,USERID);
    
    to
    ERROR(Text005,UserSetup."Approver ID");
    
    This code change actually tells you, which user setup record is missing. The original code simply is wrong.

    You should set up approvals in such a way that (only) the last approver in the chain has unlimited Amount approval limit. All the others (starting with the user itself) should (sensibly) be configured with a strictly accending approval amount.
  • Options
    kokyas963kokyas963 Member Posts: 16
    Thank you vaprog.
    the best solution is your answer below:
    You should set up approvals in such a way that (only) the last approver in the chain has unlimited Amount approval limit. All the others (starting with the user itself) should (sensibly) be configured with a strictly accending approval amount.
    Best regards.
Sign In or Register to comment.