MBS Xojo Conference
6/7th September 2018, Munich

« FileMaker Magazin - M… | Home | Image Gallery in File… »

Store your ID in URLs in Mac address book


As you may know, we can query address book in our plugins. Now you can store your own IDs for users in the contacts database by using an extra URL.

The key today is that we use an URL in the addressbook and make it a FMP URL, so the user can actually click on the URL and go to the FileMaker database right away. When synchronizing the IDs between database, we can store our own ID this way. To search, we use Addressbook.searchElementForProperty function to search for our label in URLs property and compare to the ID.

To store the value, we use the following script: 

Set Variable [ $PersonID ; Value: MBS( "Addressbook.Me") ] 

Set Variable [ $myID ; Value: "FMP://~/Clients?script=ShowContact&param=123456" ] 

Set Variable [ $MyLabel ; Value: "FileMakerID" ] 

# Query current URLs

Set Variable [ $r ; Value: MBS( "Addressbook.record.valueForProperty"; $PersonID; "URLsProperty" ) ] 

Set Variable [ $Count ; Value: MBS( "Addressbook.multivalue.count" ) ] 

Set Variable [ $index ; Value: 0 ] 

Set Variable [ $foundIndex ; Value: -1 ] 

Loop

Set Variable [ $label ; Value: MBS( "Addressbook.multivalue.labelAtIndex"; $index ) ] 

If [ $label = $MyLabel ] 

Set Variable [ $foundIndex ; Value: $index ] 

Exit Loop If [ 1 ] 

End If

# next

Set Variable [ $index ; Value: $index + 1 ] 

Exit Loop If [ $index >= $count ] 

End Loop

If [ $foundIndex >= 0 ] 

# found, so update

Set Variable [ $r ; Value: MBS( "Addressbook.multivalue.replaceValueAtIndex"; $foundIndex; $myID ) ] 

Else

# not found, so add

Set Variable [ $r ; Value: MBS( "Addressbook.multivalue.addValue"; $myID; $MyLabel ) ] 

End If

Set Variable [ $r ; Value: MBS( "Addressbook.record.SetValueForProperty"; $PersonID; "URLsProperty"; "multi" ) ] 

# save...

Set Variable [ $r ; Value: MBS( "Addressbook.save" ) ] 

And to read back the value, we can use a script like this: 

Set Variable [ $PersonID ; Value: MBS( "Addressbook.Me") ] 

Set Variable [ $MyLabel ; Value: "FileMakerID" ] 

# Query current URLs

Set Variable [ $r ; Value: MBS( "Addressbook.record.valueForProperty"; $PersonID; "URLsProperty" ) ] 

Set Variable [ $MyID ; Value: MBS( "Addressbook.multivalue.valueForLabel"; $myLabel ) ] 

Show Custom Dialog [ "MyID" ; $MyID ] 

 
Let me know if you have questions. Same can of course be done with our Xojo plugins. 

08 05 18 - 14:06
No comments

  
Remember personal info?

Emoticons / Textile


Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.