Get dataset info into variables of applescript

Post Reply
verstraete
Newbie
Posts: 8
Joined: Thu Oct 03, 2013 2:01 pm

Get dataset info into variables of applescript

Post by verstraete »

Hello,



I have a script that I want to use in switch.

When I start a submit point, I will give two variables.

How do I get the two variables from a dataset into my applescript.



Script.





tell application "Safari"

open location "http://62.206.22.39/Homann/getpdf.php?jobid=000" & jobNr & "&fn=9-Datenversand%5C" & matNr & ".zip"

end tell





tell application "Finder"

repeat

set folderName to get name of folders of folder ("/Users/DavidVV/Downloads/" as POSIX file)

if folderName contains matNr then exit repeat

end repeat

move folder ("Macintosh HD:Users:DavidVV:Downloads:" & matNr & "") to folder ("Macintosh HD:Volumes:Data-VAO:6. Home folders:DavidV:DavidV:03_Switch:Test folders:Homann:Incoming") with replacing

delete folder ("Macintosh HD:Users:DavidVV:Downloads:" & matNr & "")

end tell



Greetz.
freddyp
Advanced member
Posts: 1028
Joined: Thu Feb 09, 2012 3:53 pm

Get dataset info into variables of applescript

Post by freddyp »

In Switch Scripter you can also create scripts that use Applescript. Yours would look something like this:



on jobarrived( s, j )



set Current_Switch_Server to system attribute "Current_Switch_Server"

tell application Current_Switch_Server

using terms from application "Switch_Service"



set jobNr to evaluate variable as string of j variable "[Metadata.Text ...]"

set matNr to evaluate variable as string of j variable "[Metadata.Text ...]"

set tempFile to create path of j name jobNr & "_" & matNr & ".zip"

set downloadURL to "http://62.206.22.39/Homann/getpdf.php?jobid=000" & jobNr & "&fn=9-Datenversand%5C" & matNr & ".zip"

log level -1 message downloadURL

download source downloadURL destination tempFile

send to single j path tempFile



end using terms from

end tell



end jobarrived



This is not tested of course as I do not have a valid job number and material number. You will also have to fill in the correct definition for the metadata variable (copy&paste from the variables pane). As you can see the download can be performed by Switch directly. You do not necessarily have to pass through Safari.



You should also add some error handling.



Freddy
Post Reply