mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 04:47:29 -08:00
✨ Add type field to Task resource (Salesforce) (#2171)
* added Type field in Task resource of salesforce * ⚡ Improvements to #2110 Co-authored-by: Ketan Somvanshi <ketan.somvanshi@plivo.com>
This commit is contained in:
parent
96813fcc05
commit
2c561507f7
|
@ -120,7 +120,6 @@ import {
|
|||
import {
|
||||
LoggerProxy as Logger,
|
||||
} from 'n8n-workflow';
|
||||
import { query } from '../Elasticsearch/descriptions/placeholders';
|
||||
|
||||
export class Salesforce implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
@ -691,6 +690,27 @@ export class Salesforce implements INodeType {
|
|||
sortOptions(returnData);
|
||||
return returnData;
|
||||
},
|
||||
// Get all the task types to display them to user so that he can
|
||||
// select them easily
|
||||
async getTaskTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
// TODO: find a way to filter this object to get just the lead sources instead of the whole object
|
||||
const { fields } = await salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe');
|
||||
for (const field of fields) {
|
||||
if (field.name === 'TaskSubtype') {
|
||||
for (const pickValue of field.picklistValues) {
|
||||
const pickValueName = pickValue.label;
|
||||
const pickValueId = pickValue.value;
|
||||
returnData.push({
|
||||
name: pickValueName,
|
||||
value: pickValueId,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
sortOptions(returnData);
|
||||
return returnData;
|
||||
},
|
||||
// Get all the task subjects to display them to user so that he can
|
||||
// select them easily
|
||||
async getTaskSubjects(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
|
@ -2332,6 +2352,9 @@ export class Salesforce implements INodeType {
|
|||
const body: ITask = {
|
||||
Status: status,
|
||||
};
|
||||
if (additionalFields.type !== undefined) {
|
||||
body.TaskSubtype = additionalFields.type as string;
|
||||
}
|
||||
if (additionalFields.whoId !== undefined) {
|
||||
body.WhoId = additionalFields.whoId as string;
|
||||
}
|
||||
|
@ -2417,6 +2440,9 @@ export class Salesforce implements INodeType {
|
|||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||
const body: ITask = {};
|
||||
if (updateFields.type !== undefined) {
|
||||
body.TaskSubtype = updateFields.type as string;
|
||||
}
|
||||
if (updateFields.whoId !== undefined) {
|
||||
body.WhoId = updateFields.whoId as string;
|
||||
}
|
||||
|
|
|
@ -388,6 +388,16 @@ export const taskFields = [
|
|||
},
|
||||
description: 'The subject line of the task, such as “Call” or “Send Quote.” Limit: 255 characters.',
|
||||
},
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTaskTypes',
|
||||
},
|
||||
description: `Represents Type of the task, such as Call or Meeting.`,
|
||||
},
|
||||
{
|
||||
displayName: 'What Id',
|
||||
name: 'whatId',
|
||||
|
@ -750,6 +760,16 @@ export const taskFields = [
|
|||
user may have deselected the reminder checkbox in the Salesforce user interface,<br/>
|
||||
or the reminder has already fired at the time indicated by the value.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Type',
|
||||
name: 'type',
|
||||
type: 'options',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTaskTypes',
|
||||
},
|
||||
description: `Represents Type of the task, such as Call or Meeting.`,
|
||||
},
|
||||
{
|
||||
displayName: 'What Id',
|
||||
name: 'whatId',
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
export interface ITask {
|
||||
TaskSubtype?: string;
|
||||
WhoId?: string;
|
||||
Status?: string;
|
||||
WhatId?: string;
|
||||
|
|
Loading…
Reference in a new issue