feat(Zammad Node): Make it possible for Zammad to lookup and create users during ticket creation

This commit is contained in:
Nico Weichbrodt 2024-07-02 14:30:30 +02:00
parent aa6cfa07ef
commit f65ab7a5ca
2 changed files with 36 additions and 10 deletions

View file

@ -662,13 +662,6 @@ export class Zammad implements INodeType {
// https://docs.zammad.org/en/latest/api/ticket/index.html#create
const body = {
article: {},
title: this.getNodeParameter('title', i) as string,
group: this.getNodeParameter('group', i) as string,
customer: this.getNodeParameter('customer', i) as string,
};
const article = this.getNodeParameter('article', i) as ZammadTypes.Article;
if (!Object.keys(article).length) {
@ -679,11 +672,30 @@ export class Zammad implements INodeType {
articleDetails: { visibility, ...rest },
} = article;
body.article = {
...rest,
internal: visibility === 'internal',
const base = {
article: {
...rest,
internal: visibility === 'internal',
},
title: this.getNodeParameter('title', i) as string,
group: this.getNodeParameter('group', i) as string,
};
const createCustomerIfNotExists = this.getNodeParameter(
'createCustomerIfNotExists',
i,
) as boolean;
const body = createCustomerIfNotExists
? {
...base,
customer_id: 'guess:' + (this.getNodeParameter('customer', i) as string),
}
: {
...base,
customer: this.getNodeParameter('customer', i) as string,
};
responseData = await zammadApiRequest.call(this, 'POST', '/tickets', body);
const { id } = responseData;

View file

@ -98,6 +98,20 @@ export const ticketDescription: INodeProperties[] = [
},
},
},
{
displayName: 'Create Customer if They Do Not Exist',
name: 'createCustomerIfNotExists',
description:
'Whether you want Zammad to find out the user ID or, if there is no user for the email address, create the user for you during ticket creation',
type: 'boolean',
default: false,
displayOptions: {
show: {
resource: ['ticket'],
operation: ['create'],
},
},
},
{
displayName: 'Ticket ID',
name: 'id',