Recently on the GPUG Open Forum, Jeff Roe asked if it was possible to disable manual entry by users into the SOP Number field on the Sales Transaction Entry (SOP_Entry) window.
I suggested using GP Power Tools – Developer Tools module to create a quick trigger to lock or disable the field. As Jeff is already a GP Power Tools user and has the Developer Tools module registered, I created the required code and posted it on the forum thread. Here is a slightly more detailed version of the forum response.
My original plan was to trigger after the Window Pre focus event on SOP_Entry (Sales Transaction Entry) window to disable or lock the SOP Number field. However, I realised that this would not work as the SOP Number field needs to get focus for the next number to be populated.
So, decided that the best way to “lock” the SOP Number field without changing any functionality was to force the system to change focus to the Customer ID field once the SOP Number field is selected (and so populated). This will ensure that the next number functionality works as expected but also prevents manual changes to the automatically provided numbers.
To make this work we just need a single trigger, but to make it easier to maintain the customisation, I created a Project to put the Trigger into. This step is optional, but worthwhile as you can stop and start triggers in a project easily and you can export and import projects with a single click.
From the Project Setup window, I used the Add button and added a Focus Event Trigger to run After Original script for the Field Pre event on the field ‘SOP Number’ of window SOP_Entry of form SOP_Entry.
We did not need any changes to the Actions tab or Options tab (the Project ID is already populated because we added the trigger from the Project Setup window) and just needed a single line of code added to the Script tab. The line is highlighted in the screenshot:
focus 'Customer Number' of window SOP_Entry of form SOP_Entry;
This whole process took a couple of minutes to create. Writing the forum response and this article to explain what I did took much longer.
I have attached the configurations settings xml file which you can import into your system using the Configuration Export/Import window (for the first time) and the Project Setup window once the project exists.
I am trying to get more examples published and this one has been added to the GP Power Tools Samples page:
The possibilities of what you can do with GP Power Tools – Developer Tools module are limited only by your imagination.
Post comments if you have any questions.
This article was originally posted on http://www.winthropdc.com/blog.