8 Replies Latest reply on May 26, 2017 2:48 AM by npgdan

    Calculated AppleScript Sending Data to and from

    npgdan

      Hello,

       

      I am trying to make a calculated AppleScript to be able to push data to calendar. I have this working in native AppleScript, however I would like to clean it up and not to have to use scripting to sort which version of filmmaker and database name.

       

      I came across a method to use a set variable statement to create the AppleScript using List function. I set the variables for the calendar prior to this set variable,

       

      I keep getting a expected end of line but """. error not sure how to rectify this. Can anyone assist? Is there a easier way to do calculated AppleScript to push and retrieve data back to my database?

       

      Mine looks like this:

       

      set variable [$CalPush; Value:

      List (

      "set sd to " & Quote ($SchDate);

      "set ed to " & Quote ($EndDate);

      "set theDescription to " & Quote ($TskDescription);

      "set StartTime to " & Quote ($StartTime);

      "set EndTime to " & Quote ($EndTime);

      "set theSummary to " & Quote ($Summary);

      "set CalendarName to " & Quote ($Vendor);

      "set sdd to date sd";

      "set edd to date ed";

      "tell application " & Quote ("Calendar");

      "launch";

      "tell calendar CalendarName";

      "set theEvent to make new event with properties {summary:theDescription, start date:sdd, end date:edd, description:theSummary}";

      "show theEvent";

      "set myUUID to the uid of theEvent";

      "reload calendars";

      "end tell";

      "end tell";

      "tell application " & Quote ($FMPVer);

      "tell database " & Quote ($FileName);

      "set cell " & Quote ( Task Events::TaskCurUUID ) & " of current record to myUUID";

      "end tell";

      "end tell";

      )

      ]

      perform AppleScript [$CalPush]

        • 1. Re: Calculated AppleScript Sending Data to and from
          jormond

          You will likely get more help if you move this thread to the Discussions space. This space ( Community Feedback ) is specifically for issues regarding this website. I know it's not obvious. But few people browse this area.

          1 of 1 people found this helpful
          • 2. Re: Calculated AppleScript Sending Data to and from
            Malcolm

            When you are running AppleScript within FileMaker the script behaves as if you wrote

             

             

            tell application "FileMaker Pro"

            -- script steps

            end tell

             

            That makes things easy for you. You don't need the tell application FMPVer block, because it's already implicit.

             

            When you set the cell, you need the field name. Use Quote ( GetFieldName( task events::taskCurUUID ) ). That will give you "table::field". You may need to strip the table name. In addition, you probably also want to use  the table name to say something like "set cell X of table Y of current record.

             

            malcolm

            1 of 1 people found this helpful
            • 4. Re: Calculated AppleScript Sending Data to and from
              npgdan

              Malcolm,

               

              Thank you for the post. The command;

               

              "Tell application " & Quote ($FMPVer);

               

              is for other users that do not have FIlemaker Pro.

               

              Adding quotes around the table occurance fixed my issue. I feel like a chef, every problem gives me a new recipe for filemaker.

               

              Thank you...

               

              set variable [$CalPush; Value:

              List (

              "set sd to " & Quote ($SchDate);

              "set ed to " & Quote ($EndDate);

              "set theDescription to " & Quote ($TskDescription);

              "set StartTime to " & Quote ($StartTime);

              "set EndTime to " & Quote ($EndTime);

              "set theSummary to " & Quote ($Summary);

              "set CalendarName to " & Quote ($Vendor);

              "set sdd to date sd";

              "set edd to date ed";

              "tell application " & Quote ("Calendar");

              "launch";

              "tell calendar CalendarName";

              "set theEvent to make new event with properties {summary:theDescription, start date:sdd, end date:edd, description:theSummary}";

              "show theEvent";

              "set myUUID to the uid of theEvent";

              "reload calendars";

              "end tell";

              "end tell";

              "tell application " & Quote ($FMPVer);

              "tell database " & Quote ($FileName);

              "set cell " & Quote ( "Task Events::TaskCurUUID" ) & " of current record to myUUID";

              "end tell";

              "end tell";

              )

              ]

              1 of 1 people found this helpful
              • 5. Re: Calculated AppleScript Sending Data to and from
                ch0c0halic

                Do not under any circumstances use - Tell Application "FileMaker Pro" in an AppleScript running inside of FMP.

                 

                FMP knows when it's talking to itself so it is unnecessary to include the Tell FMP command.

                 

                And that is why you are having problems. When you change versions of FMP the AppleScript that was compiled using the older version will not know it should be addressing the current version.

                 

                By NOT putting it in the AppleScript is non-version specific.

                 

                When debugging the AppleScript in the AppleScript Editor you add in the Tell FMP command. BUT, remove it when you put it into the FMP "Perform AppleScript" script step.

                2 of 2 people found this helpful
                • 6. Re: Calculated AppleScript Sending Data to and from
                  npgdan

                  I am not sure why you would be so against the statement, in a previous script step I set the variable to correct version of filemaker running. Plus what happens if I have two versions of filemaker running at the same time?

                   

                  Is there something bad that can happen? because my script works as is, I want to make sure that I do not break something though.

                  • 7. Re: Calculated AppleScript Sending Data to and from
                    ch0c0halic

                    It adds unnecessary complexity. Most likely the way you set the variable will be good for the foreseeable future but there are no guarantees that the way you've derived the Application version will always work. Also the version you get may not be the version FMP uses for the AppleScript reference.

                     

                    Since you've derived the FMP Application version the AppleScript can't compile completely. All internal Application references have to be looked up from the App Library, which makes the AppleScript takes longer and possibly could use the wrong application Library if you have more than one version of FMP installed.

                     

                    Why even worry about which version of FMP you are running the AppleScript on? FMP already knows which version it is and doesn't need to be told.

                    2 of 2 people found this helpful
                    • 8. Re: Calculated AppleScript Sending Data to and from
                      npgdan

                      Thank you for the indepth explanation.  what you have explained makes sense.

                       

                      I originally ran the applescript as a naitive scriot and and I was following templates on the AppleScript forums. Now knowing the FileMaker will always know it's own version and makes this unnecessary is extremely helpful.

                       

                      thank you again community.