3 Replies Latest reply on Jan 20, 2010 10:00 AM by philmodjunk

    Pre-populate fields after custom dialog box



      Pre-populate fields after custom dialog box


      Hi Everyone, 


      Okay the problem is this. I have a form that includes customers' first and second names. These fields are dropdowns and are validated only if taken from value lists on the customer db. You can't enter new customers straight from the form, but instead I have an 'add new customer' button that runs a script. The script includes the custom dialog box that inputs the first and second names into the customer db, thus making it possible to find those names on the dropdown. 

      The stupid thing is that the user has to type in the names once again after the dialog box has closed. I want to find some way of pre-populating the name fields on the active form with the data that was just inputted via the custom dialog box. I've tried the Set field function and Copy and Paste too, but I just get error messages saying that the target record is not related or that it can't be modified because it's already being modified in another window (which it isn't, as far as I can tell.) 


      Anyone got any ideas? 




        • 1. Re: Pre-populate fields after custom dialog box

          I see two issues, the nuts and bolts of what you are trying to do and whether you should be copying names into these fields in the first place.


          Nuts and Bolts:

          Set field should do the job. If you are getting an error message that the field is not related, you'll need to look at your relationships and your layout design to figure out why this is the case. Copy and paste is not a method I recommend for this process. Copy and Paste have limitations that can cause problems in the future that set field, and set variable steps can avoid for you.


          Should you try to do this?

          Instead of entering names, enter an ID number from the customer table. If you establish a relationship linking the two tables by this ID number, you can simply add the related name fields to your layout and you'll see the names from the matching record in your cutomer DB appear.


          You do this by:

          Get the ID number for a given name from your customer table--this should be defined as an auto-entered serial number in the customer table.

          Enter this ID number into a new record in your related table.


          The above steps can be done with a drop down list or with a script.

          • 2. Re: Pre-populate fields after custom dialog box

            Thanks for your reply, Phil. I see where you're coming from, but the idea of getting the customerID from the customer table doesn't work so well for me because I'm trying to make the process as streamlined as possible. That means that I want the customer table to be populated exclusively from the main form (lets call it the invoice form). The customer table itself is meant to be a backend for bringing up address matches. The end-user shouldn't access it directly via any layout. Therefore there can't be a relationship between the invoice record being made and the new customer, because the customer record itself doesn't exist yet. 


            The reason I want all customers to be chosen from the value lists is to avoid duplicates in the customer table.  


            I guess one possible solution is in the form of the following script:


            ---> Go to layout [customers] ---> New record ---> Copy CustomerID (serial) ---> Go to layout [invoice] ---> Paste into 'invisible' CustomerID field (thus establishing relationship) ---> Go to layout [customers] ---> Custom dialog with first and second name inputs ---> Set first and second names fields using relationship established by CustomerID


            Is this a crazy convoluted way of getting where I want to be? All I really want to be able to do is make new records in a related table and then have those fields entered into the related table be pre-populated on the original form. Thanks for all your help :-) 




            • 3. Re: Pre-populate fields after custom dialog box

              I think you should think about your design. You say: "The end-user shouldn't access it directly via any layout." Yet the method you describe at the end of your last post accesses this table and modifies it exactly as though the user had typed the information directly into this table. Thus, why not place these fields directly on the layout? You can place fields on a layout, but still retain control over whether a user may modify the contents of those fields or not.


              In either case, I strongly recommend that you not use the script steps Copy and Paste in this fashion. There are better ways to do this by passing the information as a parameter or by storing the information in global fields or variables and then using the set field step.


              Problems with copy/paste:


              If the referenced field is not present on the current layout, these steps fail silently--no error message pops up and the script continues to execute, but the copy or paste action doesn't happen.

              If the user has copied information to the clipboard, a copy step will replace that data with the data your script copies and this will annoy and confuse your users.