Skip to content

Commit

Permalink
Merge pull request #1 from useparagon/ethan/new-tasks
Browse files Browse the repository at this point in the history
New tasks workflow
  • Loading branch information
ethanlee16 authored Mar 22, 2024
2 parents 77a6f30 + 7019a87 commit cf2fcc2
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions src/integrations/salesforce/workflows/syncNewTasksToSalesforce.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { EventStep, FunctionStep, UnselectedStep, Workflow } from '@useparagon/core';
import { IContext } from '@useparagon/core/execution';
import { IPersona } from '@useparagon/core/persona';
import { ConditionalInput } from '@useparagon/core/steps/library/conditional';
import { IConnectUser, IPermissionContext } from '@useparagon/core/user';
import {
ISalesforceIntegration,
InputResultMap,
createInputs,
} from '@useparagon/integrations/salesforce';

import personaMeta from '../../../persona.meta';
import event from '../../../events/newTask';

/**
* Sync new tasks to Salesforce Workflow implementation
*/
export default class extends Workflow<
ISalesforceIntegration,
IPersona<typeof personaMeta>,
InputResultMap
> {
/**
* Define workflow steps and orchestration.
*/
define(
integration: ISalesforceIntegration,
context: IContext<InputResultMap>,
connectUser: IConnectUser<IPersona<typeof personaMeta>>,
) {
const triggerStep = new EventStep(event);

const createTaskStep = integration.actions.createRecord({
recordType: 'Task',
"field-subject": triggerStep.output.title,
"field-taskSubtype": "task",
"field-description": triggerStep.output.description
}, {});

triggerStep.nextStep(createTaskStep);

/**
* Pass all steps used in the workflow to the `.register()`
* function. The keys used in this function must remain stable.
*/
return this.register({ triggerStep, createTaskStep });
}

/**
* The name of the workflow, used in the Dashboard and Connect Portal.
*/
name: string = 'Sync new tasks to Salesforce';

/**
* A user-facing description of the workflow shown in the Connect Portal.
*/
description: string = 'Add a user-facing description of this workflow';

/**
* Define workflow-level User Settings. For integration-level User
* Settings, see ../config.ts.
* https://docs.useparagon.com/connect-portal/workflow-user-settings
*/
inputs = createInputs({});

/**
* If set to true, the workflow will appear as enabled by default once
* a user connects their account to the integration.
* https://docs.useparagon.com/connect-portal/displaying-workflows#default-to-enabled
*/
defaultEnabled: boolean = false;

/**
* If set to true, the workflow will be hidden from all users from the
* Connect Portal.
* https://docs.useparagon.com/connect-portal/displaying-workflows#hide-workflow-from-portal-for-all-users
*/
hidden: boolean = false;

/**
* You can restrict the visibility of this workflow to specific users
* with Workflow Permissions.
* https://docs.useparagon.com/connect-portal/workflow-permissions
*/
definePermissions(
connectUser: IPermissionContext<IPersona<typeof personaMeta>>,
): ConditionalInput | undefined {
return undefined;
}

/**
* This property is maintained by Paragon. Do not edit this property.
*/
readonly id: string = '56e6dffa-cce8-44d3-a7b1-781028900a74';
}

0 comments on commit cf2fcc2

Please sign in to comment.