I was able to track down an example in a procedure (xactMonSet from pathfinder).
Code:
~if we need to select from the list of factions, provide an initial
~selection of the first one that has non-zero prestige to spend
if (empty(hero.transact.field[xactFixFac].text) <> 0) then
var factexpr as string
factexpr = "(" & hero.transact.field[xactFacLis].text & ") & (fieldval:facCPA > 0)"
if (hero.haschild[BaseFact,factexpr] <> 0) then
perform hero.transact.field[xactFact].setchosen[BaseFact,factexpr,hero]
endif
endif
One thing to note is that the script has to be trusted to be able to change any user field (which all menu-style fields are), otherwise you will sometimes get strange compilation errors. Certain types of scripts are trusted by default (like creation scripts), and otherwise you will need to use a trustme statement.