AnsweredAssumed Answered

web direct GetLayoutObjectAttribute crash when called from script/function

Question asked by ThomasMyers on Oct 11, 2017
Latest reply on Feb 6, 2018 by TSGal

WARNING: This WILL crash your web direct!

 

Here is a script I wrote to return the currently selected object within a button bar.  You pass in the name of the button bar then it returns the name of the button that is selected.  I call this script when a user clicks a different button on the layout (not the button bar).  This allows me to know what to do based on what button bar is currently selected.  It works great in client.   I am running on FMP 16.03, hosted on FMS 16.0.3.

 

--------- Here is a short test showing the issue.

Call this from a button on a layout that has a button bar named "StaffDetailsButtonBar" that also has all the buttons named.

 

Set Variable [ $EnclosingObjectName; Value:"StaffDetailsButtonBar" ]
Set Variable [ $index; Value:1 ]
Set Variable [ $ObjectList; Value:GetLayoutObjectAttribute ( $EnclosingObjectName ; "containedObjects" ) ] Set Variable [ $ListSize; Value:ValueCount ( $ObjectList ) ]

Set Variable [ $TestValue; Value:GetValue ( $ObjectList; $index ) ]

Show Custom Dialog [ Message: $TestValue; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ] Set Variable [ $Result;

 

// Next line will crash in WEB Direct only

Value:GetLayoutObjectAttribute ( $TestValue ; "isActive" ) ]
Show Custom Dialog [ Message: $Result; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
Exit Script [ Result: $Result ]

 

------------------------

Full script that works great in FMP Client (also I have a recursive function that also works in client, but not web direct)

 

Call:  GetSelectedObjectName( "StaffDetailsButtonBar")

 

Script

 

Set Variable [ $EnclosingObjectName; Value:GetValue(Get(ScriptParameter);1) ]
Set Variable [
$index; Value:1 ]
Set Variable [
$ObjectList; Value:GetLayoutObjectAttribute ( $EnclosingObjectName ; "containedObjects" ) ] Set Variable [ $ListSize; Value:ValueCount ( $ObjectList ) ]

Loop

Set Variable [ $TestValue; Value:GetValue ( $ObjectList; $index ) ]

Set Variable [ $Result; Value: Case(
IsEmpty ( $EnclosingObjectName ); "Missing EnclosingObjectName"; GetLayoutObjectAttribute ( $TestValue ; "isActive" ); $TestValue; $index ≥ $ListSize; "Not Found";
"Try Again"

)]

Exit Loop If [ Case(
$Result = "Not Found"; 1; $Result ≠ "try again"; 1

)]
Set Variable [
$index; Value:$index + 1 ]

End Loop
Exit Script
[ Result: $Result ]

Outcomes