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

Create record if not found in related table


Recommended Posts

Good day, hoping a guru can guide me;

i am sure is something simple but don’t seem to be able to figure out how to do it. 

Have two tables 

1- assets

2- vendor

I have a field “VendotName” in the asset table, I am trying to create a script that triggers on exit;

 check if vendor exist in vendor table, if vendor does not exist display a message asking if the users want to create the new vendor in the vendor table, if yes create new vendor and move to next field 

is vendor exist simple move to next field in the asset table 

Any help is appreciated 


Link to comment
Share on other sites

How is the user choosing a VendorName?  Is it a text field?  Does it have a dropdown value list?  Will they be typing in a Vendor name freehand if it doesn't appear in the value list?  You sure you want to run a triggered script that executes a check even though the user is going to be quite aware of whether or not they had to manually type in a new name from scratch or instead were able to pick the vendor from the dropdown list?


I wouldn't do the script trigger, myself.  But that doesn't make it wrong.  If it were me, I'd have a small "+" button next to the Vendor Name dropdown and it would be for adding a vendor not already in the system.  


The script logic for doing it your way is simple enough though.  Either there's a related record in Vendors (by Assets::VendorName = Vendor::VendorName presumably) or there's not:


If [ Length (Vendors::VendorName)>0]

..Exit Script

End If

Set Variable [$NewVendorName; Assets::VendorName]

New Window

New Record/Request

Set Field [Vendors::VendorName; $NewVendorName]

# Comment: Pause here if you want them to fill out address and phone and email and whatnot

Close Window


One reason I'd use the button approach instead of script trigger is that I think script triggers should be reserved for situations where nothing else will do the trick conveniently.  They can be a real clown car of a feature when you've got a solution with a lot of the damn things sprinkled all around, to the point that you have to have the script debugger on fulltime to keep focus from being yanked out from under you.  But that's strictly in the "your mileage may vary" pile, I suppose.

The other reason is that I would want the relationship to be Assets::VendorID=Vendor::VendorID with an auto-enter serial in Vendor anchoring it.  That means you should first create the Vendor record (for a new Vendor) and then pick it.  Not enter it and then push it over to Vendors.  Why VendorID?  Because I prefer the primary key to be a value that is meaningless outside of FileMaker, so there's never a day when it is deemed to be "wrong" ("oops, whoever typed in this one made a typo, this value is wrong!") and there's never a day when it needs to be changed ("Greetings Valued Customers, today Zeedo is changing its name to Greedo, but we'll continue providing the great service you're used to...").




Link to comment
Share on other sites


  • Create New...

Important Information

Terms of Use