I encountered something peculiar and I was wondering how/why this is the case.
When I build a JSON document, I am able to fetch a number parameter, and parse that to a string.
When I however try to do the same with a text parameter, and try to parse that to a string, I get an error. See below:
Also seems related to this old community thread. In some sense I get the error 'undeclared variable' (since in XQuery the '$' is used for variables), but it seems odd that this error does occur for a text parameter and not for a number parameter, and I was wondering how that is possible.
Of course there are easy solutions. I generally try to enclose user parameters in double quotes in these situations, like e.g.
{
"key": "$(IN_Text)"
}
In that case, (data type parsing) functions also can be used, like e.g.
{
"key": xs:string("$(IN_Text)")
}
But in this case that's a bit of a redundant example, as without that data type parsing function, the parameter is already inserted as a string.
Just as a caution to other users, similar to the XQuery function 'get-attribute("")' (that's automatically used when you double click on an attribute from the menu), there is also the XQuery function 'fme:parameter-value("")'. but this one has an active issue that it is not aware of the context in which it is used. More particulary, when used in a custom transformer, the 'fme:parameter-value("")' function doesn't work correctly (C662869, FMEENGINE-70950).
Then of course there is also the easy option of converting the parameters to attributes with e.g. a ParameterFetcher, but although effective, I think it's not such a clean solution (as you already have the information as a parameter). Also, in case you have one execution of a Custom Transformer, and within it you end up with many more features/records, it always seems a bit inefficient to me to spread out this constant parameter value over all of your features/records.
So long story short, I would advise to use the double quotes workaround in the meantime ;)