mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
✨ Feature/salesforce flow (#1041)
* Add handling of autolaunched flows to Salesforce node. Input variables can be either raw JSON or added via UI. * ⚡ Improvements to #1038 * fix issue when setting variables from the ui Co-authored-by: Craig McElroy <craig@mcelroyfamily.com>
This commit is contained in:
@@ -52,6 +52,11 @@ import {
|
||||
IContact,
|
||||
} from './ContactInterface';
|
||||
|
||||
import {
|
||||
flowFields,
|
||||
flowOperations,
|
||||
} from './FlowDescription';
|
||||
|
||||
import {
|
||||
salesforceApiRequest,
|
||||
salesforceApiRequestAllItems,
|
||||
@@ -144,6 +149,11 @@ export class Salesforce implements INodeType {
|
||||
value: 'contact',
|
||||
description: 'Represents a contact, which is an individual associated with an account.',
|
||||
},
|
||||
{
|
||||
name: 'Flow',
|
||||
value: 'flow',
|
||||
description: 'Represents an autolaunched flow.',
|
||||
},
|
||||
{
|
||||
name: 'Lead',
|
||||
value: 'lead',
|
||||
@@ -184,6 +194,8 @@ export class Salesforce implements INodeType {
|
||||
...attachmentFields,
|
||||
...userOperations,
|
||||
...userFields,
|
||||
...flowOperations,
|
||||
...flowFields,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1944,6 +1956,42 @@ export class Salesforce implements INodeType {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resource === 'flow') {
|
||||
//https://developer.salesforce.com/docs/atlas.en-us.api_action.meta/api_action/actions_obj_flow.htm
|
||||
if (operation === 'invoke') {
|
||||
const apiName = this.getNodeParameter('apiName', i) as string;
|
||||
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||
let variables = {};
|
||||
if (jsonParameters) {
|
||||
variables = this.getNodeParameter('variablesJson', i);
|
||||
} else {
|
||||
// Input variables are defined in UI
|
||||
const setInputVariable = this.getNodeParameter('variablesUi', i, {}) as IDataObject;
|
||||
if (setInputVariable!.variablesValues !== undefined) {
|
||||
for (const inputVariableData of setInputVariable!.variablesValues as IDataObject[]) {
|
||||
// @ts-ignore
|
||||
variables[inputVariableData!.name as string] = inputVariableData!.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
const body = {
|
||||
inputs: [
|
||||
variables,
|
||||
],
|
||||
};
|
||||
responseData = await salesforceApiRequest.call(this, 'POST', `/actions/custom/flow/${apiName}`, body);
|
||||
}
|
||||
//https://developer.salesforce.com/docs/atlas.en-us.api_action.meta/api_action/actions_obj_flow.htm
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
responseData = await salesforceApiRequest.call(this, 'GET', '/actions/custom/flow');
|
||||
responseData = responseData.actions;
|
||||
if (returnAll === false) {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user