Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Hello all,

I am just jumping into the scripting portion of FM.

I need to execute a find within the scripting languge so I can export certain records and fields into XML. I can export all the fields no problem. I assume one needs to perform a find to narrow down the results they wish to export?

I have a few lists(?) that I would like to loop through, and one I would like to just export the unique keys.

Examples:

* I have a list and I would like to just export the XML data for all the items in the list. What is the best way to accomplish this. I suppose I could do a dump of the whole database and while parsing through the XML with XSLT I could just ignore the duplicate field that I am looking for. I would rather only export all the unique fields, is there a way to dump the whole lists values?

* In relation to this list I would like to loop through each item in the list and perform a find for that key. I will then export and apply xsl to this criterea. Is there a way while in this loop to change the name of the output files name (in export) to the key of the list?

Thanks a lot!!

Posted

You'd better first define how to identify your dublicate records and create a relationship in the same file. In your script use the isvalid(relationship::indentify field). When it's valid, omit those records. Otherwise you can continue to the next record. When you are finished, use the export function and export your records in xml.

greetz,

Jeffer

Posted

Thanks for the reply.

So I can call an applescript after the file has been exported. This applesctript can change the name, based on an ID that I was searching with? Can one create a variable to pass to applescript through the FM scripting languge?

Posted

Hi Datafirm,

Notwithstanding the great advice given by Jeffer and Tom, something else you might consider ...

Value Lists (actually the ValueListItems() function) may make it easier for you. It

Posted

...as long, of course, as you don't exceed the 64k limitation for the field (including "

Posted

This sounds almost perfect. We are both talking about the pop-up list? It sounds like that can do exactly what I was describing; dump the lists values for export and iterate through each lists value, perform a search and export records. Am I correct. I would love to hear more!

Thanks!

LaRetta said:

Value Lists (actually the ValueListItems() function) may make it easier for you. It

Posted

Hi Datafirm,

Well, I've only got time right now for a quick description. It's pretty easy to do - takes longer to explain than to do. If you need each specific script-step before tonight, maybe others can list it out for you. But here's how:

Create a standard text field (Unique). Create a Value List (Unique), 'use values from field' and select 'all values' and point to Unique. Then you can create a calculation (text, unstored) with:

ValueListItems(Status(CurrentFileName), "Unique")

So your script would: Perform your regular find. Don

Posted

Hi,

I had a few more minutes than I thought so I wrote out the multiline script portion for you:

Script , after your find portion, would be something like:

Set Field [ Unique, YourField ]

Freeze Window

Loop

Go to Record/Request/Page

[ Next, Exit after last ]

Set Field [ Unqiue, Unique & "

Posted

1. If the "Unique" field is a global, you won't have to worry about multi-user. However, I'd suggest that if you're going to run a script anyway, that loops and sets field, you may as well just loop through and omit duplicates and then export the "standard" way. Again, no multi-user issues and no size limit. Degree of difficulty is about the same, so try both and see which runs faster.

2. "So I can call an applescript after the file has been exported. This applesctript can change the name, based on an ID that I was searching with? Can one create a variable to pass to applescript through the FM scripting languge?"

Yes. An easy way would be to grab the data from the first found record, no need to "create a variable" (which FileMaker doesn't really do, we use global fields for that). Sorry I don't have time to get into detail, but dig around a little and you can find some examples:

http://www.macscripter.net/faq/finder_macos.php

http://maccentral.macworld.com/features/applescriptprimer00/

Posted

thanks. I will be getting to a response later. I just watnted to thank you all for your input! smile.gif

LaRetta said:

Hi,

I had a few more minutes than I thought so I wrote out the multiline script portion for you:

Script , after your find portion, would be something like:

Set Field [ Unique, YourField ]

Freeze Window

Loop

Go to Record/Request/Page

[ Next, Exit after last ]

Set Field [ Unqiue, Unique & "

Posted

Tom said...

If the "Unique" field is a global, you won't have to worry about multi-user.

ValueListItems won't work on a global field. crazy.gif

If this solution didn't require finding a set of records first; in other words, if it was based upon all values in a field in the database, using ValueListItems is very powerful. Just find one record and export the calc (or use the calc any way you wish for a unique set.) But because it was dealing with only a found set, this probably wouldn't be a better way to go - just an alternate way. Both require scripting several lines to accomplish it. smile.gif Thanks Tom!

LaRetta

Posted

Sorry, I thought you were looping through and setting each value into a field with a paragraph separator. That would work with a global. I see what you meant now. But I don't see why you're setting Unique in each record to contain all the values. Why not just Replace the Unique field with YourField? Then isolate one record and export your ValueListItems calc.

I think your method would be slower in this case though, LaRetta, because first you'd have to do a Replace with "" (blank) for the Unique field in ALL records in the database, or else clear Unique in the found records at the end of the script. So that's a second loop or at least another Replace.

Posted

Hi Tom,

I'm not setting each record to all values. I'm setting ONE record (whever record I'm on) to the found set (as a multiline). It will be blanked again after the export. This would work just as well setting a text field in another db or anywhere, I just happen to use whatever db we're in and use whatever record is the current record. Makes no difference.

Then the ValueListItems() only displays the unique values from that set. The VLI calculation is then exported with the Unique values. smile.gif

I'd be happy to provide a quick demo if you're still unclear on how this would work. smile.gif

Cheers,

LaRetta

Posted

Thanks again for the reply,

I have been thinking about his some more and trying to replicate what you have said. I am a bit confused. Maybe I can go over it again and if you have time you can see if I am still on the right track.

I am not concerned with a multi user environment, this is just going to be used to publish HTML files.

Lets just assume I have a few fields. State, and location, both are valueLists. There are only four states in this database and there are maybe a hundred or so locations. Of course each location in each record is only bound to one state.

For the first simple HTML file that I am going to create, I will need to print a list of the states and under each state (or in a table) I will be listing the locations that were found in each state. I need to export an XML file with only the first records that have a unique state->location relationship and would only like to export those fields in the XML if at all possible from the scripting interface? This would allow me to easily create this HTML page through XSL. My next step is going to have a bunch of thumbnails with relevant info from each record that was corresponding to each location, this appears to be just as easy as performing a find and doing it for every location. So I will end up with a bunch of location HTML files.

Does this make sense, or was this exactly what you were describing and I am just being dense?

Thanks in advance for your time and ideas!

Regards

LaRetta said:

Hi Datafirm,

Well, I've only got time right now for a quick description. It's pretty easy to do - takes longer to explain than to do. If you need each specific script-step before tonight, maybe others can list it out for you. But here's how:

Create a standard text field (Unique). Create a Value List (Unique), 'use values from field' and select 'all values' and point to Unique. Then you can create a calculation (text, unstored) with:

ValueListItems(Status(CurrentFileName), "Unique")

So your script would: Perform your regular find. Don

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