dbTalk Databases Forums  

Checking whether a new portal record is needed

comp.databases.filemaker comp.databases.filemaker


Discuss Checking whether a new portal record is needed in the comp.databases.filemaker forum.



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

Default Checking whether a new portal record is needed - 09-19-2005 , 01:35 AM






I have a database with the following relationship

vehicle_model::model_id ---< crash_link::model_id --
crash_link::crash_id >--- crash::crash_id

I have successfully added a portal to CRASH records on the Vehicle_model
layout. Although, in theory, I can enter new Crash records from the
portal there are too many fields and I want to display the crash_details
layout for data entry purposes.

I have tried to create a script attached to a button "Add/change crash
details". I need to check whether a related record exists and either
display the related record or prompt to create a new record.

The following script correctly creates a global variable $$crash_cd but
does not seem to recognise it in the Find Request because
Get(foundcount) is always zero.

One thought - are script variables case-sensitive?
Will I need to create a field in the vehicle_model table to store the
find value?

Michael Paine



Script by Michael Paine
New_OS_crash_record

Set Error Capture [ On ]
Set Variable [ $$TEST_CAT; Value:"OS" ]
Set Variable [ $$MODEL_CD; Value:VEHICLE_MODEL::MODEL_ID ]
Set Variable [ $$CRASH_CD; Value:$$model_cd & "/" & $$TEST_CAT ]
Enter Browse Mode
Go to Layout [ “CRASH_LINK” (CRASH_LINK) ]
Perform Find [ Specified Find Requests: Find Records; Criteria:
CRASH_LINK::CRASH_ID: "$$crash_id" ] // does not seem to work as intended
[ Restore ]
If [ Get(FoundCount)=0 ]
Show Custom Dialog [ Title: "Confirm New Crash Record"; Message: "A
crash test record does not exist for this model & test. Create new
record?[" & $$crash_cd & "]"; Buttons:
“Yes”, “No” ] // this always displays - even when a related record exists
If [ Get(LastMessageChoice)=1 ]
New Record/Request
Show All Records
Set Field [ CRASH_LINK::MODEL_ID; $$MODEL_CD ]
Set Field [ CRASH_LINK::CRASH_ID; $$crash_CD ]
Go to Layout [ “CRASH_DETAILS” (CRASH) ]
Show All Records
New Record/Request
Set Field [ CRASH::MODEL_ID; $$MODEL_CD ]
Set Field [ CRASH::CRASH_ID; $$crash_CD ]
Set Field [ CRASH::TEST_TYPE; $$TEST_CAT ]
Go to Field [ CRASH::TEST_BY ]
Exit Script [ ]
End If
Else
Go to Layout [ “CRASH_DETAILS” (CRASH) ]
Perform Find [ Specified Find Requests: Find Records; Criteria:
CRASH_LINK::CRASH_ID: “$$crash_cd” ]
[ Restore ]
Exit Script [ ]
End If

Reply With Quote
  #2  
Old   
audleman@quasika.net
 
Posts: n/a

Default Re: Checking whether a new portal record is needed - 09-19-2005 , 11:57 AM






Replace the step:

Perform Find [ Specified Find Requests: Find Records; Criteria:
CRASH_LINK::CRASH_ID: "$$crash_id" ] // does not seem to work as
intended


with

Enter Find Mode[]
SetField[CRASH_LINK::CRASH_ID; $$crash_id]
Perform Find[]

You are attempting to use the Specify Find Request dialog for the
Perform Find script step, but it doesn't work like you're thinking. It
only allows you to test against a static value that you type in, not
against a variable. To test against a variable, you have to input the
three steps as described above.

The reason the dialog always appears is that your find is invalid, thus
always returns 0 records.

Kevin


Reply With Quote
  #3  
Old   
audleman@quasika.net
 
Posts: n/a

Default Re: Checking whether a new portal record is needed - 09-19-2005 , 02:30 PM



Your problem lies in using Perform Find[Restore]

Instead you need to use

Enter Find Mode[]
SetField[CRASH_LINK::CRASH_ID: $$crash_id]
Perform Find[]

The 'Restore' function of Perform Find doesn't work the way you're
thinking. The only thing you can put in there is static text, such as
"> 5". It's basically useless, in other words.

This will solve your second problem, that of the dialog box always
coming up. Your find is invalid the way it's programmed, so you are in
fact always getting an empty found set.

Kevin


Reply With Quote
  #4  
Old   
Michael Paine
 
Posts: n/a

Default Re: Checking whether a new portal record is needed - 09-19-2005 , 03:52 PM



Excellent. Thank you Kevin. I was hoping there was a simple explanation.
Michael

audleman (AT) quasika (DOT) net wrote:

Quote:
Your problem lies in using Perform Find[Restore]

Instead you need to use

Enter Find Mode[]
SetField[CRASH_LINK::CRASH_ID: $$crash_id]
Perform Find[]

The 'Restore' function of Perform Find doesn't work the way you're
thinking. The only thing you can put in there is static text, such as
"> 5". It's basically useless, in other words.

This will solve your second problem, that of the dialog box always
coming up. Your find is invalid the way it's programmed, so you are in
fact always getting an empty found set.

Kevin


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.