AnsweredAssumed Answered

Scripts: Create PDF then Insert into Container; for Local & Remote users

Question asked by dew119 on Oct 20, 2014
Latest reply on Oct 26, 2014 by user19752

Needing your help. After 3 days, I'm pretty frazzled after trying so many variables with no success.

 

QUESTIONS (as I understand it):

1. How to get the remote computer to save PDF to the host's "Files" folder (so it can find it during the Insert" step)?

2. How can I calc/edit the relarted/full paths so the script works for MAC users too?

ISSUE: I do not have user's host/server info so I ned to be able to use "GET" functions to build a path variables. I saw Get(HostName), Get(HostIPAddress) and Get(FilePath) but so far have been unable to create a workable calc with those..

3. How to modify paths for MAC usrs? differtn format/syntax?

 

GOAL: When user clicks a "Create PDF" button, a script creates the PDF, then Inserts a link to the PDF in a Container field (External, Open storage).

 

Scenario:: I need this script to work with single/local and multi-user/remote "ConnectionStates". My multi-file solution is used sometimes by Single-users (with Local path) and sometimes by small groups who network/logon remotely (some small groups use FMPro12-13; others use FMs12-13).

 

The script below works for Local (single-user). But, when the file is hosted and the user logs on remotely, the PDF gets saved to the workstation's FMA12 folder. Then, the workstation can't find the file during the "Insert" step, because it goes looking it in the host's "Files" folder.

 

Hoping you can help to clear my fog ... ;-)

 

Diane

 

