diff --git a/src/integrations/salesforce/workflows/syncNewTasksToSalesforce.ts b/src/integrations/salesforce/workflows/syncNewTasksToSalesforce.ts new file mode 100644 index 0000000..7b0e2aa --- /dev/null +++ b/src/integrations/salesforce/workflows/syncNewTasksToSalesforce.ts @@ -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, + InputResultMap +> { + /** + * Define workflow steps and orchestration. + */ + define( + integration: ISalesforceIntegration, + context: IContext, + connectUser: IConnectUser>, + ) { + 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>, + ): ConditionalInput | undefined { + return undefined; + } + + /** + * This property is maintained by Paragon. Do not edit this property. + */ + readonly id: string = '56e6dffa-cce8-44d3-a7b1-781028900a74'; +}