Try something like the following, which should give you the selected text in the field, which you can then use in the script
Set Variable [ $selection ; Middle( Table::Field ; Get ( ActiveSelectionStart ) ; Get ( ActiveSelectionSize )) ]
You can then Set the appropriate related field using Set field [ related::field ; $selection ]
There may be other ways, but this one came to me first.
Hey, thanks so much for responding. Well, I have made a workaround by just doing two super-simple buttons in the layout. One copies selected text to clipboard, the other pastes to the designated field. I tired using the snippet you sent which I couldn't get working. FM kept telling me that it couldn't find my table (I substituted my table and field names in for the placeholder you sent). Looks like my two-button solution is going to be more flexible anyhow.
What version of filemaker are you using? The above example by SWS should work for you.
A minor detail that I often leave out myself is that it should really look like this, when you view it in manage scripts:
Set Variable [ $selection ; Value: Middle( Table::Field ; Get ( ActiveSelectionStart ) ; Get ( ActiveSelectionSize )) ]
(Value: is added by filemaker, you don't type it in.)
If you add Table::Field to your expression by finding it in the field list and double-clicking it to add it to your expression, you shouldn't see this error message.
Using copy and paste in any script is usually the less ideal approach as it replaces any text the user may have previously copied to the clipboard with the selected text and this can irritate/inconvenience your users.