Which trigger are you using?
Is this field formatted as a pop-up menu?
Please post the script.
I've used script triggers in portals and they work on all rows of the portal so we need to figure out why it didn't work for you.
Ah, good point. The field is formatted as a Drop-down List, and it uses a Value list. The source for the value list is "from another file", namely the value list in the related database.
Here's the script:
If [ Elements05::Item Status = "user_name1" ]
Send Mail [ Send via E-mail Client; To: "email@example.com"; Subject: Elements05::Job # & "." & Elements05::Item # & " has been assigned to you."; Message: Elements05::Job # & "." & Elements05::Item # & " has been assigned to you." ] [ No dialog ]
Else If [ Elements05::Item Status = "user_name2" ]
Send Mail [ Send via E-mail Client; To: "firstname.lastname@example.org"; Subject: Elements05::Job # & "." & Elements05::Item # & " is back for re-work."; Message: Elements05::Job # & "." & Elements05::Item # & " is back for re-work." ] [ No dialog ]
One observation, with OnObjectModify, if you type in your drop down's field, this trigger will fire with each and every key stroke. That's why this can be a better trigger for a pop-up menu. For drop downs, OnObjectExit may give you more predictable results.
Is Elements05 the table occurrence your portal is based on? (Did you select Elements05 in the show records from box in portal set up?)
This is a case where filemaker advanced saves a lot of frustration. IF you had that version, I'd suggest enabling the script debugger and watching it execute when you edit the field. This would very likely pinpoint for you where your script is going wrong.
Since you don't, you may have to modify your script to investigate further. You could put Show Custom Dialog [Quote ( Elements05::Status )] at the start of this script as a test. Then edit the field in different rows of your portal and see what pop's up in the custom dialog. The quote function will enclose the field's contents in quotation marks which can make it easier to spot invisible characters such as a space or carriage return that might be affecting your script's behavior.
I tried OnObjectExit first, but it was generating two emails each time I changed a status, instead of one. OnObjectModify seemed to fix that. I wondered if it was generating two emails because there were two exits - exiting the field and exiting the portal. I dunno. Yes, Elements05 is the related database it's pulling the information from.
You could put Show Custom Dialog [Quote ( Elements05::Status )] at the start of this script as a test.
I did that, and when I change the status of any record other than record #1, that dialog box shows the status to be the same as record #1, no matter what it is. it's like the script thinks all the records are the first record.
Which explains why this is happening--at least it rules out the script trigger as the issue.
Is the field you've set the trigger on really from Elements05 and not some other table occurrence? Double click it while in layout mode and check.
Ah, it looks like it's another... occurance? Sorry, I didn't build this database. It was built a long time ago, and I sort of inherited it when I started working here, and I've been trying to learn Filemaker along the way. :D
Here's what the portal is pulling records from: Elements05 is the name of the database, but the portal is set to show records from Elements05 2 which appears to be another occurance, set up with a relationship to Elements05 via one of the fields. So I don't know why the portal is pulling from the second occurance and not the main table, but this is a big complicated database and I don't understand Filemaker well enough to understand how it all works together.
I am scared to change the portal so it pulls from the main table because I don't know what effect that would have on the data, and this is a critical database, all our work is done in it.
Don't change your portal. Change your script to reference values from Elements05 2 instead of Elements05 as it does now.
If you search Manage | Database | Relationships carefully, you should find that you have a table occurrence labeled Elements05 and another labeled Elements 05 2. Each potentially defines a different relationship by linking different table occurrences or by using different pairs of match fields. Analyzing the diffeerences here may help you better understand how the database works.
That was it, I feel like an idiot, and thank you. :smileyvery-happy: