dbTalk Databases Forums  

fmp6 new record quirk

comp.databases.filemaker comp.databases.filemaker


Discuss fmp6 new record quirk in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Joseph O'Brien
 
Posts: n/a

Default fmp6 new record quirk - 06-23-2011 , 11:53 AM






I have a script that creates a related record and fills in data using global variables from the parent record.

It seems that under certain conditions which remain a mystery, existing values in the related file are overwritten by the new values.

Basically, the script begins by setting a global variable by concatenating two strings. It then calls a script in a child record. The second script creates a new record and sets the values of two fields based on the the global variable from the parent file.

Again, I haven't been able to figure out exactly what conditions cause datain the child file to be overwritten, but it almost seems like the new record isn't being selected. Is there a way to force FMP6 to select the new, blank record? Would "Go To Last Record" guarantee that it would be selected?

Here's the script, just in case you need more information.

Thanks for any suggestions!

Script 1:
Enter Browse Mode[]
Set Field ["GlobalVariable","primaryKey & childFile1:Notes"]
Perform Script[Sub-scripts,External:"childFile2.fp5(*)"]

The following script is performed from childFile2.fp5:

New Record/Request
Set Field ["relatedPrimaryKey","Left(parentFile::GlobalVariab le,5)"]
Set Field ["notes","Right(parentFile::GlobalVariable)-5"]

Reply With Quote
  #2  
Old   
Your Name
 
Posts: n/a

Default Re: fmp6 new record quirk - 06-23-2011 , 04:07 PM






In article
<d95a735c-12db-4ee6-8a49-70fb3047d73f (AT) glegroupsg2000goo (DOT) googlegroups.com>,
comp.databases.filemaker (AT) googlegroups (DOT) com wrote:

Quote:
I have a script that creates a related record and fills in data using globa=
l variables from the parent record.

It seems that under certain conditions which remain a mystery, existing val=
ues in the related file are overwritten by the new values.=20

Basically, the script begins by setting a global variable by concatenating =
two strings. It then calls a script in a child record. The second script cr=
eates a new record and sets the values of two fields based on the the globa=
l variable from the parent file.=20

Again, I haven't been able to figure out exactly what conditions cause data=
in the child file to be overwritten, but it almost seems like the new reco=
rd isn't being selected. Is there a way to force FMP6 to select the new, bl=
ank record? Would "Go To Last Record" guarantee that it would be selected?=
=20

Here's the script, just in case you need more information.

Thanks for any suggestions!

Script 1:
Enter Browse Mode[]
Set Field ["GlobalVariable","primaryKey & childFile1:Notes"]
Perform Script[Sub-scripts,External:"childFile2.fp5(*)"]

The following script is performed from childFile2.fp5:

New Record/Request
Set Field ["relatedPrimaryKey","Left(parentFile::GlobalVariab le,5)"]
Set Field ["notes","Right(parentFile::GlobalVariable)-5"]
You could use the Go To Record [Last] command to force FileMaker to be at
the last record, which will be the new one if they are not sorted, but
that seems a bit like using a jack hammer to crack a peanut. )

This is just a quick first guess, and I'm not sure it's the cause of your
problem, but what is the definition for the parentFile relationship that
retrieves the global values? (I'm ignoring what is probably a typo in the
last line with the Right function.)

If it's definied using the relatedPrimaryKey field from the childFile2.fp5
file to the parent file, then you've got a problem ... the relationship
won't work when retrieving the GlobalVariable field's data since it won't
have any link data.

To get around this you could move the global field to the childFile2.fp5
file instead. That way the relationship from parent to child will exist
(even if there are no related records yet) so the global field can have
its data set ready for the second script to retrieve locally (not via a
relationship).
i.e.
Script1:
Enter Browse Mode []
Set Field [childFile2::GlobalVariable, primaryKey & childFile1::Notes]
Perform Script [Sub-scripts, External:childFile2.fp5(Script2)]

Script2:
Set Field [relatedPrimaryKey, Left(GlobalVariable, 5)]
Set Field [notes, Right(GlobalVariable, Length(GlobalVariable) - 5)]


Personally I would use two separate global fields to save the bother of
concatenating and then extracting the two separate data values, but using
one isn't any problem.

Helpful Harry )

Reply With Quote
  #3  
Old   
cortical
 
Posts: n/a

Default Re: fmp6 new record quirk - 06-23-2011 , 07:53 PM



On 24/06/11 2:23 AM, Joseph O'Brien wrote:

Quote:
Script 1:
Enter Browse Mode[]
Set Field ["GlobalVariable","primaryKey& childFile1:Notes"]
Perform Script[Sub-scripts,External:"childFile2.fp5(*)"]

The following script is performed from childFile2.fp5:

New Record/Request
Set Field ["relatedPrimaryKey","Left(parentFile::GlobalVariab le,5)"]
Set Field ["notes","Right(parentFile::GlobalVariable)-5"]

maybe a commit may help in the script 1 before executing s2; in fm5 ( a
long time ago) change mode (enter preview, enter browse)

I would also suggest using 2 globals; they are cheap after all. I notice
you are concatenating a key and a text field , then parsing the left 5
char of the concatenation, this may be the cause of the issue you are
experiencing as well. set a global as the key, another as the text, or
having set the foreign key, use a back rel to parse the related text

In current versions, one would use a variable in place of the global.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.