Jump to content
Server Maintenance This Week. ×

combining 2 scripts to use with FileMaker


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

Recommended Posts

Hello,

OK....I have two scripts I am trying to now combine into one.

One script is a folder action that when a PDF File is dropped into it, that it sends and email message to a group of addresses and lets them know the name of the PDF file that was just put in the folder.

The other script is for a filemaker pro database that opens a file (in this case a pdf) in photoshop (once it is dropped on its script application icon), and adds it as a new record to to my open database after it changes its file size and copy and pastes it into the database picture field.

So, here is my thought..... I would love a folder action that when a file is dropped into that folder, that it does what the second script does, makes the smaller version and copies and pastes it into the databases picture field after it creates a new record, leaving the high res PDF untouched and then have the email alert happen once it is in the database to let them know to look at it for review.

Trying to combine these two steps.....see the two datbases below to see how they are are writtien now as they are working independently.

email script:

on adding folder items to this_folder after receiving these_items

repeat with i in these_items

set fileName to name of (info for i)

tell application "Mail"

tell (make new outgoing message with properties ¬

{to recipient:"[email protected], [email protected] ", subject:fileName, content:fileName & " has been added to folder " & this_folder as text})

send

end tell

end tell

end repeat

end adding folder items to

filemaker and photoshop script:

on open theFiles

beep

if class of theFiles is not list then

set theFiles to theFiles as list

end if

tell application "Adobe Photoshop CS3"

set display dialogs to never

close every document saving no

end tell

repeat with thisFile in theFiles

tell application "Finder"

set filePath to thisFile as alias

set fileName to name of thisFile

set dateMod to modification date of thisFile

end tell

--I added this line below to capture the modification date

set daMonth to (month of dateMod as integer) as string

set daDay to day of dateMod as string

set daYear to year of dateMod as string

set dateMod to daMonth & "/" & daDay & "/" & daYear

tell application "FileMaker Pro Advanced"

tell database "PDF Approval"

set newRecordID to create new record at the end

go to the last record

end tell

end tell

tell application "Adobe Photoshop CS3"

activate

open filePath

tell document 1

set docHeight to height

set docWidth to width

set docName to name

if (mode is not RGB) then

change mode to RGB

end if

resize image width 400.0 as pixels

flatten

select all

copy

close saving no

end tell

end tell

tell application "FileMaker Pro Advanced"

activate

tell database "PDF approval"

tell current record

--go to field "picture" --of the current record

go to cell "picture"

paste

end tell

tell database 1

tell window 1

set tableName to name of current table

set recID to ID of current record

end tell

do script FileMaker script "Commit Record"

tell table tableName

tell record ID recID

set cell "name" to fileName

--I added this line below to put the modification date into FMP

set cell "dateModified" to dateMod

--end tell

end tell

end tell

end tell

end tell

end tell

end repeat

end open

any thoughts on how to combine this would be great!!!

thanks

barbara

Link to comment
Share on other sites

you can call one script from another.

If(blah)

go to layout(Layout)

else

Perform Script(Script)

EndIf

go to Layout(Layout)

Set Field(Fieldname)

Commit Records

Blah

Blah

Blah

So if both your scripts are working just call one from the other. In some cases it's preferable to call scripts rather then have one large script where it's difficult to follow the logic.

hth

Link to comment
Share on other sites

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