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
0
Comments
My Blog - nav.education
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.
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?
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
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.
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.
Lavin
"Profanity is the one language all programmers know best."
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.
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.
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
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.
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
"Profanity is the one language all programmers know best."
"Profanity is the one language all programmers know best."