Jump to content

More than one portal


rabbittb

This topic is 8067 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Newbies

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"]

Link to comment
Share on other sites

  • Newbies

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.

Link to comment
Share on other sites

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"]

Link to comment
Share on other sites

This topic is 8067 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.