Creating Custom Transform Operations
By default, Salesforce-to-Service Board real-time data sync is handled by predefined transform action functions that are configured for use by the associated transform templates. In cases where you want to override this default behavior, you can configure custom transform operations.
* 
The Transform Operation field in the Transform Template object is overwritten whenever release versions are upgraded. Because any updates to this field value are not preserved at upgrade, you must create a custom transform template to execute the custom transform operation.
The following steps show an example of how to configure a custom transform operation for the SFE to Appointment Create transform template.
To create custom transform operations:
1. In Max Designer, on the Developer Tools () launchpad menu, click Sources, and then in the list view, in the top left corner, click Create() and complete the fields as follows to create a new Source record.
Name: com.servicemax.dc.operation.integration.SyncAppointmentCreateOperation
Application: Service Board
Code:
/*
* Copyright (C) 2007-present, ServiceMax Inc.
*
* The program(s) herein may be used and/or copied only with
* the written permission of ServiceMax Inc. or in accordance with
* the terms and conditions stipulated in the agreement/contract
* under which the program(s) have been supplied.
*/
package com.servicemax.dc.operation.integration

import com.servicemax.core.Database
import com.servicemax.core.Max
import com.servicemax.core.annotations.Application
import com.servicemax.transform.operation.TransformOperation

@Application(application = 'svmx_dispatch_console')
class SyncAppointmentCreateOperation extends TransformOperation {

@Override
protected Object realExecute(Map<String, Object> parameters) throws Exception {
SyncOperationHelper.validateParameters(parameters)
def result = [success: true]
Collection<Object> convertedRecords = parameters.get('records')
Map record = (Map) convertedRecords.iterator().next()
String externalId = record.get('io_external_id')
if (!isExistedInSB(externalId)) {
executePatch('svmx_appointment', convertedRecords, null)
}
return result
}

private boolean isExistedInSB(String externalId) {
Max.executeInTransaction {
Integer size = Database.queryObject('SELECT count(*) FROM svmx_appointment WHERE io_external_id = :io_external_id', [io_external_id: externalId])
return size > 0
}
}
}
2. In Max Designer, on the Developer Tools () launchpad menu, click Operations, and then in the list view, in the top left corner, click Create () and complete the fields as follows to create a new Operation record.
Field
Value
Name
Sync Appointment Create Event
Identifier
sync_appointment_create_event
Computer Language
Groovy
Class Name
com.servicemax.dc.operation.integration.SyncAppointmentCreateOperation
Method Name
execute
3. In the newly created record, on the Relations tab, in the Related Lists view, in the top right corner, click Show All Relationships (), and then click to open the Permissions list that has a Relationship column value of Permission Related Operation.
4. In the Permission Related Operations list view, click Create (), and then in the Create New Permission dialog box, complete the fields as follows to create three Permission records for the Dispatcher, Service Board Integration, and Service Board Administrator roles.
Actor: Dispatcher, Service Board Integration, and Service Board Administrator
Scope: Not Record Specific
All Other Fields: Accept default values
5. In Max Designer, on the Developer Tools () launchpad menu, click Transform Templates, and then in the list view, click a transform template, for example, SFE to Appointment Create Template.
6. On the record page, in the top right corner, on the Options () menu, click Copy, and then in the newly copied record, complete the fields as follows.
Field
Value
Name
SFE to Appointment Create Custom Template
Identifier
salesforce_event_svmx_appointment_create_custom
Transform Operation
Sync Appointment Create Event
7. In Max Designer, on the Administration () launchpad menu, click Settings, and then in the list view, in the top left corner, click Create () and complete the fields as follows to define custom real-time sync rules for your newly created transform operation.
Field
Value
Name
SFDC Real-Time Sync Custom Transform Rules
Applicable Application
Service Board
Identifier
sfdc_realtime_sync_custom_transform_rules
Datatype
Code
Default Value
{
"create_SFE_Appointment": [
{
"id": "salesforce_event_svmx_appointment_create_custom"
}
]}
Application
Service Board
8. In Max Admin, on the Development Actions () launchpad menu, click Synchronize.
For more information:
Was this helpful?