📁 Showcase
Automation

Automations

1. AutomateEventSheet

ensure automation AutomateEventSheet kind: spreadsheet 
  spreadsheet: EventSheet

a. BeforeInsert event

ensure event BeforeInsert fire: beforeInsert

ensure pipelineVar P1 form: PrivateRowIdResult

i. GetRows step

ensure var VarConditionDoesEventIdMatchExisting2 kind: condition 
  deploy: fixedOnDeploy
  value: "<root>
      <stmt>${f:Details.Id} == ${in:Details.Id}</stmt>
    </root>" 
  sourceForm: EntityEvent 
  inputForm: EntityEvent

ensure var VarMappingEventToPrivateRowIdResult1 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityEvent 
  toForm: PrivateRowIdResult 
  fieldMappingMap: {
      'map': {
        '${ctx:row.id}': 'Details.RowId'
      }
    }

// step, getSpreadsheetRows, GetSpreadsheetRows
ensure automation AutomateEventSheet
ensure event BeforeInsert
ensure step GetSpreadsheetRows kind: getSpreadsheetRows 
  targetSpreadsheet: EventSheet 
  targetSpreadsheetFilterVar: VarConditionDoesEventIdMatchExisting2 
  outputFormPipelineVar: P1 
  targetToSourceMappingVar: VarMappingEventToPrivateRowIdResult1

ii. RemoveField step

// step, removeField, RemoveField
ensure step RemoveField kind: removeField 
  removeField: Details.FormMode

iii. Copyfield step

ensure var VarMappingPrivateRowIdResultToEvent1 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityEvent 
  toForm: PrivateRowIdResult 
  fieldMappingMap: {
      'map': {
        '${ctx:row.id}': 'Details.RowId'
      }
    }

// step, copyField, CopyRowIdToCurrentForm
ensure automation AutomateEventSheet
ensure event BeforeInsert
ensure step CopyRowIdToCurrentForm kind: copyField 
  sourcePipelineVar: P1 
  mappingVar: VarMappingPrivateRowIdResultToEvent1

iv. UpdateSheet step

ensure var VarConditionHasEventRowIdValue kind: condition 
  deploy: fixedOnDeploy
  value: "<root>
      <stmt>${in:Details.RowId} has value</stmt>
    </root>" 
  sourceForm: EntityEvent 
  inputForm: PrivateRowIdResult

ensure var VarMappingEventToEvent1 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityEvent 
  toForm: EntityEvent 
  fieldMappingMap: {
      'map': {
        '${f:Details.RowId}': 'Details.RowId',
        '${f:Details.Subject}': 'Details.Subject',
        '${f:Details.Description}': 'Details.Description',
        '${f:Details.StartDateTime}': 'Details.StartDateTime',
        '${f:Details.EndDateTime}': 'Details.EndDateTime',
        '${f:Details.IsAllDayEvent}': 'Details.IsAllDayEvent',
        '${f:Details.Location}': 'Details.Location',
        '${f:Details.AssignedTo}': 'Details.AssignedTo',
        '${f:Details.RelatedTo}': 'Details.RelatedTo'
      }
    }

// step, updateSpreadsheet, UpdateSpreadsheetEventSheet
ensure automation AutomateEventSheet
ensure event BeforeInsert
ensure step UpdateSpreadsheetEventSheet kind: updateSpreadsheet 
  executionConditionVar: VarConditionHasEventRowIdValue 
  executionConditionInputPipelineVar: P1 
  targetSpreadsheet: EventSheet 
  rowIdField: Details.RowId 
  sourceToTargetMappingVar: VarMappingEventToEvent1

v. Terminate step

// step, terminate, Terminate
ensure step Terminate kind: terminate 
  executionConditionVar: VarConditionHasEventRowIdValue 
  executionConditionInputPipelineVar: P1

vi. CreateRecord step

ensure var VarConditionDoesEventNotExist kind: condition 
  deploy: fixedOnDeploy
  value: "<root>
      <and>
        <stmt>${in:Details.RowId} has no value</stmt>
        <stmt>${f:Details.Id} has no value</stmt>
      </and>
    </root>" 
  sourceForm: EntityEvent 
  inputForm: PrivateRowIdResult

