Update Custom App to Platform version 2.2

We’ve been using a Custom App which needs updating to Platform version 2.2 (from version 2.1).

I followed the Changes for our Platform version 2.1 apps which meant changing the value of "platform-version" in manifest.json in app root directory to "2.2"

The SMI function has already been registered in the same file. However, when testing locally using fdk run and appending "dev=true" at the end of the ticket URL, the app says “Something went wrong…” with no other info. Have setup the Client Name and Data Feed URL at localhost.../custom_configs

Original manifest.json

{
  "platform-version": "2.1",
  "product": {
    "freshservice": {
      "location": {
        "ticket_sidebar": {
          "url": "index.html",
          "icon": "styles/images/icon.png"
        }
      }
    }
  },
  "dependencies": {
    "axios": "0.21.0"
  },
  "engines": {
    "node": "14.17.5",
    "fdk": "8.6.1"
  }
}

Here, updated 2.1 to 2.2

In server.js, I have 1 function that’s exported. The docs say to remove event registrations but if I remove that we get a 404 error

Any help greatly appreciated!

Hi @JoannaWright, have you added the "functions" property in manifest.json under product.freshservice to declare the SMI functions?

Hey Kaustav, I’ve added the "functions" property now. I have one function in server.js -

exports = {
  getX: getXFunction
};

Is this what wants defining in manifest.json? I have tried the below

{
  "platform-version": "2.2",
  "product": {
    "freshservice": {
      "location": {
        "ticket_sidebar": {
          "url": "index.html",
          "icon": "styles/images/icon.png"
        }
      },
	  "functions": {
		  "getX": {
			  "timeout": 10
		  }
	  }
    }
  },
  "dependencies": {
    "axios": "0.21.0"
  },
  "whitelisted-domains": [],
  "engines": {
    "node": "14.17.5",
    "fdk": "8.6.1"
  }
}

And the app cannot start with the following error in the console: [ERROR] Function getX is not defined for product freshservice

@JoannaWright This is weird. I tested and found that I get this error when I pass a function by reference in the exports block. If I define the function in the exports block, it works.

For example, the following code produces the error
[ERROR] Function getX is not defined for product freshservice:

function getXFunction(payload) {
  console.log(payload);
  renderData(null, payload);
}

exports = {
  getX: getXFunction,
};

But, defining the function inside the exports block works:

exports = {
  getX: function (payload) {
    console.log(payload);
    renderData(null, payload);
  },
};

While I try to figure out why this happens, can you try moving the function definition inside the exports block?

@Developer-Platform any idea why this is the expected behaviour for defining SMI functions?

@kaustavdm The custom app works if I define the function in the exports block as you advised which is, yeah, weird!

Thanks so much for the help :slight_smile: It would be interesting to see why it behaves this way

I learnt that it will take some moderate changes to the parser logic that feeds into validate and is something the team looks forward to addressing in the future.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.