Help with Carafe.Fm charts

I need some help getting charts to work with Carafe.FM. I am working on C3 Donut v2.1.3 now but I have tried others in the past and I am just not getting it.

I can hard code the data but I should be able to use JSONSetElement and I am not sure what I am doing wrong. I think I need to set it as an array? But I am not sure how to do that in JSON.

below is what I am passing as a script parameter.

JSONFormatElements ( 
   JSONSetElement ( $$JSON ; 

	[ "carafeWebViewerObjectName" ; "CustomerIncomePercent" ; "JSONString"]
;	[ "Total" ; $Total; "JSONString"]
;	[ "InContract" ; $Incontract ; "JSONString"]
;	[ "Potential" ; $Potential; "JSONString"]
;	[ "Unlikely" ; $Unlikely; "JSONString"]


   )
)

/*
Format instructions
JSONSetElement( $parameter ; [ "carafeWebViewerObjectName" ; "CustomerIncomePercent" ; JSONString ] ; [ "jsonData" ; $jsonData ; JSONString ])

Sample
{"chartData":[["PO","150000.00"],["PO Remaining","100000.00"],["PO Utilized","50000.00"]]}

*/

One thing that jumped out at my eye as soon as I saw the example above is that it has "JSONString" in quotes.

The JSON data-type constants (such as: JSONString, JSONNumber, JSONObject, etc.) are actual reserved words in the FileMaker calculation syntax which evaluate to constant values identifying the type. As such, they are not (should not) be quoted.

So, rather than having something like:

JSONSetElement( "Potential" ; $Potential; "JSONString" )

The proper usage is:

JSONSetElement( "Potential" ; $Potential; JSONString )

It may seem like a subtle difference, but it is important. I do not know if this is the underlying cause of the issue that the above post covers, but even if it is not, being aware of how to use the JSON data-type constants will eventually dodge other potential mishaps.

Hope this helps.

Thanks for the help. It did not make it work but as you said it is good to know and will likely help in the future.

1 Like