ensure var VarMappingEventToCreateEvent2 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityEvent 
  toPlugin: SalesforcePlugin 
  toForm: CreateEvent 
  fieldMappingMap: {
      'map': {
        '${f:Details.Id}': 'Id',
        '${f:Details.Subject}': 'Subject',
        '${f:Details.Description}': 'Description',
        '${f:Details.Location}': 'Location',
        '${f:Details.IsAllDayEvent}': 'IsAllDayEvent',
        '${f:Details.AssignedTo}': 'AssignedTo',
        '${f:Details.RelatedTo}': 'RelatedTo',
        '${f:Details.StartDateTime}': 'StartDate',
        '${f:Details.EndDateTime}': 'EndDate'
      }
    }

ensure var VarMappingCreatedRecordIdToEvent kind: mapping 
  deploy: fixedOnDeploy
  fromPlugin: SalesforcePlugin 
  fromForm: CreatedRecordId 
  toForm: EntityEvent 
  fieldMappingMap: {
      'map': {
        '${f:Details.Id}': 'Details.Id'
      }
    }

// step, callPlugin, CreateRecordIntoSalesforce
ensure automation AutomateEventSheet
ensure event BeforeInsert
ensure step CreateRecordIntoSalesforce kind: callPlugin 
  executionConditionVar: VarConditionDoesEventNotExist 
  executionConditionInputPipelineVar: P1 
  targetPlugin: SalesforcePlugin 
  targetPluginApi: CreateEvent 
  pluginInputMappingVar: VarMappingEventToCreateEvent2 
  pluginOutputMappingVar: VarMappingCreatedRecordIdToEvent

b. AfterInsert event

// event, AfterInsert
ensure event AfterInsert fire: afterInsert

i. ForwardToGroups step

// step, forwardToGroups, ForwardToGroups
ensure step ForwardToGroups kind: forwardToGroups 
  senderRole: $Self
  groups: [Salesforce]

c. AfterUpdate event

// event, AfterUpdate
ensure event AfterUpdate fire: afterUpdate

i. UpdateEvent step

ensure var VarMappingEventToCreateEvent1 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityEvent 
  toPlugin: SalesforcePlugin 
  toForm: CreateEvent 
  fieldMappingMap: {
      'map': {
        '${f:Details.Id}': 'Id',
        '${f:Details.Subject}': 'Subject',
        '${f:Details.Description}': 'Description',
        '${f:Details.Location}': 'Location',
        '${f:Details.IsAllDayEvent}': 'IsAllDayEvent',
        '${f:Details.AssignedTo}': 'AssignedTo',
        '${f:Details.RelatedTo}': 'RelatedTo',
        '${f:Details.StartDateTime}': 'StartDate',
        '${f:Details.EndDateTime}': 'EndDate'
      }
    }

// step, callPlugin, UpdateAccountInSalesforce
ensure automation AutomateEventSheet
ensure event AfterUpdate
ensure step UpdateEventInSalesforce kind: callPlugin 
  targetPlugin: SalesforcePlugin 
  targetPluginApi: UpdateEvent 
  pluginInputMappingVar: VarMappingEventToCreateEvent1

d. BeforeRemove event

// event, BeforeRemove
ensure event BeforeRemove fire: beforeRemove

i. RemoveRecord step

ensure var VarMappingEventToRecordIdInputForm1 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityEvent 
  toPlugin: SalesforcePlugin 
  toForm: RecordIdInputForm 
  fieldMappingMap: {
      'map': {
        '${f:Details.Id}': 'Id'
      }
    }

// step, callPlugin, RemoveFromSalesforce
ensure automation AutomateEventSheet
ensure event BeforeRemove
ensure step RemoveFromSalesforce kind: callPlugin 
  targetPlugin: SalesforcePlugin 
  targetPluginApi: RemoveRecord 
  pluginInputMappingVar: VarMappingEventToRecordIdInputForm1

2. AutomateEventWebhook

ensure automation AutomateSalesforcePluginEventDetailWebhook kind: pluginWebhook 
  plugIn: SalesforcePlugin 
  pluginApi: EventDetailWebhook

a. OnCallback event

ensure event OnCallback fire: onCallback

