dbTalk Databases Forums  

if no related record then create new record script steps?

comp.databases.filemaker comp.databases.filemaker


Discuss if no related record then create new record script steps? in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
MaximalVariance
 
Posts: n/a

Default if no related record then create new record script steps? - 01-03-2007 , 01:15 PM






hello all and happy 2007!

i have a script step for 'go to related record'. I would like to
capture the case when there is *no* related record, and prompt for the
creation of a *new* record in the related table.

does anyone know the error code, or how to script this?
in pseudo code, something like:

go to related record from table x using layout y, show only related
records
if no related records then
go to layout y, create new record
end if

thoughts?

thanks much,
sg


Reply With Quote
  #2  
Old   
Christoph Kaufmann
 
Posts: n/a

Default Re: if no related record then create new record script steps? - 01-03-2007 , 03:12 PM






MaximalVariance <StephenTGallagher (AT) gmail (DOT) com> wrote:

Quote:
i have a script step for 'go to related record'. I would like to
capture the case when there is *no* related record, and prompt for the
creation of a *new* record in the related table.

does anyone know the error code, or how to script this?
in pseudo code, something like:

go to related record from table x using layout y, show only related
records
if no related records then
go to layout y, create new record
end if
I use this a lot. Not sure what the script steps and functions are
called in your version, this is my translation from my German version:

Enter Browse mode
If IsValid(y::somefield)
Go to related records (Y, Laoyut Y)
Else
grab key field
go to layout y
New record
set key field
end if

When appropriate, I tell the user after the "Else" step that there are
no child record and aks whether I sould abort or create one.
--
http://clk.ch


Reply With Quote
  #3  
Old   
Helpful Harry
 
Posts: n/a

Default Re: if no related record then create new record script steps? - 01-03-2007 , 11:27 PM



In article <1167851719.160415.176570 (AT) a3g2000cwd (DOT) googlegroups.com>,
"MaximalVariance" <StephenTGallagher (AT) gmail (DOT) com> wrote:

Quote:
hello all and happy 2007!

i have a script step for 'go to related record'. I would like to
capture the case when there is *no* related record, and prompt for the
creation of a *new* record in the related table.

does anyone know the error code, or how to script this?
in pseudo code, something like:

go to related record from table x using layout y, show only related
records
if no related records then
go to layout y, create new record
end if

thoughts?
You'll need two scripts or a Portal on the current layout that's set to
allow creation of related records.

Without a Portal the scripts would be something like this:

In the Parent File / Table

If [IsEmpty(Relationship::KeyField)]
Set Field [Relationship::g_tempField, KeyField]
Perform Script [Create New Record]
Else
Go To Related Records [Relationship]
End If

where g_tempField is a Global field in the Child File / Table, and the
second script is:

In the Child File / Table

New Record / Request
Set Field [KeyField, g_tempField]







Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
  #4  
Old   
eyebrown@mindspring.com
 
Posts: n/a

Default Re: if no related record then create new record script steps? - 01-04-2007 , 06:02 AM



In article <1hrdxgl.uj3wsob8o4jkN%clk (AT) freesurf (DOT) ch>, clk (AT) freesurf (DOT) ch
(Christoph Kaufmann) wrote:

Quote:
I use this a lot. Not sure what the script steps and functions are
called in your version, this is my translation from my German version:

Enter Browse mode
If IsValid(y::somefield)
Go to related records (Y, Laoyut Y)
Else
grab key field
go to layout y
New record
set key field
end if
I, too, use IsValid for this purpose and many other reasons to learn if
any related records exist or not (I'm running FM 6, served, with
multi-platform clients).

Long ago I ran across someone complainging that the IsVald script step was
unstable. This has worried me ever since, but I've never found a
circumstance where it would fail me.

What *has* failed me is using variations of Helpful Harry's
IsEmpty(relationship::related field). For some kind of finds & script
analysis, if a record does not exist, then the field is not empty, it's
just not there.

Steve Brown


Reply With Quote
  #5  
Old   
Matt Wills
 
Posts: n/a

Default Re: if no related record then create new record script steps? - 01-04-2007 , 08:09 AM





On 01/04/2007 07:02:17 eyebrown (AT) mindspring (DOT) com wrote:

Quote:
In article <1hrdxgl.uj3wsob8o4jkN%clk (AT) freesurf (DOT) ch>, clk (AT) freesurf (DOT) ch
(Christoph Kaufmann) wrote:

