Búsquedas recientes
No hay búsquedas recientes

Corentin BERTEAU
Incorporación 23 may 2023
·
Última actividad 20 nov 2023
Seguimientos
0
Seguidores
0
Actividad total
9
Voto
1
Suscripciones
3
RESUMEN DE LA ACTIVIDAD
INSIGNIAS
ARTÍCULOS
PUBLICACIONES
COMENTARIOS DE LA COMUNIDAD
COMENTARIOS DE ARTÍCULOS
RESUMEN DE LA ACTIVIDAD
Última actividad de Corentin BERTEAU
Corentin BERTEAU hizo un comentario,
Ok my bad.
function requestCommentsTicket(client, id) {
var settings = {
url: '/api/v2/tickets/' + id + '/comments',
type:'GET',
dataType: 'json',
};
client.request(settings).then(
function(data) {
console.log('request result', data)
},
function(response) {
console.log('request result', response)
}
);
}
Ver comentario · Editado 20 nov 2023 · Corentin BERTEAU
0
Seguidores
1
Voto
0
Comentarios
Corentin BERTEAU creó una publicación,
Hello, I am currently facing difficulties retrieving the latest public comment, and I have not found a solution in the documentation to identify whether a comment is public or not:
The client.get(ticket.comments)
route retrieves all comments from ticket, but it does not retrieve the boolean parameter 'public' for comments.
Publicado 20 nov 2023 · Corentin BERTEAU
0
Seguidores
2
Votos
2
Comentarios
Corentin BERTEAU hizo un comentario,
Hi,
Thanks for sharing this, my way to do this below but can't find a solution to update modal.html with some ticket info.
let client = ZAFClient.init();
let modalClient = null;
let parentClient = null;
let data;
function displayModal() {
return new Promise((resolve) => {
client.invoke('instances.create', {
location: 'modal',
url: 'assets/modal.html',
size: {
width: '450px',
height: '200px'
}
}).then(function(modalContext) {
// The modal is on screen now
var modalClient = client.instance(modalContext['instances.create'][0].instanceGuid);
// The modal has been closed
modalClient.on('modal.close', function() {
resolve('cancel');
});
client.on('modal.response', (response) => {
resolve(response);
});
});
});
}
// Send the selected tags from the modal to the ticket sidebar
async function confirmChange() {
console.debug("confirmChange called...");
const context = await client.context();
let instanceGuid = context.instanceGuid;
modalClient = client.instance(instanceGuid);
parentClient.trigger('modal.response', 'confirm');
modalClient.invoke('destroy');
}
// Close the modal without sending changes to the ticket sidebar
async function cancelChange() {
const context = await client.context();
let instanceGuid = context.instanceGuid;
modalClient = client.instance(instanceGuid);
parentClient.trigger('modal.response', 'cancel');
console.debug("cancelChange called...");
modalClient.invoke('destroy');
}
// Ticket sidebar and modal button click listeners
window.addEventListener('DOMContentLoaded', function (event) {
let displayModalButton = document.querySelector("#displayModal");
let confirmButton = document.querySelector("#confirm");
let last_comment = document.querySelector("#last_comment");
let cancelButton = document.querySelector("#cancel");
let group_is_helpdesk = false;
client.get('currentUser').then(function (currentUserData) {
if (currentUserData && currentUserData.currentUser) {
const currentUser = currentUserData.currentUser;
const userGroups = currentUser.groups;
userGroups.forEach(function (group) {
if(group.id === 8995665084317)
{
let test = group.name;
group_is_helpdesk = true;
}
});
} else {
console.error('Les données de l\'utilisateur actuel ne sont pas définies.');
}
}).catch(function (error) {
console.error('Erreur lors de la récupération des données de l\'utilisateur actuel:', error);
});
client.on('ticket.save', async function () {
if(group_is_helpdesk)
{
console.log(group_is_helpdesk);
try {
data = await client.get('ticket');
if (data && data.ticket) {
console.log(data);
const currentStatus = data.ticket.customStatus.name;
if (currentStatus === 'Transfert vers SAV') {
const userConfirmed = await displayModal();
console.log(userConfirmed);
if (userConfirmed === 'cancel') {
console.log('L\'utilisateur a annulé l\'opération.');
throw new Error('Annulation de la sauvegarde');
}
console.log('Le ticket peut être sauvegardé.');
return "Transfert SAV en cours..."
} else {
throw new Error('Le statut n\'est pas "Transfert vers SAV".');
}
} else {
throw new Error('Les données du ticket ne sont pas définies.');
}
} catch (error) {
console.error(error.message);
return Promise.reject(false);
}
} else {
return Promise.reject(false);
}
});
if (last_comment) {
console.log('ici');
console.log(data);
last_comment.innerText = test;
}
if (confirmButton) {
confirmButton.addEventListener("click", function () {
console.log("Add Tags Button clicked.");
confirmChange();
});
}
if (cancelButton) {
cancelButton.addEventListener("click", function () {
console.log("Cancel Button clicked.");
cancelChange();
});
}
});
// Framework events
client.on('app.registered', function () {
// Listen for the modal registration
client.on('instance.registered', function (context) {
if (context.location === 'modal') {
let instanceGuid = context.instanceGuid;
modalClient = client.instance(instanceGuid);
// Trigger the event to send the parent instance GUID to the modal
modalClient.trigger(
'send_parent_client_guid_event',
client._instanceGuid
);
}
});
// Receive the parent client instance
client.on('send_parent_client_guid_event', function (parentClientGuid) {
console.debug('Receiving parent guid...', parentClientGuid);
parentClient = client.instance(parentClientGuid);
});
});
Ver comentario · Publicado 16 nov 2023 · Corentin BERTEAU
0
Seguidores
0
Votos
0
Comentarios
Corentin BERTEAU hizo un comentario,
I'm trying to do the same thing, but from the moment my function is asynchronous, client.on('ticket.save', async function () {... return false;}
doesn't work.
The only way I've found, and it's very ugly, is to call a nonexistent variable to block the sending by creating an error... If I find a solution or if I manage to make it work, I'll keep you informed.
It's possible anyway; the 'cancel submit ticket' application does exactly what we're trying to reproduce.
----
* update *
My bad, to cancel async function : return Promise.reject(false);
I will review my code and share my approach here asap.
Ver comentario · Editado 16 nov 2023 · Corentin BERTEAU
0
Seguidores
0
Votos
0
Comentarios
Corentin BERTEAU hizo un comentario,
Hi Ashwin Raju
+1 this feature is a must have.
Ver comentario · Publicado 23 may 2023 · Corentin BERTEAU
0
Seguidores
1
Voto
0
Comentarios