Hi there,
This is one for the experienced plugin builders I guess. I am creating a Server Side Action (SSA) that calls a script that does some advanced financials calculations. The same script is used in the frontend and works perfectly. I was hoping to be able to use it as is in the backend but I found that I need to rewrite all functions to be async. Not a big issues, however, I don’t seem to be able to get to the properties of objects any more in the same way as I do in the frontend.
See the snippet below:
async function generateProfitAndLossForYearAsync(idea, year) {
const financials = await idea.get(IDEA_FINANCIALS_FIELDNAME);
//Get revenue streams
let revenueStreams = await financials.get(FINANCIALS_REVENUESTREAMS_FIELDNAME);
revenueStreams = revenueStreams ? await revenueStreams.get(0, revenueStreams.length()) : [];
…
The idea.get seems to return a fully formed financials object, which has, among other things, a list of revenue streams. However, the next call, to get the revenue streams, always returns null. The same setup (although not async) at the client side works without any problems.
Any idea what I am doing wrong?