I am trying to dynamically populate a multiselect in the installation parameters. The first step, I believe, would be to get the domainName so I can make API calls, but client.data.get(“domainName”) returns the error “Error: Cannot read properties of undefined (reading ‘get’)”. What am I doing wrong here?
Note: since I don’t know the event name equivalent to “onLoad”, I’m temporarily firing the JS on “change”.
iparams.json:
“authorized_roles”: {
“display_name”: “Authorized roles”,
“description”: “Please select the agent roles authorized to submit solutions articles”,
“type”: “multiselect”,
“required”: true,
“default_value”: “Admin”,
“options”: [“Admin”, “Knowledgebase Manager”],
“events”: [
{“change”: “getAuthorizedRoles”}
]
}
iparams.js:
var clientAPP = null;
document.addEventListener(“DOMContentLoaded”, function () {
app.initialized()
.then(initAPP)
});
initAPP = function (_client) {
clientAPP = _client;
};
async function getAuthorizedRoles(clientAPP) {
var authorized_roles = new Promise(function (response) {
try {
var domainName = clientAPP.data.get("domainName");
return domainName;
} catch (err) {
alert("Error: " + err.message); //Returns "Error: Cannot read properties of undefined (reading 'get')"
}
})
.then(function (domainName) {
alert("DomainName" + domainName);
})