imdarek

Applescript Error to create new record

5 posts in this topic

Hi, I am using filemaker 11 to copy customer info from excel into the database and then it would generate special keys in pdf allowing us to send the file to the customer.

My access to the filemaker is non-admin, and the import function of customer info has been blocked.

We are keying in the record one at a time, so we are looking at ways to automate this process.

When I try to create a new record using applescript with just 

Quote

Create new record

it was not allowed. There are data that require validation like date and auto-indexed record number.

So, is there a way we could create new record and then using the set function to copy data into the report?

Share this post


Link to post
Share on other sites
3 hours ago, imdarek said:

the import function of customer info has been blocked

What exactly does that mean? Do you have the privilege to create new records in the customers table?

 

3 hours ago, imdarek said:

it was not allowed.

It was not allowed because ...? Please show the exact error message.

 

3 hours ago, imdarek said:

There are data that require validation like date and auto-indexed record number.

I am afraid that's also too vague.

Share this post


Link to post
Share on other sites

Hi Imdarek and welcome to the FM Forums,

You posted this question in the FM Server 11, are these files being served?

On 2/17/2017 at 1:07 AM, imdarek said:

I am using filemaker 11 to copy customer info from excel into the database and then it would generate special keys in pdf allowing us to send the file to the customer.

My access to the filemaker is non-admin, and the import function of customer info has been blocked.

You should contact Admin to see if your Accounts and Privileges can be modified so you can do this.

Share this post


Link to post
Share on other sites

Hi,

I am using the script editor in Mac itself to create record.

When I create a new record, it shows this error : "Set Data failed.  Invalid data was supplied."

	tell application "FileMaker Pro"
		go to layout "Contract"
		go to (create new record)
	end tell

If I would want to create new record with all the pre-defined fields, leaving out those auto-indexed field and auto-calculated value, it shows "Set Data failed.  Invalid data was supplied."

on Create_Customer_Info(Cust_Info)
	tell application "FileMaker Pro"
		go to layout "Customer"
		tell current layout
				go to (create new record with data Cust_Info)
		end tell
	end tell
end Create_Customer_Info

However, when i create a script in Filemaker to create new record and commit record, I am able to set the field using Applescript however, the additional field that will automatically calculate the field based on the earlier set field does not appear.

Share this post


Link to post
Share on other sites

I have managed to reproduce the error by defining one of the fields to validate as Not Empty, Validate Always. The user privileges have nothing to do with this: I get the same error when logged in as admin.

Apparently, the create new record event attempts to commit the newly created record and fails due to validation. This is hardly surprising, considering that the entire AppleScript dictionary for Filemaker was created before version 7 introduced the concept of committing records - and no major changes were made since then.

I did manage to work around the problem by using the create new record with data event; however, this requires the fields you want to populate to be positioned above any other fields on the layout. I must say, I was quite surprised by this; I would expect it to populate the fields that are first in the tab order, or the fields that are furthest back on the Z axis. But apparently it just goes from top to bottom.

If you're not able to modify your layout to suit, perhaps you could circumvent the entire issue by using go to (duplicate last record) and then set cell "CustomerName" of current record to "John Smith" etc.

 

6 hours ago, imdarek said:

when i create a script in Filemaker to create new record and commit record, I am able to set the field using Applescript however, the additional field that will automatically calculate the field based on the earlier set field does not appear.

I am not sure what you mean by "the additional field that will automatically calculate the field based on the earlier set field".

I am also puzzled by this: if you can create a script in the target file, then why do you need AppleScript to automate the process? You started by saying that "the import function of customer info has been blocked" - but you still haven't explained how exactly. If you have the privilege to create new records, then you also have the privilege to import them. Perhaps you just don't have access to the menu command, due to custom menus being installed.

 

 

 

