Jump to content

Trigger one File to create a new record in another file.


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

Recommended Posts

Hi, 

I have searched everywhere and could not find something I could apply to do what I am looking for. 

I have a Fire Dept database that I manage, they have a table of "Event Reports" for each call.  Within our Fire Departments we have 14 towns that are part of a Mutual Aid Group which has a radio desk that manages large, multi resource incidents.  I would like to develop a database to help them manage the resources at the incidents since a handful of departments are already using the database solution I host for them on a server.  

I would like to create a script that copies the values in about 6 fields on an Event Report from a townships database and have a new record created in the Mutual Aid database and have those 6 values set into their respective fields?  

I understand the set variable and set field steps but spanning those from one file to another is not something I have done before.  

Any help would be really appreciated.   

Town Database the data is coming from.  

Event Report:Time

Event Report:Type of Event

Event Report:Full Address

Event Report:Township

Evnet Report:I.C.S. Officer

 

Mutual Aid Database the data is going to. 

Incidents:Township

Incidents:Address

Incidents:TimeStart

Incidents:EventType

Incidents:CommandOfficer

Edited by CKonash
Link to comment
Share on other sites

Hi there

If I were doing this, I would Perform a Script that exists in the Mutual Aid database, from the Townships database, and pass the information as a Script parameter, separated by carriage returns.

So in the Townships database you do something like :-

Perform Script (External Database: Mutual Aid DB ; Add Record Script ; ScriptParameter "Time¶Type Of Event¶Full Address¶Township¶ICS Officer ")

and then in the Mutual Aid DB, you would have a script like this :-

Add Record Script

Go To Layout (Data Entry)

New Record/Request

Set Field ( Township ; GetValue ( Get ( ScriptParameter ) ; 4 ) )

Set Field ( Address ; GetValue ( Get ( ScriptParameter ) ; 3 ) )

Set Field ( Time Start ; GetValue ( Get ( ScriptParameter ) ; 1 ) )

etc

This should give you a new record with all the data copied across.

Does that help?

Edited by rwoods
Link to comment
Share on other sites

Thank you very much.  I'm going to try that now.   

One thing I forgot, and was hoping I would have the ability to pass a pdf in a container field in the Township DB into a container field in the Mutual Aid DB.  Can I do that via a scrip parameter?

Thanks,

Chris

Link to comment
Share on other sites

Hi,  I tried a few things and I almost got it working, minus the container thing.  

The township script is triggering the new record script in the Mutual Aid database. :) 

The Mutual Aid Database is seeing the scrip parameter that I set but it isn't setting the fields with the values from the Township Database, it is setting the filed with what is actually typed in the scrip parameter calculation.  

How do I get the value in the fields to become the values in the scrip parameter?  

 

Thank You!. 

Chris

Screen Shot 2017-02-27 at 12.30.30 PM.png

Screen Shot 2017-02-27 at 12.28.50 PM.png

Link to comment
Share on other sites

  • 1 month later...
On 2/27/2017 at 11:19 AM, rwoods said:

Add Record Script

This should give you a new record with all the data copied across.

Does that help?

Hello, 

I have been successful in getting the script to open the other file and create a record.  What I didn't think of is is it possible to specify an account username and password for it to login to the other file under?  It was working great for me because I have the same user account and password for both the databases I was working with.  I would prefer not to Login as a Guest since that would kill my security privileges I believe.  Anyone know if it is possible to specify a user account and password when using an open file script step?

Thanks very much!. 

Chris

 

Link to comment
Share on other sites

8 hours ago, CKonash said:

Hello, 

 Anyone know if it is possible to specify a user account and password when using an open file script step?

Not in a secure way because it means hard-coding the credentials somewhere.  The whole idea is that if a user needs access to a file, he needs credentials in it.  If you don't care about security that much you can use the APIs to open a file (fmp url, ActiveX, AppleEvents) and hard-code the password.

If you don't want to maintain individual accounts in a file, look at using External Authentication to use groups, which is infinitely more secure.

 

Link to comment
Share on other sites

1 hour ago, Wim Decorte said:

Not in a secure way because it means hard-coding the credentials somewhere.  

 

Thank you very much.  This would be a handoff of information between a police server and a fire server which happen to be separate.  The user account for the handoff would only be able to access the given fields and nothing else so I guess it's ok to hard-code the credentials.  I'll research how to open a fmp file using the url script step and put the credentials in the url and see how that works.  If I get into trouble I'll maybe reach out to see what I am doing wrong. 

 

