mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
feat(Zammad Node): Make it possible for Zammad to lookup and create users during ticket creation
This commit is contained in:
parent
aa6cfa07ef
commit
f65ab7a5ca
|
@ -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;
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue