Returning a function from a query

I have the following query

const myFunction = () => {
      return "returning from myFunction";
    };
return myFunction;

Is anyway to call this query from another query and still get the returning data of myFunction?

I have tried to trigger it in a normal way but I get the following error.

failed {"name":"QueryRunError","errorData":"Could not clone result","trigger":"NATURAL_FAILURE","displayOptions":{"hideToast":false}}
1 Like

I found a way and using parameters,

code for query1:

const myFunction = (param1) => {
      return "Hello " + param1;
    };
    
return myFunction(name);

calling myFunction from query2

query1.trigger({
    additionalScope : { name: "Tommy" },
    onSuccess: function (data) {
    console.log("success", data);
  },
  onFailure: function (error) {
    console.log("failed", error);
  }
})
2 Likes