Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Hi All,

I have a portalk with 3 fields, I want to know from the main page ...i have 3 buttons, I want each button to sort each field in portal as I want. Is there a way to do so since the relationship from portal and main page is sorted already, i can not change anything?

Any help

Thanks

Version: Developer v6

Platform: Windows 95/98

Posted

The key is to use the GetField calculation.

Here's my "cheatsheet" for doing this (bare minimum explanations, ask questions!). I also have ascending and descending sorts. There are many example files of this if you want to see it hands on.

File with Portal:

Relationship:

Sort Related Records by:

c.Sort.Ascending (set to Ascending order) followed by:

c.Sort.Descending (set to Descending order)

File Related To (can be same file):

g.Sort.ByWhat? global number set by button scripts to match field order below

c.Sort.ByWhat? calculation text returning field to sort by using GetField

g.Sort.Order.Ascending? global number as checkbox with value list 0 & 1

c.Sort.Ascending text, will contain contents of c.Sort.ByWhat? or nothing

c.Sort.Descending text, will contain nothing or contents of c.Sort.ByWhat?

c.Sort.ByWhat?

------------------------------------------------------

GetField(

Choose( g.Sort.ByWhat?,

"FieldName.1.To.SortBy", >> name of field to sort by for g.Sort.ByWhat? = 1

"FieldName.2.To.SortBy", >> name of field to sort by for g.Sort.ByWhat? = 2

"FieldName.2.To.SortBy", >> name of field to sort by for g.Sort.ByWhat? = 3

...,

"FieldName.n.To.SortBy" >> name of field to sort by for g.Sort.ByWhat? = n

)

)

------------------------------------------------------

c.Sort.Ascending

------------------------------------------------------

Case( g.Sort.Order.Ascending?, c.Sort.ByWhat?)

------------------------------------------------------

c.Sort.Descending

------------------------------------------------------

Case( not g.Sort.Order.Ascending?, c.Sort.ByWhat?)

------------------------------------------------------

Posted

Attached is a bare-bones example, based largely on what CobaltSky wrote (see below). One downside of this method is that clicking a radio button does not force a re-sort. This method also has a good example of using the ValueListItems function.

ColbaltSky's great article about "Dynamic Portal Sorting in FileMaker Pro" is on his web site:

http://www.nightwing.com.au/FileMaker/resources.html

Version: v7.x

Platform: Mac OS X Panther

PortalSort.zip

Posted

> I need to have the portal records sort by the location of the current main record they appear in. Would this work?

I'm not sure I'm understanding this, so here's a stab: you want the portal's sorting to be based on a field in the record the portal is displayed on. This is doable, the hard part is determining how to define a relationship between the portal's sorting calculations and the main record. If the portal has a field that uniquely relates to a main file record, that's easy. if not, it may be easier to script

Did I answer what you were asking?

Posted

yes, that is what I am asking and you answered it. What I have is a File with our Retailers then a related file with Retailers contacts. Each Retailer has a number that corresponds with the contacts file. The problem is that we might have 3 different locations and we need to have the contacts sorted depending on location.

I have tried to relate the files differently so that the portal shows only the contacts from each location. (I have done this by creating a field in each file that combines the retailernumber with the city) this seemed to work as the contacts would show up in their correct retailer files, but when you try to add a contact you get a message that the relationship is invalid and must be correct. I'm not sure what the problem is now

Posted

The retailernumber -city field in Contacts is a calculation. Normally calculations are unstored, which means they cannot be indexed. The match field in the related file must be indexed, and the field isn't.

To fix this: Define Fields, open the field, and then click Storage Options... Uncheck Do not store calculation results. Click Indexing: Off amd check Automatically turn on indexing if needed.

Why didn't I click Indexing: On? If (when...) things change in the future and this field is no longer part of a relationship, therefore it does not need to be indexed, Indexing will be turned off, saving disk space & speed.

Posted

I thought that the indexing worked differently: when set to "index when needed" FMP will index the field if it is ever used in a Find, or if it is used in a relationship.

I don't think the indexing is ever turned off by FMP once it has been turned on. Working out when to turn it off would be tricky... especially in a multi-user environment.

Posted

I'm probably wrong about the indexing being turned off, it was a distant memory of something I read years ago. And if my memory serves me, my memory isn't as good as it was when I was a lad... wink.gif

Posted

I gave the indexing recommendation a try and it didn't work. I can get the previously created records to show in the portal, but I still can't add new records through the portal. I have checked my field and relationship options against another similar relationship, but I can't find the problem. Any other suggestions on things to check? Thanks

Posted

Hi,

From what I understood, you established a relationship from your main to the related file using a calculation in the Related file as the Match key.

These settings wouldn't let you create related records.

As your goal is to create new records through a filtered relationship, I'd suggest that you :

- use 2 globals for the parameters and a calculation 'cgCompound' = gRetailernumber&" "gCity as your Right key

- create a text field in the Contacts file, called 'TextLink'

- establish a relationship from 'cgCompound' to 'TextLink' with "Allow Creation of Related Records" checked.

- create an additional relationship, called 'ConstantRel' from the Contacts to the Retailers file (This constant would use a num field, called nConstant, with an auto-entered value of 1 in the 2 file).

Then, the RetailerNumber and City fields could be set to be lookup fields from a the 'ConstantRel', respectively targetting the gRetailerNumber and gCity.

I'd assume you'd have the Retailer's name come by another lookup later on.

As Sam said though, using a script would even be easier. You'd just pass the values to the related file using the constant relationship, with a script along the lines of.

Assuming you're still using global fields for the filter, if not change them to text/num fields.

In the Retailer's file.

SetField [gRetailerNumber, RetailerNumber]

SetField [gCity, City]

PerformExternalScript[Contacts-"NewRecordFromFiltered"]

Exit Record

where "NewRecordFromFiltered" in the Contacts file would just be

NewRecord/Request

SetField[RetailerNumber, Constant:gRetailerNumber]

SetField[City, Constant:gCity]

The Portal would still use your current Compound key RetailerNumber&" "&City as the Left Key, but you'd switch to the script when adding a record is required.

HTH

Version: v6.x

Platform: Mac OS 9

This topic is 7545 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.