-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from useparagon/ethan/new-tasks
New tasks workflow
- Loading branch information
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
src/integrations/salesforce/workflows/syncNewTasksToSalesforce.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
} |