haani Posted November 7, 2013 Posted November 7, 2013 Hi, I am working on a database and I have just found a problem with it that I can't seem to fix, as you can see from the image, I have added a portal row to a layout which includes check boxes and I have a send email button at the bottom which runs the following script: Set Field [ Case::chk box; 1 ] Go to Layout [ âQuote Viewâ (Consultant) ] Set Variable [ $FilePath; Value: Get ( TemporaryPath ) & "Quote " & Case::Case Number & ".pdf" ] Save Records as PDF [ File Name: âfile:$FilePathâ; Current record ] Send Mail [ Send via E-mail Client; To: Case::Solicitor's Email; Subject: "New Quote: " & Case::Case Number & " "; Message: "Dear " & Case::Company Name & "¶¶" & "Please find the Quote attached "; Attachment: âfile:$FilePathâ ] Go to Layout [ âConsultantâ (Consultant) ] now the issue is that if I select any checkbox, always the first row on the portal row is selected and then the email is sent, is there anyway I can modify the script to make it select the row where the check box is selected, I searched around and thought maybe set field would fix it, but it didn't, any help would be greatly appreciated! sorry posted this is the wrong thread, this was meant to go in managing scripts thread! Attached Thumbnails
No_access Posted November 7, 2013 Posted November 7, 2013 You could use a loop, something like this. go to portal row(select;first) loop if checkbox ="" Save Records as PDF [ File Name: “file:$FilePath”; Current record ] - "APPEND" end if go to portal row(Select;Next;Exit after last) end loop
LaRetta Posted November 7, 2013 Posted November 7, 2013 Hi Haani, We are missing perspective here. What is the table occurrence name of the portal - Case? What is the table occurrence name of the current layout - Consultant? You check your checkbox in the portal but then you simply go to the other layout but you do not take the Case Number from that portal with you. From the Consultant layout looking to the related Cases table, it would seem that it is a one-to-many relationship (guessing here since we do not yet have details on your setup but based upon it being a portal). If so, when you switch to a Consultant layout, you will only ever see the FIRST related Case when looking through to that relationship. To take the current Case Number with you, set it as a script parameter. However, you need additional Case information for the email and it appears you are gathering it from the Consultant layout. Either gather all of the case information before you leave that portal row (for setting in the email) or go to a layout based upon that Case record first and gather the additional information from that Case record. Check out the Go To Related Record[] script step to do that. The email should be generated from the Case table, I believe. In FileMaker, everything is perspective. perspective is everything.
haani Posted November 7, 2013 Author Posted November 7, 2013 thanks for your help guys, but I have tried No_Access loop script and it doesn't still it selects only the first row, heres my amended script go to portal row(select;first) loop if Case::chk box = "" Go to Layout [ “Quote View” (Consultant) ]Set Variable [ $FilePath; Value: Get ( TemporaryPath ) & "Quote " & Case::Case Number & ".pdf" ]Save Records as PDF [ Restore; Append; No Dialog; “$FilePath”; Current record ]Send Mail [ Send via E-mail Client; To: Case::Solicitor's Email; Subject: "New Quote: " & Case::Case Number & " "; Message: "Dear " & Case::Company Name & "¶¶" & "Please find the Quote attached "; Attachment: “file:$FilePath” ]Go to Layout [ “Consultant” (Consultant) ] end if go to portal row(Select;Next;Exit after last) end loop as Laretta said here are my table instances name for consultant its "Consultant" and for case its "Case" the relationship is not one to many its one to one, I have tried setting the parameter to Casenumber and tired the go to related record function in the script and it still doesn't work. just to let you know checkbox has a custom value list of "1" to make it boolean. would it help if I posted my entire database?
LaRetta Posted November 7, 2013 Posted November 7, 2013 If you have a portal of values then Case *IS* the many side to the single parent record you are viewing in Consultant. Yes, please zip and attach your file. :-)
haani Posted November 7, 2013 Author Posted November 7, 2013 thanks laretta heres my database, quote attach pdf is the script I have been playing around with, thanks again. just so you are aware when u open the database there is an onopen script that runs, its just a reminder script, it will alert of two reminders one after 3 secs and another after 20 secs. check ur pm for the database thanks
LaRetta Posted November 7, 2013 Posted November 7, 2013 haani, on 06 Nov 2013 - 7:23 PM, said: â¨is there anyway I can modify the script to make it select the row where the check box is selected  Make the checkbox a button so the script knows the specific Case you wish to send.  But if all that checkbox will do is run a script, why have a checkbox at all?  Do you wish to record that a quote was sent on that case?  If so, you might wish to save the date sent instead of a single checkmark. â¨You are basing your relationship from Consultants to Cases upon name which is major problem. Switch to using proper keys in ALL your tables before you move any further with your solution.  If you do not, you will have major problems.  Guaranteed.   Your Quote should be based upon the LINES (in this instance it is your Cases table).  You then place the ONE side (Consultants) on the body.  Look at this standard Invoices example by Comment to see how to set up the keys  http://fmforums.com/forum/topic/63425-auto-fill-one-field-with-text-from-two-fields/#entry300150.  It also shows how to put the 'invoice print' in the lineitems table.  So your Quote is the Invoice and your Case is the LineItems.  If there are several checkboxes checked, do you want to sent the email to all that are checked at once or send the email one at a time only when checked?  If several at once, what would determine which were checked on a prior request or which might be checked THIS time?  And can different Users of your solution send different emails for the same Case?  I am afraid I have more questions than answers at this point except this simple test to try:  If you simply want to go to details about a (single) Case, assuming you have corrected a quote to be based upon Case as it should (per the attached Invoices example), you can attach a button in the portal row with a single button specified as this (screen shot). This shows you how you can isolate this single Case record.  Copy your Quote in Consultants and paste it in Case. It should work the same since it is based upon the same table occurrence group. So your GTRR will isolate the Case record clicked in the portal. Then printing the SINGLE RECORD will do it. Once you play with GTRR to understand how it works, you can incorporate it into your email script.  I know I gave you quite a bit. The most important is getting your relationships corrected according to Invoices example.Â
LaRetta Posted November 7, 2013 Posted November 7, 2013 (edited) Note that I do NOT have anything checked below in the GTRR. It will produce a found set of ALL Cases() which are related but it will LAND on the Case() the button is fired from (which is why your email will be based upon the current record only). I hope that made sense. I decided to attach your modified file only showing the GTRR attached to the checkbox. You would have to include your other steps, change to Quote to being based upon Case and most importantly, correct your relational keys. :-) If you wish to send emails to all Cases which are checked (and it does not interfere being multi-user) then you would simply GTRR and then constrain your found set down to only checked Case records. My copy of the file has been removed per OP request. Edited November 8, 2013 by LaRetta
LaRetta Posted November 7, 2013 Posted November 7, 2013 Found it. Here is what everyone new to relational design should be familiar with filemaker_solution_architectures_en.pdf
haani Posted November 8, 2013 Author Posted November 8, 2013 thanks for all your help but all I want is if one checkbox is checked then only that case is emailed to the client, I will look into getting my relationship right.
Recommended Posts
This topic is 4032 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now