Request Password to continue

rsaritzkyrsaritzky Member Posts: 469
Hi:

I want to do some extra checking on a Purchase Order before user can post.

If certain fields on a purchase line do not pass validation, I want to prompt the user for a password. If they enter the correct password, then the posting process continues.

So I want to create a form which will prompt the user for a password.

But I need the form to validate the password and return the result to the calling function.

For example, if I change codeunit 91 (Purch.-Post(Yes/No)) and add:

IF myfunc.CheckDatesOnPOLines(PurchHeader) = FALSE THEN
FORM.RUNMODAL(FORM::PasswordCheck)


The form will prompt for the password and determine if the password is valid, but how do I return an "OK" (or "Not OK") back to Codeunit 91?

Thx
Ron

Comments

  • matttraxmatttrax Member Posts: 2,309
    Why not just do it with roles and permissions? "Elevated" users can always post. There is code in the tips and tricks section for checking users and ad groups for roles.
  • rsaritzkyrsaritzky Member Posts: 469
    matttrax wrote:
    Why not just do it with roles and permissions? "Elevated" users can always post.

    The workflow here is different than can be accommodated with your suggestion. The supervisors who approve the "override" are not the people who post. When an override message is displayed, they want to call a supervisor over who will enter a password on the screen, allowing the the posting to continue. Using roles would require the supervisor to log into their workstation, bring up the Purchase Order and post themselves - not what they want.
    Ron
  • kapamaroukapamarou Member Posts: 1,152
    rsaritzky wrote:
    Using roles would require the supervisor to log into their workstation, bring up the Purchase Order and post themselves - not what they want.

    What about a table like: EntryNo, TableID, RecordID, UserName.

    The employee requests permission to post.
    The manager allows the post by clicking a button that inserts a record in the table.
    The user reposts.
    Your code check for an entry for that record.

    Then by user roles you allow only the manager to modify / insert into that table.

    You get the idea. Would that help?
  • rsaritzkyrsaritzky Member Posts: 469
    I can do the same thing functionally, but a little bit more efficiently with a single-instance codeunit, but I guess that's the way I'll have to go. Thanks for the suggestion.
    Ron
  • SPost29SPost29 Member Posts: 148
    To answer your immediate question from C/SIDE refernce guide

    RUNMODAL (Form)
    Use this function to create, launch, and close the form you specify. Use this function or the RUN (Form) function if you know at design time the exact form you want to run. Otherwise, use the Form.RUNMODAL or Form.RUN function.

    [Action] := Form.RUNMODAL
    Action

    Data type: code

    This optional return code tells you what action the user took. Here are the possible return values:

    If Action is...
    It means that the user...

    OK
    Pressed OK to exit the window

    Cancel
    Pressed Cancel to exit the window

    LookupOK
    Pressed OK on a lookup window

    LookupCancel
    Pressed Cancel on a lookup window

    Yes
    Pressed Yes

    No
    Pressed No

    Close
    Pressed Close, Esc, or closed the window using the title bar

    Helpform
    Selected Help

    RunObject
    Selected an option that ran another object

    RunSystem
    Selected an option that ran an external program


    Form

    Data type: variable

    Once you define this variable, you can run these form functions on it: SETTABLEVIEW, SETRECORD, GETRECORD, RUN, and RUNMODAL. Unlike the Form.RUN function, the system does not automatically clear the variable after it executes this function.

    If the form you specify does not exist, a compilation error occurs.

    Comments
    Once you define the variable f, you can use it before and after you run the form. If you use the Form.RUN function, you can only use the variable before you run the form.

    Examples
    This example shows how to use this function. Assume that the variable Form has been defined as Form 1.

    CLEAR(f)
    Form.XXX; // any user-defined function
    Form.SETTABLEVIEW(Rec);
    Form.SETRECORD(Rec);
    IF Form.RUNMODAL = Action::LookupOK THEN Form.GETRECORD(Rec)...

    Note that the code above includes the CLEAR function to make sure the variable has been cleared.



    Steve
  • kapamaroukapamarou Member Posts: 1,152
    rsaritzky wrote:
    I can do the same thing functionally, but a little bit more efficiently with a single-instance codeunit, but I guess that's the way I'll have to go. Thanks for the suggestion.

    You're welcome.

    If it were me and I could spare a table or two then I would go with the table so I can maintain a log. :wink:

    If you have more than one managers that may approve such operations then knowing who approved what is a plus, I think.

    But you can find more than a single solution and choose the one that best fits your needs.
  • klavinklavin Member Posts: 117
    Anything you may be able to use document approval for? Not sure what version, what you have licensed etc... I haven't used Document Approval's myself, but from things I have read about it - it might be a solution that works for you without having to write code and giving you a little more flexibility.

    Lavin
    -Lavin
    "Profanity is the one language all programmers know best."
  • rsaritzkyrsaritzky Member Posts: 469
    klavin wrote:
    Anything you may be able to use document approval for? Not sure what version, what you have licensed etc... I haven't used Document Approval's myself, but from things I have read about it - it might be a solution that works for you without having to write code and giving you a little more flexibility.

    Lavin

    Document Approval is on a more "global" basis. This is a particular circumstance that would require modifying Document Approval way more than just customizing an approval process. What we do is that we have thousands of jobs (each job is a foreclosed property that we are managing for our customers). When the job closes, a "close date" is stored in the job record.

    Now, if an invoice comes in from a vendor that applies to that job, and the posting date is after the close date, that raises a red flag, and requires a supervisor's approval to pay the vendor.
    Ron
  • Alex_ChowAlex_Chow Member Posts: 5,063
    1. Add a checkbox.
    2. Modify the onvalidate trigger on the checkbox so only managers can check on it
    3. On posting, check whether the checkbox is checked.

    No codeunits needed.
  • rsaritzkyrsaritzky Member Posts: 469
    Alex Chow wrote:
    1. Add a checkbox.
    2. Modify the onvalidate trigger on the checkbox so only managers can check on it
    3. On posting, check whether the checkbox is checked.

    No codeunits needed.


    Alex - this would still require that the manager log into the purchase order and check the checkbox. We want this to be displayed as some type of dialog during the posting process.
    Ron
  • klavinklavin Member Posts: 117
    I understand it more now...
    Our example was in E-Ship and using Miscellaneous packages...

    It was wanted that all of the packing stations to be able to access these or have them sent from any packing station under any login, but only the supervisors could approve the orders.

    I had created a table and form to manage the users and passwords (passwordtext on form) - Only gave access to this form to the DC Managers. Popped up a form to enter userid/password; had it do a check and return true/false for if it was valid.

    I even set it up for the passwords to expire every month and it would prompt them to change it and not have it as the last password...
    overkill, yes... but its what was wanted... They wanted to make sure no one was using Misc. Packages for unauthorized reasons like sending products to their house, but wanted it easily used everywhere.

    They were shipping as much as 1200 UPS packages a day at one time out of just one location, while 7 others were shipping at the same time as well.

    Definitely possible... Just make sure it is up prior to the posting routine, don't want to lock anyone.

    Kevin
    -Lavin
    "Profanity is the one language all programmers know best."
  • klavinklavin Member Posts: 117
    Actually forgot to mention, I had a table ID for what it was that was being protected, so it could be used for multiple things.
    -Lavin
    "Profanity is the one language all programmers know best."
Sign In or Register to comment.