mirror of
https://github.com/n8n-io/n8n.git
synced 2026-07-28 03:24:59 +02:00
fix(Salesforce Node): Pass ParentId when creating or updating a Case (#33775)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
37f569053f
commit
fffee465a4
|
|
@ -2483,8 +2483,8 @@ export class Salesforce implements INodeType {
|
|||
if (additionalFields.subject !== undefined) {
|
||||
body.Subject = additionalFields.subject as string;
|
||||
}
|
||||
if (additionalFields.parentId !== undefined) {
|
||||
body.ParentId = additionalFields.parentId as string;
|
||||
if (additionalFields.ParentId !== undefined) {
|
||||
body.ParentId = additionalFields.ParentId as string;
|
||||
}
|
||||
if (additionalFields.priority !== undefined) {
|
||||
body.Priority = additionalFields.priority as string;
|
||||
|
|
@ -2554,8 +2554,8 @@ export class Salesforce implements INodeType {
|
|||
if (updateFields.subject !== undefined) {
|
||||
body.Subject = updateFields.subject as string;
|
||||
}
|
||||
if (updateFields.parentId !== undefined) {
|
||||
body.ParentId = updateFields.parentId as string;
|
||||
if (updateFields.ParentId !== undefined) {
|
||||
body.ParentId = updateFields.ParentId as string;
|
||||
}
|
||||
if (updateFields.priority !== undefined) {
|
||||
body.Priority = updateFields.priority as string;
|
||||
|
|
|
|||
|
|
@ -1918,6 +1918,33 @@ describe('Salesforce', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should pass ParentId when creating a case with a parent', async () => {
|
||||
mockExecuteFunctions.getNodeParameter.mockImplementation((param: string): any => {
|
||||
const params: Record<string, unknown> = {
|
||||
resource: 'case',
|
||||
operation: 'create',
|
||||
type: 'Problem',
|
||||
additionalFields: {
|
||||
ParentId: 'parentCase123',
|
||||
},
|
||||
};
|
||||
return get(params, param);
|
||||
});
|
||||
|
||||
salesforceApiRequestSpy.mockResolvedValue({ id: 'childCase123', success: true });
|
||||
|
||||
await node.execute.call(mockExecuteFunctions);
|
||||
|
||||
expect(salesforceApiRequestSpy).toHaveBeenCalledWith(
|
||||
'POST',
|
||||
'/sobjects/case',
|
||||
expect.objectContaining({
|
||||
Type: 'Problem',
|
||||
ParentId: 'parentCase123',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle case create with all additional fields', async () => {
|
||||
mockExecuteFunctions.getNodeParameter.mockImplementation((param: string): any => {
|
||||
const params: Record<string, unknown> = {
|
||||
|
|
@ -1930,7 +1957,7 @@ describe('Salesforce', () => {
|
|||
status: 'New',
|
||||
owner: 'user123',
|
||||
subject: 'Test Case Subject',
|
||||
parentId: 'parent123',
|
||||
ParentId: 'parent123',
|
||||
priority: 'High',
|
||||
accountId: 'acc123',
|
||||
contactId: 'contact123',
|
||||
|
|
@ -2023,7 +2050,7 @@ describe('Salesforce', () => {
|
|||
status: 'Working',
|
||||
owner: 'user456',
|
||||
subject: 'Updated Case Subject',
|
||||
parentId: 'parent456',
|
||||
ParentId: 'parent456',
|
||||
priority: 'Medium',
|
||||
accountId: 'acc456',
|
||||
recordTypeId: 'rt456',
|
||||
|
|
@ -2068,6 +2095,32 @@ describe('Salesforce', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should pass ParentId when updating a case to set a parent', async () => {
|
||||
mockExecuteFunctions.getNodeParameter.mockImplementation((param: string): any => {
|
||||
const params: Record<string, unknown> = {
|
||||
resource: 'case',
|
||||
operation: 'update',
|
||||
caseId: 'childCase456',
|
||||
updateFields: {
|
||||
ParentId: 'parentCase456',
|
||||
},
|
||||
};
|
||||
return get(params, param);
|
||||
});
|
||||
|
||||
salesforceApiRequestSpy.mockResolvedValue({ success: true });
|
||||
|
||||
await node.execute.call(mockExecuteFunctions);
|
||||
|
||||
expect(salesforceApiRequestSpy).toHaveBeenCalledWith(
|
||||
'PATCH',
|
||||
'/sobjects/case/childCase456',
|
||||
expect.objectContaining({
|
||||
ParentId: 'parentCase456',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle case update with custom fields', async () => {
|
||||
mockExecuteFunctions.getNodeParameter.mockImplementation((param: string): any => {
|
||||
const params: Record<string, unknown> = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user