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
      What is wrong when Database appears unavailable to the scheduler, yet regular users are logged in?
    • By ggt667
      Is there a way in AppleScript to trap if the connection is lost and have an AppleScript act on this?
      At the risk of asking and answering myself( AppleScript below )
      repeat tell application "FileMaker Pro" try database "db" on error do shell script "sudo shutdown -r now" with administrator privileges end try end tell delay 59 -- 59 secs end repeat  
    • By Colin Hunter
      I'm running FMS 11.0.5.510 on OS X 10.9.5. It's serving forty databases, one of which is served to the web via custom web publishing. Everything is running smoothly but the campus security auditor is picking up a vulnerability with the old version of OpenSSL running on OS X 10.9.5's Apache. I addressed this on a different, non-FMS Mac by disabling Apple's bundled Apache and using MacPorts to install Apache2.
      How to do this on my FMS 11 Mac? Just getting MacPorts to install Apache2 is the first problem as port install apache2 fails with a conflicting ports message. I assume this is because the existing Apache is blocking installation of the new version but how to stop the existing one? I tried turning off web publishing in the FMS admin console but port install still fails with the familiar conflicting ports message. Even stopping the web server with Mark Banks' FMSControl didn't help.
      I therefore have a couple of questions:
      How do I stop the existing Apache so MacPorts will install Apache2? Once I have Apache2, how do I get FMS11 to use it instead of Apple's bundled Apache1? Thanks
      Colin
    • 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