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

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

Recommended Posts

Posted

Hi,

I'm trying to make a script that copies the content of about 30 consecutive fields from the previous record into the same field on the current record. My current solution is to, one by one,

go to previous record

copy field x

go to next record

paste field x

This makes for a long, tedious and inefficient script that takes a long time to execute. Is there a better way?

Thanks

Andrew

Posted

Create a global field called gPrimary. Create a relationship from gPrimary to the PrimaryKey of your table. We'll call this relationship "Primer". Go to the record with the relevant data and set gPrimary as the PrimaryKey. ie: SetField (gPrimary ; PrimaryKey). Now go to the record where you want the data and use the SetField script based upon this relationship. So, in full:

Go to Previous Record

SetField (gPrimary ; PrimaryKey)

Go to Next Record

SetField (MyField ; Primer::MyField)

SetField (MyField2 ; Primer::MyField2), etc, etc.

Peter

Posted

Thanks, works like a charm!

Another question about this.

Before I export this database, I need to change all the field names. The way I can think of to do it is by exporting into a separate filemaker file with the correct field names and then exporting that file, but that seems kind of backwards. Is there a way to automate this process within the same file?

Thanks again!

Posted

Create a global field called gPrimary

This is not really 7.0 but more the way it was done in previous versions, when networking is most of the calculations NOW done on the server to prevent hogging network bandwidth, with one exception namely global fields. I'm not saying they should be avoided as in OOP but the new feature Get(ScriptParameters) are there to solve this particular issue.

--sd

Posted

Value from last visited record means exactly that. So you better make sure you are IN the previous record (in a field) before you use that.

Picnichouse, what are you exporting to? Filemaker? Text? It must be text, or else you'd be done after changing the names in the other FileMaker file. XML export would allow you to create whatever field names you want. As a first line, right? What separators? Otherwise what do you mean by "field names" in a text file? XML/XSL would be little tedious, basically hand-building the first line as text; but it would work.

Posted

Yes, I'm exporting to text (csv). I need the first record to hold the header names. Right now I'm doing it by exporting to another filemaker database with the correct field names and then exporting a text file from there. I'd like to be able to do it within the same file if possible.

Also, the fields need to export in a different order than order of creation.

Thanks for the help!

Posted

This is how you could do it with an XSL stylesheet file (which you could actually export from FileMaker). But you solution of using a separate FileMaker file is a good one also.

This example is more or less what you get with a "Merge" export out of FileMaker; comma-separated; field names in the first row, no quotes; data in other rows, with quotes.

But you can see I explicitly put the separators in each place. I also moved the order of the "field names" around a little. I did not move the order of the field data around. You don't really need to; because you can export in the order that you want directly from FileMaker. It's only the "fake" names that you need put the same as what you want to export.

ArbitraryFieldsCSV.zip

Posted

Fenton's solution is probably best for this situation, but for other uses I find it easiest to go to the previous record, set a global with its id, return to the original record, and set all the fields using Set Field [fieldX; rel::fieldX], where rel is a relationship from the global to the table's id.

Alternatively, you can set the global with the new record's id, go to the previous one and use Set Field [rel::fieldX; fieldX], then return to the new record.

Either method should take about the same amount of time.

  • 11 months later...
Posted

These are simple instructions and I believe I've followed them in spirit. For Peter1's instructions I have done the following:

create a global field called gPrimary

create a field called serNo and auto enter a serial number

create a field called filename which holds the text string of a filename

create a field called prevre which should receive the filename field of the previous record.

and created the following script

Go to Record/Request/Page

[ Previous ]

Set Field [ MyTable::gPrimary; MyTable::serNo ]

Go to Record/Request/Page

[ Next; Exit after last ]

Set Field [ MTable::prevrec; primer::filename ]

I apologize if this is so obvious, but I'm not seeing it.

Looking at the above, I'm not sure how the relationship between gPrimary and serNo comes into play, other than the last line of the script.

But I'm getting zero but I'm not seeing why it's not working, thanx, sam

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