Edited by comment

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • By ggt667
      How can I get ESS access to PostgreSQL from FM11SA?
    • By Franco Pagano
      When i use a local robot to create pdf files or other, i have a problem when the connection go down, filemaker loose every reference to the remote file.
      The only way is to close the file and open again, i solved this problem on Mac using this apple script.
      1)  The AS check the connection if ok open the file.
      2)  If the connection go down then the AS close the file and wait until the connection is up, at that time it reopen the file.
      3) if you close the file then the applescript quit it self. 
      I am not a Apple script developer, i assembled it using few examples, then probably  isn't well done but it work.
      -------------------------------------------------
      tell application "Finder" to set ThePath to POSIX path of ((container of (path to me)) as alias)
      set VarRepeat to "Yes"
      tell application id "com.filemaker.client.advanced12"
          activate
          try
              set window_name to the name of every window whose visible is true
          on error
              set window_name to "Error"
          end try
      end tell
       
      ---------------------------------------------------
      repeat
          set testIP to chkUP("http://www.apple.com") or chkUP("http://www.google.com")
          ---------------------------------------------------
          if testIP as text = "False" and window_name contains "Robot" then
              tell application "System Events"
                  activate
                  set {procesList, pidList} to the {name, unix id} of (every process whose name contains "Filemaker Pro")
              end tell
              delay 5
              set VarLoop to "OK"
              try
                  --tell application "FileMaker Pro Advanced" to close every window
                  --on error
                  do shell script "kill -KILL " & pidList as text
                  set window_name to "Error"
                  set VarRepeat to "Yes"
              end try
              
              
          end if
          
          
          ---------------------------------------------------
          if testIP as text = "True" then
              try
                  tell application id "com.filemaker.client.advanced12"
                      activate
                      delay 5
                      set window_name to the name of every window whose visible is true
                  end tell
              on error
                  set window_name to "Error"
              end try
              --display dialog testIP as text
              --------------------------    
              if testIP as text = "True" and window_name contains "Error" and VarRepeat = "Yes" then
                  
                  tell application id "com.filemaker.client.advanced12"
                      activate
                      try
                          open ThePath & "Robot.fmp12"
                          set window_name to "Robot"
                          set VarRepeat to "No"
                      on error
                          quit
                      end try
                  end tell
                  
              end if
          end if
          ---------------------------------------------------    
          --with timeout of 60 * 60 * 24 seconds
          delay 5
          if VarRepeat = "No" and window_name contains "Error" then quit
      end repeat
      to chkUP(theURL)
          return (count (get ((theURL as URL)'s host & {dotted decimal form:""})'s dotted decimal form)) > 0
      end chkUP
    • By Lewis2412
      I have two filemaker servers. One is version 7 and the other is version 11 advanced. I transferred the files from FM7 server to FM11 with no problem. Long story short, everything was great until I realized that the users were still using the FM7 files. To fix the problem, I shut down the filemaker service on both servers, then made a backup of each server by copying the files to another folder. Then I removed the FM11 files that were never used and copy and pasted the .fp7 files from the FM7 server to the FM11 server. I started the filemaker service on FM11, opened the files using the FM11 console. Now when I try to open the files on a workstation, the files do not show up in the Remote list. The server console shows that they are open. How can I correct this?
    • By fm8443
      I have a simple Applescript that works in Script Editor
      tell application "Keyboard Maestro Engine" 
      do script "Search the Web" 
      end tell
      I add this same script (with escape chars) to my RESOURCES::A_SCRIPT field inside FM.
      The RESOURCES table is not connected to the other tables in the graph.
      "tell application \"Keyboard Maestro Engine\" 
      do script \"Search the Web\" 
      end tell"
      I've tried this with this field being defined as a Global Storage Field or not.  Similar problems with both.
      I have an FM Script called EXECUTE:
      Perform Applescript (RESOURCES::A_SCRIPT)
      When I run this FM Script I get an error message:
      "Error: -2741" / "Expected EOL but found Command Name"
      I've have tried rebooting my Mac.
      Any ideas?
       
       
    • By Franco Pagano
      fmp 14 last release.
      i put this applescript in a global field  and also all the fmp field are global.
      i don't understand  wy it doesn't work, if the applescript var are set as ... "set ServerDisk to "afp://2.236.100.143/dati" ... it work.
      Were i am wrong?
      Many thanks.

          set ServerDisk to field ("ServerDisk_as" as text) of table ("__AS" as text)
          set ServerFolder to field ("ServerFolder_as" as text) of table ("__AS" as text)
          set VarAccount to field ("VarAccount" as text) of table ("__AS" as text)
          set VarPw to field ("VarPassWord" as text) of table ("__AS" as text)
      tell application "Finder"
          display dialog ServerFolder
          if not (disk ServerDisk exists) then
              mount volume ServerFolder as text as user name VarAccount with password VarPw
          end if
      end tell