Thanks,

Chris

 

Link to comment
Share on other sites

  • 4 weeks later...
On 4/17/2017 at 6:47 AM, Wim Decorte said:

Not in a secure way because it means hard-coding the credentials somewhere.  The whole idea is that if a user needs access to a file, he needs credentials in it.  If you don't care about security that much you can use the APIs to open a file (fmp url, ActiveX, AppleEvents) and hard-code the password.

 

 

Hi Wim, 

I have tried so many different combinations to Open the second file with the open url script step.  I still get a popup dialog window to enter credentials for the file that the script is opening.  It sees the file on the server and is attempting to open it but the hard coded username and password don't seem to be working.  Am I doing it incorrectly?  

fmnet:/Username:[email protected]/NORCON

Screen Shot 2017-05-14 at 9.54.22 AM.png

Link to comment
Share on other sites

Note that I mentioned the fmp protocol as one of the options. That one would work with the 'open url' script step.  But you are not using the fmp protocol at all. you're using the internal FM file reference syntax.

Here's a good intro on the fmp protocol.  Also look in the help for 'fmp protocol'

https://www.seedcode.com/fmp-url-protocol-filemaker-testing/

Also, note that if you just want to push data into another system and not really open a file to have the user interact with that other file's user interface then you can just use the FileMaker Server XML API to create records and run scripts on the other file *without* actually opening the file.

Link to comment
Share on other sites

20 hours ago, Wim Decorte said:

Here's a good intro on the fmp protocol.  Also look in the help for 'fmp protocol'

https://www.seedcode.com/fmp-url-protocol-filemaker-testing/

Hello, 

I am definitely not an expert on the filemaker scripting of open file vs open URL but your direction in assisting me to find the needed reading material was awesome, thank you so much.

I have never done the XML data exchange so I wouldn't know how to even start that process...  

Using the Open URL script step, I messed around with it this morning and am able to get the File 1 to open File 2 with the embedded user and password and also get the intended script to run.  Adding in the script parameter into the URL is where I get hung up.  I added the info as it appears below in the picture but it does not return the data from File 1, it simply returns the literal text that is in the script parameter of the open URL script parameter.  Instead of pulling the address from File 1 into File 2 using the script parameter within the url it is only pulling the table::field.  

Am i doing something totally wrong?

Thanks

Chris

 

Screen Shot 2017-05-15 at 1.51.06 PM.png

Screen Shot 2017-05-15 at 1.50.06 PM.png

Link to comment
Share on other sites

Should be ... &param=" & Event Report::Time & ¶ & etc.

To make it more readable you could put your fields into a variable first.

Link to comment
Share on other sites

1 hour ago, Fitch said:

Should be ... &param=" & Event Report::Time & ¶ & etc.

To make it more readable you could put your fields into a variable first.

I have tried a few different variations of what you described and none of them return we I would have hoped.  All of the data is entered into the first script paramenter field and it is still the name of the Table:Field from File 1.  

See attached.  Any ideas?

Thanks 

Chris

 

Screen Shot 2017-05-15 at 4.08.34 PM.png

Screen Shot 2017-05-15 at 3.59.53 PM.png

 

Screen Shot 2017-05-15 at 4.18.40 PM.png

Edited by CKonash
Link to comment
Share on other sites

I guess I wasn't clear. FileMaker treats everything inside a pair of quotes as a literal string of text. I.e., your URL as written is not sending the values of the fields, it's sending the names of the fields.

What I was trying to say is that your URL should look like:

"fmp:// ... param="   // no more quote marks after this
&  //  concatenate the line above with the line below
List( fieldA; fieldB; etc )  // no quotes

Be aware that sending position-based parameters may require extra error handling -- what if one of the fields is empty? What if address has two lines? GetValue( param ; 2 ) may not be what's expected.

Link to comment
Share on other sites

Just want to say thank you so very much to the three of you that helped me.  I was able to decipher what you shared with me and implement it into our fire departments database and now we can create a record and use the scrip parameter to dump in the vital info into a different database that our county will use to monitor incoming fire apparatus.  I definitely could not have done that without you.  

Thanks so much! 

Edited by CKonash
Link to comment
Share on other sites

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