mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
Sfdc (#933)
* add sfdc user node interface * add sfdc user node description for get method * sfdc user node getall * sfdc user node support limit * sfdc user node support options * sfdc user node update user operations * sfdc add usr node query logic * ⚡ Small improvements Co-authored-by: YErii <yeriime@outlook.com>
This commit is contained in:
@@ -71,7 +71,13 @@ import {
|
||||
import {
|
||||
ITask,
|
||||
} from './TaskInterface';
|
||||
|
||||
import {
|
||||
userFields,
|
||||
userOperations,
|
||||
} from './UserDescription';
|
||||
import {
|
||||
IUser,
|
||||
} from './UserInterface';
|
||||
|
||||
export class Salesforce implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -135,7 +141,11 @@ export class Salesforce implements INodeType {
|
||||
value: 'task',
|
||||
description: 'Represents a business activity such as making a phone call or other to-do items. In the user interface, and records are collectively referred to as activities.',
|
||||
},
|
||||
|
||||
{
|
||||
name: 'User',
|
||||
value: 'user',
|
||||
description: 'Represents a person, which is one user in system.',
|
||||
},
|
||||
],
|
||||
default: 'lead',
|
||||
description: 'Resource to consume.',
|
||||
@@ -154,6 +164,8 @@ export class Salesforce implements INodeType {
|
||||
...taskFields,
|
||||
...attachmentOperations,
|
||||
...attachmentFields,
|
||||
...userOperations,
|
||||
...userFields,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1885,6 +1897,35 @@ export class Salesforce implements INodeType {
|
||||
responseData = await salesforceApiRequest.call(this, 'GET', '/sobjects/attachment');
|
||||
}
|
||||
}
|
||||
if (resource === 'user') {
|
||||
//https://developer.salesforce.com/docs/api-explorer/sobject/User/get-user-id
|
||||
if (operation === 'get') {
|
||||
const userId = this.getNodeParameter('userId', i) as string;
|
||||
responseData = await salesforceApiRequest.call(this, 'GET', `/sobjects/user/${userId}`);
|
||||
}
|
||||
//https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
const fields = ['id,name,email'];
|
||||
if (options.fields) {
|
||||
// @ts-ignore
|
||||
fields.push(...options.fields.split(','));
|
||||
}
|
||||
try {
|
||||
if (returnAll) {
|
||||
qs.q = `SELECT ${fields.join(',')} FROM User`;
|
||||
responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
qs.q = `SELECT ${fields.join(',')} FROM User Limit ${limit}`;
|
||||
responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs);
|
||||
}
|
||||
} catch(err) {
|
||||
throw new Error(`Salesforce Error: ${err}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user