Page 1 of 1

Event detail an contact

PostPosted: Fri Apr 02, 2010 12:45 am
by medjemni
Hi John,
In Event Detail Layout, in want to be able to see a list of all my contact. Then to select a contact to book an event with the selected date.
You have an idea?

PostPosted: Fri Apr 02, 2010 6:07 am
by John Sindelar
Sure. You can create a portal on this layout (you may want to make the layout a little bigger first) showing all your contacts.

Showing All Contacts

To do this, create a new table occurrence of your contacts table on the graph and call it "SampleEvents_AllContacts". Then relate this to Sample Events by linking the EventID with the ID in your Contacts table using the "x" operator: this kind of relationship shows all records.

Now format your portal as you see fit and add a "select" button in the portal row. This button will link the current event to the contact you click on. Have this button set the event's contact ID key (the field _id_contact in our sample data) to the following calc where _id is the unique ID in your contacts field:

Code: Select all
If (
   SampleEvents::_id_contact = SampleEvents_AllContacts::_id ;
       "" ;
    SampleEvents_AllContacts::_id
)


That if statement de-selects the contact if they are already linked to that event.

Going Further: Conditional Formatting

You can add conditional formatting to the portal to highlight the selected contact. Since only text-like objects can be conditionally formatted, it helps if the button you created above to select the contact was made using the button tool and that fills the whole portal row behind the contacts name. Once it does, add conditional formatting to turn it blue when...

Code: Select all
// Contact is selected

SampleEvents::_id_contact = SampleEvents_AllContacts::_id


Add the same conditional formatting calc to the contacts' name in the portal, turning the text white when the contact is selected.

Going Further: Type-ahead Portal Filtering

If you're using FileMaker 11 you can also easily add a type-ahead to this portal so that as you type in the first few letters of the contact's last name, the portal shows just the contacts who match what you're typing.

Begin by creating the field you'll type into: create a global text field in SampleEvents called z_ContactTypeAheadGlob. Make this a text field and set it's options to Global storage. Place this at the top of your portal as shown below.

Now double click on your portal of all contacts and check "Filter portal records". Click "Specify" and add this as the filter criteria:

Code: Select all
Let ( [
n = Length ( SampleEvents::z_ContactTypeAheadGlob )
] ;

Left ( SampleEvents_AllContacts::NameFull ; n ) = SampleEvents::z_ContactTypeAheadGlob

)


Now filtered portals don't refresh on their own, so we'll need to add a script trigger to refresh this as you type. Create a new script called "Contact Type Ahead" with the following steps:

Commit Records/Requests []
Refresh Window [Flush cached join results]
Go to Field [SampleEvents::z_ContactTypeAheadGlob]

Now enter layout mode and assign a script trigger to the "z_ContactTypeAheadGlob" on your layout, right click on the field and select "Set Script Triggers". Add an "OnObjectModify" trigger, and call your "Contact Type Ahead" script.

That's it! Our version looks like this:

Image

Hope that helps,

John

PostPosted: Fri Apr 02, 2010 10:05 am
by medjemni
Hi john,
thanks for your help.
Can you just explain how to create the "select" button in the portal row.
Can you just send me your layout (my email: [email protected])

PostPosted: Fri Apr 02, 2010 10:13 am
by John Sindelar
medjemni wrote:Hi john,
thanks for your help.
Can you just explain how to create the "select" button in the portal row.


Sure. Use the button tool to draw a button the same size as the first portal row (not including the scroll bar). Make the button white with no borders and make its button action the SetField step I mentioned above. Then send it backward behind the contact's name.

If you don't know how to do this stuff, emailing the layout doesn't really help since the layout pastes in with new stuff like this broken and you have to go in and fix it.

Email me directly if you get stuck and we'll figure something out (john at seedcode.com)

PostPosted: Mon Apr 12, 2010 3:17 pm
by martin baarda
Hi john using the new calendar in the complete version.
I have a question about this topic: in calender I would like to use the Mini Window Edit Appointment lay-out is that possible instead of Event Details

greetings Martin

PostPosted: Mon Apr 12, 2010 7:14 pm
by John Sindelar
It is, just switch it so that it is based on SampleEvents (or whatever you've renamed that to): ideally it already is as you made CalDailyAppointments your "SampleEvents" table occurrence. Then make any adjustments you need to so the scripts on that layout work in the new context.

Get This when I try to select from the list

PostPosted: Sun Dec 12, 2010 5:25 pm
by ramac10
This button requires that a field be active. Press Tab or click in a field to make a field active.

MAC OS
FM 11 Pro