I use this a lot. Not sure what the script steps and functions are
called in your version, this is my translation from my German version:

Enter Browse mode If IsValid(y::somefield) Go to related records (Y,
Laoyut Y) Else grab key field go to layout y New record set key field end
if

I, too, use IsValid for this purpose and many other reasons to learn if
any related records exist or not (I'm running FM 6, served, with
multi-platform clients).

Long ago I ran across someone complainging that the IsVald script step was
unstable. This has worried me ever since, but I've never found a
circumstance where it would fail me.

What *has* failed me is using variations of Helpful Harry's
IsEmpty(relationship::related field). For some kind of finds & script
analysis, if a record does not exist, then the field is not empty, it's
just not there.

Steve Brown
Create a calc field something like

CompareKeys = If ( ThisTable::ThisKey = ThatTable::ThatKey ; 1 ; 0 )

Then look at the value of CompareKeys to determine if a related record exists.

Matt


Reply With Quote
  #6  
Old   
Helpful Harry
 
Posts: n/a

Default Re: if no related record then create new record script steps? - 01-04-2007 , 02:04 PM



In article
<eyebrown-0401070706240001 (AT) 209-42-139-215 (DOT) earthlink.wispnet.net>,
eyebrown (AT) mindspring (DOT) com wrote:

Quote:
In article <1hrdxgl.uj3wsob8o4jkN%clk (AT) freesurf (DOT) ch>, clk (AT) freesurf (DOT) ch
(Christoph Kaufmann) wrote:

I use this a lot. Not sure what the script steps and functions are
called in your version, this is my translation from my German version:

Enter Browse mode
If IsValid(y::somefield)
Go to related records (Y, Laoyut Y)
Else
grab key field
go to layout y
New record
set key field
end if

I, too, use IsValid for this purpose and many other reasons to learn if
any related records exist or not (I'm running FM 6, served, with
multi-platform clients).

Long ago I ran across someone complainging that the IsVald script step was
unstable. This has worried me ever since, but I've never found a
circumstance where it would fail me.

What *has* failed me is using variations of Helpful Harry's
IsEmpty(relationship::related field). For some kind of finds & script
analysis, if a record does not exist, then the field is not empty, it's
just not there.
I can't say I've ever found a problem with this - if a field doesn't
exist then it must be empty.

BUT, there are other ways. Usually I use the Count function. If there
are no related records then counting them will add up to 0.
ie.
If Count(Relation::KeyField) = 0
Message "There are no Related records"
Else
Message "There are Count(Relation::KeyField) related records"

Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
  #7  
Old   
eyebrown@mindspring.com
 
Posts: n/a

Default Re: if no related record then create new record script steps? - 01-05-2007 , 06:58 AM



In article <050120070904420556%helpful_harry (AT) nom (DOT) de.plume.com>, Helpful
Harry <helpful_harry (AT) nom (DOT) de.plume.com> wrote:

Quote:
BUT, there are other ways. Usually I use the Count function. If there
are no related records then counting them will add up to 0.
ie.
If Count(Relation::KeyField) = 0
Message "There are no Related records"
Else
Message "There are Count(Relation::KeyField) related records"
As most of my files contain a Constant field (a calc number field that has
a one in it across all records), I sometimes use a summary field for this:

Sum(Relation::Constant)

Steve Brown


Reply With Quote
  #8  
Old   
eyebrown@mindspring.com
 
Posts: n/a

Default Re: Re: if no related record then create new record script steps? - 01-05-2007 , 07:09 AM



In article <1499.PQNWYBQK (AT) news (DOT) verizon.net>, Matt Wills <Im (AT) witz (DOT) end> wrote:

Quote:
Create a calc field something like

CompareKeys = If ( ThisTable::ThisKey = ThatTable::ThatKey ; 1 ; 0 )

Then look at the value of CompareKeys to determine if a related record exists.
This is the way I do this job most frequently (I'm running FM6,
remember). The reason I've explored alternatives is that running finds on
this calc feld can be very slow for largish files, 50,000 + records. This
depends on the complexity of the calc fields that create the keys. I
typically have many specialized keys, like Case ( OrderDate >=
TextToDate("1/1/2005"), OrderID, 1, 0) would key me to all order records
generatred since January 2005.

So making a CompareKy calc that in turn references other calc fields can
get troublesome, depending on the calcs and what fields are being
referenced in turn. Usually the result is that a CompareKeys field as you
describe cannot be indexed

Steve Brown


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.