Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Repeating Fields... (pasting data into)


Andy Whittaker
 Share

Recommended Posts

Can anyone help me with a script that will paste record numbers from a found set of records into a repeating field. I can only seem to get one record number into the repeating field via scripting, after that the number simply gets replaced and not repeated. Thanks. [email protected]

Link to comment
Share on other sites

Hi Andy,

Repeating fields are a legacy from the early days of FileMaker and (sadly) won't accept data using the more recent 'Set Field' script step. You have to use the "Paste" command. Moreover the paste step must be called when the database is on a layout where the field your pasting into is present and has "allow entry into field" enabled. In the case of a repeating field, the number of repetitions defined to show on the layout (using the 'Format Field' dialog) must also be equal to or greater than the repetition you are pasting into.

 

Once you've confirmed that all the above conditions are met, add the required 'Paste' step within your script and click on the 'Specify Field' button to select the repeating field you want to paste into. Before leaving the Specify Field dialog you must enter the number of the repetition which you want to paste into in the repetition box at the lower left (below the list of available fields).

 

That's it - you should be in business. smile.gif

Link to comment
Share on other sites

Hi Andy

 

Well it can be done using Set Field. Can you please provide a little more detail about what you are trying to do and why? This will help in providing the correct solution.

 

Ray, I agree with you when you say that "Repeating fields are a legacy from the early days of FileMaker" but just don't understand why you say that they "won't accept data using the more recent 'Set Field' script step". This is clearly not true.

Link to comment
Share on other sites

Thanks for picking up on that, David. You're absolutely right. I've just tried it in 5.5 with no difficulties.

 

I still have the nagging feeling that there was a platform or version in which I encoutered a brick wall with set field and repeating fields, but it clearly works in 5.5 on both platforms. confused.gif

 

Apologies to Andy for the faulty advice on that point! :eek:

Link to comment
Share on other sites

  • 3 weeks later...

Ahh! yes - that nagging feeling. It has all come back to me in a nasty blinding rush.

 

Yes this works:

Set Field ["DestinationField", "GetRepetition(SourceField, 2)"]

 

And this works too:

Set Field ["DestinationField"-2, "SourceField"]

 

but alas, this does not:

Set Field ["DestinationField"-2, "GetRepetition(SourceField, 2)"]

 

This is a problem I had originally encountered on v5.5. When both the souce and destination locations are repetitions, the Set Field command does not work (it clears the destination repetition, leaving it null). 'Insert Calculated Result' does the same.

 

I've tested it on both Windows and Mac, on versions 5.0 and 4.0v3 with the same (lack of) result.

 

The work-around I used to get over the problem was to use an intermediary global field and twice as many script steps; viz

 

Set Field ["gScriptTemp.txt", "SourceField"]

Set Field ["DestinationField"-2, "gScriptTemp.txt"]

 

But there's no denying it is clumsy and tedious and shouldn't be necessary. If there's something I'm overlooking, or even a sensible explanation anyone can offer, I'd be grateful smile.gif

Link to comment
Share on other sites

Yes it's an old bug of FM.

Instead of

Set Field ["DestinationField"-2, "GetRepetition(SourceField, 2)"]

you should use

Set Field ["DestinationField"-2, "GetRepetition(SourceField, 2) & """]

 

Dj

 

Originally posted by CobaltSky:

[qb]Ahh! yes - that nagging feeling. It has all come back to me in a nasty blinding rush.

 

Yes this works:

Set Field ["DestinationField", "GetRepetition(SourceField, 2)"]

 

And this works too:

Set Field ["DestinationField"-2, "SourceField"]

 

but alas, this does not:

Set Field ["DestinationField"-2, "GetRepetition(SourceField, 2)"]

 

This is a problem I had originally encountered on v5.5. When both the souce and destination locations are repetitions, the Set Field command does not work (it clears the destination repetition, leaving it null). 'Insert Calculated Result' does the same.

 

I've tested it on both Windows and Mac, on versions 5.0 and 4.0v3 with the same (lack of) result.

 

The work-around I used to get over the problem was to use an intermediary global field and twice as many script steps; viz

 

Set Field ["gScriptTemp.txt", "SourceField"]

Set Field ["DestinationField"-2, "gScriptTemp.txt"]

 

But there's no denying it is clumsy and tedious and shouldn't be necessary. If there's something I'm overlooking, or even a sensible explanation anyone can offer, I'd be grateful smile.gif [/qb]

Link to comment
Share on other sites

Thanks Dj - much appreciated! smile.gif

 

Mind you, I'm not sure that there's much comfort in the 'explanation' "It's an old bug". One would like to think that there would be no such thing as an old bug - once it is known/reported, surely it should be fixed before it gets 'old'. confused.gif

 

Prompted to do some research by your words, Dj, I decided to look it up on the FMI Knowledge base.

 

It is indeed a *very* old bug. Article 104269 reports is as occurring in 3.x!!! Moreover, the folks at FMI are apparently not aware of the 'fix' you mentioned (which, BTW, I tested, and it works fine!) because they suggest much the same clumsy work-around as I had come up with - using a global field and twice as many script steps.

 

For what it's worth, there is also an 'explanation' of sorts contained in the article. It tells more or less how the bug came about - but offers no clue as to why it wasn't fixed in the next version - or the next or the next or the...

 

The problem occurs because FileMaker Pro takes into consideration what the destination is. When the destination is repetition x (other than the first), FileMaker Pro will inform all functions to "go down to repetition x" of the fields they are referencing or "looking at" (that is why the Extend function is sometimes needed).

 

However, GetRepetition is already looking at a specific repetition of the field it is referencing before it is told to "go down to repetition x" of the field it is referencing.

 

For example, with a script step like "Set Field ["B"-2,"GetRepetition(A,2"]" , you could say that the GetRepetition is being told to return the second repetition of the second repetition of field A. Obviously, this is meaningless in FileMaker terms so that GetRepetition function returns nothing.

(taken from the FMI Knowledge Base article no 104269).

 

Must say though, that although Dj's solution works, I'm none the wiser as to why it works - moreover, the fact that it does seems to fly in the face of the 'explanation' offered by FMI. Ie if GetRepetition in this context can be said to be "meaningless in FileMaker terms", how the heck does adding "" after it suddenly make it meaningful again. :rolleyes:

 

I'm also now wondering if the sundry other functions that the FMI article 104269 lists as not working with GetRepitition can also be cajoled into submission with the addition of some strategically placed 'nothings'. smile.gif

Link to comment
Share on other sites

Sure Ray,

for Last is the same IOW, Last(rep or rel field ) & "" whilst for Max and Min you should use form:

Max (rep or rel or fields)+0

Min (rep or rel or fields)+0

 

Dj

Link to comment
Share on other sites

Guys – my hat fall down! Amazing!

 

DJ is the MAN!

 

My score in this topic is

Goran = 200%

Ray = 90%

David = 80%

 

Thank you all!

Link to comment
Share on other sites

 Share



×
×
  • Create New...

Important Information

Terms of Use