# Youseful Software - FileMaker sample script # Script name: Youseful - JavaScript totals # Plug-in: YsflJS.fmx64 (Windows x64) # Setup: No fields or Node.js installation needed. This uses embedded JavaScript and passes JSON separately through fm.param. # Expected: [{"sku":"A1","total":30},{"sku":"B2","total":7}] (JSON formatting may differ). # Format: UTF-8 Script Workspace step listing. Add the steps manually; this is not an importable FileMaker file. # Lines beginning with # are notes; optionally add them as Comment steps. # Preserve calculation quotes, backslashes, and paragraph symbols exactly. Set Variable [ $rows ; Value: "[{\"sku\":\"A1\",\"qty\":3,\"price\":10},{\"sku\":\"B2\",\"qty\":1,\"price\":7}]" ] Set Variable [ $json ; Value: YsflJs_Run ( "JSON.parse(fm.param).map(row => ({sku: row.sku, total: row.qty * row.price}))" ; "mode=inproc timeout=15¶param=" & $rows ) ] Set Variable [ $error ; Value: YsflJs_LastError ] If [ $error <> 0 ] Set Variable [ $detail ; Value: YsflJs_Error ] Show Custom Dialog [ "JavaScript failed" ; $detail ] Exit Script [ Text Result: $json ] End If Show Custom Dialog [ "Line totals" ; JSONFormatElements ( $json ) ]