SCRIPT: Create PDF, then Insert doc into Container (external, open storage)

  • Allow User Abort [ On ]
  • Set Error Capture [ On ]

 

  • #

 

  • Go to Layout [ “PDU Certificates to Educators” (Placements) ]
  • #
  • # 1 ---------------- Variable: FileName -------------------

 

  • Set Variable [ $filename; Value: If( not IsEmpty( GetRepetition( Placements::vEducID ; 1) ) ; // THIS HIDDEN 10-20-2014 and IsValid ( GetRepetition( Placements::vEducID ; 1 )) Year ( Placements::PL_EndDate ) & "-" & Case( Month ( Placements::PL_EndDate ) = "1" ; "01" ; Month ( Placements::PL_EndDate ) = "2" ; "02" ; Month ( Placements::PL_EndDate ) = "3" ; "03" ; Month ( Placements::PL_EndDate ) = "4" ; "04" ; Month ( Placements::PL_EndDate ) = "5" ; "05" ; Month ( Placements::PL_EndDate ) = "6" ; "06" ; Month ( Placements::PL_EndDate ) = "7" ; "07" ; Month ( Placements::PL_EndDate ) = "8" ; "08" ; Month ( Placements::PL_EndDate ) = "9" ; "09" ; Month ( Placements::PL_EndDate ) = "10" ; "10" ; Month ( Placements::PL_EndDate ) = "11" ; "11" ; Month ( Placements::PL_EndDate ) = "12" ; "12" ) & "-" & Case( Day ( Placements::PL_EndDate ) = "1" ; "01" ; Day ( Placements::PL_EndDate ) = "2" ; "02" ; Day ( Placements::PL_EndDate ) = "3" ; "03" ; Day ( Placements::PL_EndDate ) = "4" ; "04" ; Day ( Placements::PL_EndDate ) = "5" ; "05" ; Day ( Placements::PL_EndDate ) = "6" ; "06" ; Day ( Placements::PL_EndDate ) = "7" ; "07" ; Day ( Placements::PL_EndDate ) = "8" ; "08" ; Day ( Placements::PL_EndDate ) = "9" ; "09" ; Day ( Placements::PL_EndDate ) ) & "_PDUs" & "_" & GetRepetition( Placements::PDU_Earned ; 1) & If( GetRepetition( Placements::PDU_Earned ; 1) < 2 ; "Unit_EDUC " ; "Units_EDUC " ) & GetRepetition( Placements::EducLName_LkUp ; 1) & "_" & TrimAll ( Placements::CenName_LkUp ; 3; 3 ) & "_STU " & LeftWords ( Placements::StuLNameF_LkUp; 1 ) & ".pdf" ; "" ) ]
  • #
  • # 2 ---------------- Variable: FilePath -------------------

 

  • If [ Get ( ConnectionState ) < 1 // LOCAL, Single User ]

 

  • Set Variable [ $filepath; Value:"file:Files/Placements/$filename" ]

 

  • Else If [ Get ( ConnectionState ) > 0 // NETWORK, Remote User ]
  • Set Variable [ $filepath; Value:Get(FilePath) ]

 

  • End If
  • #
  • # 3 --------------- Variable: FilePathName -------------------

 

  • If [ Get ( ConnectionState ) < 1 // LOCAL, Single User ]
  • Set Variable [ $filepathname; Value:"file:Files/Placements/$filename" ]
  • Else If [ Get ( ConnectionState ) > 0 // NETWORK, Remote User ]

 

  • Set Variable [ $filepathname; Value:Substitute ( Get(FilePath); ".fmp12" ; "" ) & "/" & $filename ]

 

  • End If

 

 

 

  • #
  • # 4 --------------- SAVE RECORD AS PDF ..........................1 page ... [Restore; No dialog; FileName: (Variable) "$filename"; Current record]
  • If [ Get ( ConnectionState ) < 1 // LOCAL, Single User ]
  • #--------------- 10/20 9:43AM Step below worked LOCALLY ... but remote/networked user could not locate file for INSERT----------------------------------------
  • Save Records as PDF [ File Name: “file:Files/Placements/$filename”; Automatically open; Current record ] [ Document - Author: Placements::PDU_IssuedBy; Keywords: "PDU Certificate"; Compatibility: Acrobat 5 and later ] [ Pages - Number Pages From: 1; Include: Specific Pages; Start Page: 1; End Page: 1 ] [ Security - Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ] [ Initial View - Show: Page Only; Page Layout: Single Page; Magnification: 75% ] [ Restore; No dialog ]
  • Else If [ Get ( ConnectionState ) > 0 // NETWORK, Remote User ]
  • #--------------- 10/20 3:23PM Step below - REMOTE crated PDF and saved it to it's lovcal FMA12 folder ... Then, REMOTE unable to locate file for next INSERT step -----------------------

 

 

  • Save Records as PDF [ File Name: “$filename”; Automatically open; Current record ] [ Document - Author: Placements::PDU_IssuedBy; Keywords: "PDU Certificate"; Compatibility: Acrobat 5 and later ] [ Pages - Number Pages From: 1; Include: Specific Pages; Start Page: 1; End Page: 1 ] [ Security - Printing: High Resolution; Editing: Any except extracting pages; Enable copying; Enable Screen Reader ] [ Initial View - Show: Page Only; Page Layout: Single Page; Magnification: 75% ] [ Restore ]
  • End If
  • #
  • Go to Layout [ original layout ]
  • #
  • #
  • # 5 ------------------ INSERT new PDF into PlaceCNTR_PDUs ------------
  • #INSERT FILE: Store Reference ONLY (External storage): PATH: file:Files/Placements/$filename
  • If [ Get ( ConnectionState ) < 1 // LOCAL, Single User ]
  • Insert File [ Placements::PlaceCNTR_PDUCertificates; “file:Files/Placements/$filename” ]
  • #
  • Else If [ Get ( ConnectionState ) > 0 // NETWORK, Remote User ]

 

 

  • Insert File [ Placements::PlaceCNTR_PDUCertificates; “file://Files/Placements/$filename” OR “$filepathname” OR “file://$filepathname” OR “$filename” OR “file://$filepathname” ]
  • End If
  • #
  • Commit record.
  • -----------

END

Outcomes