AnsweredAssumed Answered

Script to grab and display a photo - needing assistance

Question asked by thilleary on Mar 7, 2018
Latest reply on Mar 8, 2018 by philmodjunk

Looking for assistance on populating a FMP16 layout showing a contact database, with a photo of the particular person. There are hundreds of records in the database. I am attempting to adapt the following sample code for this script that is purported to put the picture up on the dashboard and create an error log for pictures it cannot find. It'd be great if I could get it to work.

 

Go To Record/Request [first]

Loop

  Set Variable [ $path ; Get(DocumentPath) & "/products/" & products::productCode & ".jpg" ]

  Insert Picture [ products::image ; $path ]

   if [ get(lasterror) <> 0 ]

Set Variable [ $log ; List ( $log ; products::productCode & ".jpg is missing from folder" ) ]

End If

  Go To Record/Request [next ; exit after last ]

End Loop

 

Set Field [ products::log ; $log ]

Set Variable [ $logpath ; Get(DesktopPath) & "log.txt" ]

Export Field Contents [ products::log ; $logpath ]

 

I am sure the problem I am having with this script is setting up the path variable.

 

The path to the folder that contains the photo files is called "Photos" and it is at:

MacintoshHD/Users/tom/Documents/OneDrive/SMN2018/MasterData/Photos

 

In may main table I calculate the file name, which is comprised of the first and last names of the contacts (for example, the photo for John Doe is the file "Doe_John_.68.jpg" which is located in the /Photos/ subfolder).

 

I just need to work out how the phot is accessed and displayed on the layout.

 

Anyone have good advice on this?

 

Much appreciated.

/T Hilleary

Outcomes