I use a custom function named "cf CorrectContext." It has one parameter, getFieldNameX.
Internally it contains this code:
/*
Given a fully qualified field name, return true if the field matches the current layout table name
*/
Let (
parts = Substitute ( getFieldNamex ; "::" ; ¶ ) ;
GetValue ( parts ; 1 ) = Get(LayoutTableName)
)
This allows me to use the function in script steps and other calculations:
If [ cf correctContext ( GetFieldName ( field-ref ) ) ]
// code here
End if