Keith John Hutchison
Keith John Hutchison

Reputation: 5277

How to go to the correct filemaker layout given a layout id?

A FileMaker snapshot file has a layout id. However, using the go to layout number does not work as I had expected.

Set Variable [$json; Value:Get(ScriptParameter)]
Set Variable [$layout_id; Value:JSONGetElement ( $json ; "UIState.Layout.@id" )]
Go to Layout [$layout_id] // layout number by calculation 
// ends up on a completely different layout than the one the snapshot file opens.

I've discovered that the layout id and layout number are two different numbers ... which is why the go-to layout number script step failed.

The JSON string used as a parameter for the above script is.

{
    "UIState": {
        "UniversalPathList": "fmnet:/10.1.1.63/Balanced.fmp12\nfmnet:/10.1.1.220/Balanced.fmp12\nfmnet:/169.254.254.47/Balanced.fmp12\nfilemac:/Macintosh HD/source/fmp16/Balanced.fmp12",
        "Rows": {
            "@rowCount": "1",
            "@baseTableId": "131",
            "#text": "21383239"
        },
        "Layout": {
            "@id": "2"
        },
        "View": [

        ],
        "SelectedRow": {
            "@id": "21383239"
        },
        "StatusToolbar": {
            "@visible": "True"
        },
        "Mode": {
            "@value": "browseMode"
        },
        "SortList": {
            "@Maintain": "True",
            "@value": "False"
        }
    }
}

Which can be run from the command line. Example

open 'fmp://filemaker.server/Balanced.fmp12?script=snapshot_link&param={ "UIState": { "UniversalPathList": "fmnet:/10.1.1.63/Balanced.fmp12\nfmnet:/10.1.1.220/Balanced.fmp12\nfmnet:/169.254.254.47/Balanced.fmp12\nfilemac:/Macintosh HD/source/fmp16/Balanced.fmp12", "Rows": { "@rowCount": "1", "@baseTableId": "131", "#text": "21383239" }, "Layout": { "@id": "2" }, "View": [], "SelectedRow": { "@id": "21383239" }, "StatusToolbar": { "@visible": "True" }, "Mode": { "@value": "browseMode" }, "SortList": { "@Maintain": "True", "@value": "False" } } }'

What would be a good way to find the right layout to display in FileMaker given a valid layout id?

Upvotes: 0

Views: 323

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 116982

I believe you can calculate the layout number by finding the index number of a given layout ID in the list returned by the LayoutIDs function, say =

Let ( 
listOfIDs = LayoutIDs ( "" ) 
;
ValueCount ( Left ( listOfIDs ; Position ( ¶ & listOfIDs & ¶ ; ¶ & $layout_ID & ¶ ; 1 ; 1 ) ) )
)

Upvotes: 1

Related Questions