I am trying to create a very simple app to enable a 1-click “pickup” option when reading a ticket. I’d like to create a button that an agent can click to pick up a ticket. I understand it’s very easy to pick up tickets already, I’m just trying to see if I can make it marginally easier.
The button here works, to retrieve the user_id of the logged in user, but when I attempt to use client.interface.trigger(“SetValue”, {id: “agent”,value: user_id }) it doesn’t work, and I get the “uncaught TypeError” seen in the title. There must be something I don’t understand about how to use interface methods.
My code currently is this:
document.onreadystatechange = function() {
if (document.readyState === 'interactive') renderApp();
function renderApp() {
var onInit = app.initialized();
onInit
.then(function getClient(_client) {
window.client = _client;
client.events.on('app.activated', assignAgent);
})
.catch(handleErr);
}
};
function assignAgent() {
client.data
.get('loggedInUser')
.then(function(payload) {
console.log(`Current user_id: ${payload.loggedInUser.user_id}`);
client.interface.trigger("SetValue", {id: "agent",value: `${payload.loggedInUser.user_id}` });
})
.catch(handleErr);
}
The console.log does output the correct user_id, I just cannot set the agent value to user_id.
Sorry if these are stupid questions, I am quite new to this.