Newbies rabbittb Posted February 25, 2002 Newbies Posted February 25, 2002 I have a file with two portals in a layout. One of the portals displays hardware and pricing information and the other portal displays line items. I want to be able to select an item from the hardware portal and click a button to add it to the line items portal. Due to FMPro not handling portals very well I can't specify which portal I want to add the data to. How can I script the button to perform the operation? I'm using FMPro 5.5.
SteveB Posted February 25, 2002 Posted February 25, 2002 If necessary, you can put a field that is unique to the portal you want to go to, and then execute a GoToField script step. If there already is a unique field, just execute the GoToField. You can make tis field 1 pixel wide and 1 pix high so it can't be seen.
andygaunt Posted February 25, 2002 Posted February 25, 2002 As you did not state in your post I assume that the two portals are related db's to the one with the portal. I did this based on three files. 1 for hardware, 1 for lineitems, 1 for displaying portals. But it could work with just one or two files as well. first, the file that is displaying the portals and the line items must have a constant field (eg Pipe, Text field, Auto Enter 1) As does the hardware file. These have a relationship. Pipe to Pipe. The file displaying the portal has a global to hold the id of the hardware. (hold hardware, global text) Then the script Set Field (hold hardware, "hardware::hardware id) Go To Field (Line items::hardware id) Loop Exit Loop (If IsEmpty(line items::hardware id) Go To Portal Row (Next) End Loop Set Field (line items::hardware id, hold hardware) The button is on each line of the hardware portal. When you click the button it sets the global field to the hardware id. Then go to the first portal row of the line items, and loop through until it finds the first empty line. Then set that portal row line to the hardware id. I had a lookup for the hardware name in the line items to the hardware based on hardware id. Does this help at all. Let me know if you need more help
Newbies rabbittb Posted February 25, 2002 Author Newbies Posted February 25, 2002 Andy, I tried you suggestion but was unable to get it to work. The script seemed to enter an infinite loop if I tried to enter a second record. I have a feeling that FM is confused about which portal I am trying to access. Basically all I am trying to do is add a new record to a related db via a portal. I like the concept of lookups but I only want to have one button in the main db if possible. Here is the script I'm using. It's an adaptation of yours so maybe the infinite loop is my fault. Thanks for your help. Go to Field["LineItems Rel::numHardwareId"] Loop Exit Loop If["IsEmpty(LineItems Rel::numHardwareId)"] Go to Portal Row [next] End Loop Set Field["LineItems Rel::numHardwareId", "searchRel::numHardwareId"]
andygaunt Posted February 25, 2002 Posted February 25, 2002 Hi rabbitt, have posted my files on the web. download here. http://www.albion.co.uk/fmpro/2portals.zip I used three files. The two portals are both in related db's Will look at code again for yours. Try these anyway.
Newbies rabbittb Posted February 25, 2002 Author Newbies Posted February 25, 2002 Andy, Thanks for the files. They helped me understand where you are coming from. However, I would like to have only one button that says "Add Selection" if possible. I adapted my database using your suggestions but I'm still getting stuck in an infinite loop when trying to add a second record to line items. It appears that the script is trying to loop in the hardware portal and not the line items portal which obviously isn't what I want it to do. Thanks for your help.
andygaunt Posted February 25, 2002 Posted February 25, 2002 If you get stuck, email the files and I will look at from here.
Fitch Posted February 26, 2002 Posted February 26, 2002 I'd suggest you pop that data into a global field before you run your loop. So the first line of that script would be... Set Field["globalGuy", "searchRel::numHardwareId"] And replace your last line with... Set Field["LineItems Rel::numHardwareId", "globalGuy"]
andygaunt Posted February 26, 2002 Posted February 26, 2002 Fitch, I am now following your POLR. See earlier post for proof.
Newbies rabbittb Posted February 26, 2002 Author Newbies Posted February 26, 2002 With Andy's help the db is now working as I desired. Thanks.
Recommended Posts
This topic is 8307 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now