My goal: I have an API query (“getDeviceDetails“) which returns a device, something like: {id: 5, description: "Mobile device", typeId: 1 }
Then I have a second API query (“getWorkOrderType“) which returns a dictionary of definitions for the ids in the first query (something like [{value: 1, label: “Samsung“}, {value: 2, label: “Apple“}] ).
I want to transform the first query to something like: {id: 5, description: "Mobile device", type: {value: 1, label: "Samsung"}}
Issue: I go to the devices query’s transformer and try to map accessing getWorkOrderType.data.find(...), but I receive an error: “getWorkOrderType is not defined”. I can access getWorkOrderType output data from other parts of my code normally (in Select boxes, etc), but not from this query transformer.
One way to make sure the data in getWorkOrderType is defined and accessible would be to save this data to a variable.
Do you expect the data of this variable to change often or do you believe it will be static? If dynamic, we can set the variable in the success handler of the query run. If not dynamic we can hard-code the device values.
As to why the linter is telling you that getWorkOrderType is undefined, I am not quite sure, one guess was that the getWorkOrderType had not run yet in your current editing session and therefore the query's state is empty and thus not defined.
This linting warning may just be a quirk of viewing the Transformer in editor mode, were you able to test the app live, in a situation where getWorkOrderType runs and then the second query runs?
Or you could try in the editor, running the queries in order to see if the transformer works despite the linting warning.