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:
Ricardo Espinoza
2021-09-05 08:55:53 -04:00
committed by GitHub
parent 96813fcc05
commit 2c561507f7
3 changed files with 48 additions and 1 deletions

View File

@@ -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;
}