May 28, 201411 yr Hi. I have a field with a script trigger that passes 2 parameters to a script; 1) the name of a related table (as literal text), and 2) a field's object name. I use this script for different fields on different layouts and have so far been using "If" statements to decide what to do, e.g.: If [Get ( ActiveModifierKeys ) = 16] If [$relatedTable = "People » Projects"] Go to Related Record [ From table…etc.] Else If [$relatedTable = "Company » Projects"] Go to Related Record [ From table…etc.] etc. End If End If This all works fine, but obviously breaks if I change the TO name. I know I can pass the field as an actual field name (not literal text), but once it's in my script, how can I use that without testing using literal text? It seems I have to go through the "If" tests, and if that's true I'm not sure how to incorporate GetFieldName or something similar to go to the correct related table and layout. Thanks for any help with this. Michael
May 28, 201411 yr You could make this generic by not using a Go to Related Record script step, but going to a layout based on the target TO and doing an find. It will require a strict naming convention where you would prefix layouts with the TO name so that you can construct the desired layout name easily. In this scenario you would pass a field reference into your script and use the RelationInfo() function to find out what fields you need to use to make a find that mimics a GTRR call.
May 28, 201411 yr Author Thanks, Wim. I do use that naming convention on my layouts, so this looks perfect. Much appreciated.
Create an account or sign in to comment