ensure pipelineVar PipelineRowExist form: PrivateRowIdResult
ensure pipelineVar PipelineEvent form: EntityEvent

i. CopyEvent step

ensure var VarMappingEventDetailToEvent2 kind: mapping 
  deploy: fixedOnDeploy
  fromPlugin: SalesforcePlugin 
  fromForm: EventDetail 
  toForm: EntityEvent 
  fieldMappingMap: {
      'map': {
        '${f:Details.Id}': 'Details.Id',
        '${f:Details.Subject}': 'Details.Subject',
        '${f:Details.Description}': 'Details.Description',
        '${f:Details.StartDateTime}': 'Details.StartDateTime',
        '${f:Details.EndDateTime}': 'Details.EndDateTime',
        '${f:Details.IsAllDayEvent}': 'Details.IsAllDayEvent',
        '${f:Details.Location}': 'Details.Location',
        '${f:Details.AssignedTo}': 'Details.AssignedTo',
        '${f:Details.RelatedTo}': 'Details.RelatedTo'
      }
    }

// step, copyField, CopyEventDetailToPipeline
ensure automation AutomateSalesforcePluginEventDetailWebhook
ensure event OnCallback
ensure step CopyEventDetailToPipeline kind: copyField 
  targetPipelineVar: PipelineEvent 
  mappingVar: VarMappingEventDetailToEvent2

ii. GetRows step

ensure var VarConditionDoesEventIdMatchExisting1 kind: condition 
  deploy: fixedOnDeploy
  value: "<root>
      <stmt>${in:Details.Id} == ${f:Details.Id}</stmt>
    </root>" 
  sourceForm: EntityEvent 
  inputForm: EntityEvent

// step, getSpreadsheetRows, GetSpreadsheetRows
ensure automation AutomateSalesforcePluginEventDetailWebhook
ensure event OnCallback
ensure step GetSpreadsheetRows kind: getSpreadsheetRows 
  targetSpreadsheet: EventSheet 
  targetSpreadsheetFilterVar: VarConditionDoesEventIdMatchExisting1 
  inputFormPipelineVar: PipelineEvent 
  outputFormPipelineVar: PipelineRowExist 
  targetToSourceMappingVar: VarMappingEventToPrivateRowIdResult1

iii. CopyRowId step

ensure var VarMappingPrivateRowIdResultToEvent2 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: PrivateRowIdResult 
  toForm: EntityEvent 
  fieldMappingMap: {
      'map': {
        '${f:Details.RowId}': 'Details.RowId'
      }
    }

// step, copyField, CopyRowIdToTempForm
ensure automation AutomateSalesforcePluginEventDetailWebhook
ensure event OnCallback
ensure step CopyRowIdToTempForm kind: copyField 
  sourcePipelineVar: PipelineRowExist 
  targetPipelineVar: PipelineEvent 
  mappingVar: VarMappingPrivateRowIdResultToEvent2

iv. UpdateSheet step

ensure var VarMappingEventToEvent2 kind: mapping 
  deploy: fixedOnDeploy
  fromForm: EntityEvent 
  toForm: EntityEvent 
  fieldMappingMap: {
      'map': {
        '${f:Details.FormMode}': 'Details.FormMode',
        '${f:Details.Id}': 'Details.Id',
        '${f:Details.Subject}': 'Details.Subject',
        '${f:Details.Description}': 'Details.Description',
        '${f:Details.StartDateTime}': 'Details.StartDateTime',
        '${f:Details.EndDateTime}': 'Details.EndDateTime',
        '${f:Details.IsAllDayEvent}': 'Details.IsAllDayEvent',
        '${f:Details.Location}': 'Details.Location',
        '${f:Details.AssignedTo}': 'Details.AssignedTo'
      }
    }

// step, updateSpreadsheet, UpdateSpreadsheetEventSheet
ensure automation AutomateSalesforcePluginEventDetailWebhook
ensure event OnCallback
ensure step UpdateSpreadsheetEventSheet kind: updateSpreadsheet 
  executionConditionInputPipelineVar: PipelineRowExist 
  targetSpreadsheet: EventSheet 
  inputFormPipelineVar: PipelineEvent 
  rowIdField: Details.RowId 
  sourceToTargetMappingVar: VarMappingEventToEvent2