January 20, 200620 yr I am trying to simplify by automating this task. I have a field that says "staff name". I also have a field that says "staff email". I did a script that will insert a email if "staff name" is selected, but I have to somehow make the script execute. Can someone tell me how to make it auto execute the script when I select "staff name"? -OR- Give me a better solution to make this happen? Thanks everyone! Love this forum!
January 20, 200620 yr Make your StaffEmail an autoenter calc with replace existing value turned ON. Evaluate(Quote( Let([ a = StaffName]; Case( a = "john doe"; "[email protected]"; a = "Jane Doe"; "[email protected]"; ect...))); StaffName) What this will do is evalueate the auto enter calc every time Staff Name changes.
January 20, 200620 yr Author WOW! Very nice! You just made the first 6 months of this year!!! THANK YOU SIR!
January 20, 200620 yr Hey Zero, I'm curious why you wouldn't simply use the Let() statement without the Evaluate(Quote(...)) and have it replace the contents, like this: Let( a = StaffName; Case( a = "john doe"; "[email protected]"; a = "Jane Doe"; "[email protected]") ) They do evaluate a little differently, where using the Evaluate(Quote(...)) does not replace the existing Email if there's no match in the Let(), but is this desired behavior? See the sample. I don't want to rain on Cal's parade, but it seems like Email would be an attribute (field) in a Staff table. It would be structurally better then, to simply reference the related Email field whenever you need to see the email address for a selected staff name. It's not a good practice to hard-code all the staff email addresses in a case statement as suggested. EvaluateTest.fp7.zip
January 25, 200620 yr Sorry for taking so long to reply here. Yes, Idealy email would be a related field and would auto lookup in the first place. By now ( a few days later) I have no idea why I didn't just tell them that, as I dislike to hardcode anything that might ever change. I've had funny results just using Calc fields before for things like this ender, although they were probably due to faulty programming on my part, I've grown fond of the evaluate function and often use it where it isn't nessecarily needed. Anywho, Cal, ender is right, doing it the way I originaly showed you is a bad idea. Create another field in your staff table that contains thier email, that way you don't have to update your code everytime a new staff person is added to the database.
Create an account or sign in to comment