Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

mulesoft-assets/template-wday2sfdc-changeroleemployee-broadcast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anypoint Template: Workday to Salesforce Change Role Employee Broadcast

License Agreement

Note that using this template is subject to the conditions of this License Agreement. Please review the terms of the license before downloading and using this template. In short, you are allowed to use the template for free with Mule ESB Enterprise Edition, CloudHub, or as a trial in Anypoint Studio.

Use Case

This Anypoint Template should serve as a foundation for setting an online sync of Employee Role Changes from Workday to Salesforce Users.

Every time there is a change in an already existing Employee in Workday, the integration will poll for them in the source instance and it will be responsible for updating the Change Role for the User in Salesforce.

Requirements have been set not only to be used as examples, but also to establish a starting point to adapt your integration to your requirements.

As implemented, this Anypoint Template leverages the Batch Module. The batch job is divided in Input, Process and On Complete stages.

The Template retrieves all updated Employees since last poll, checks for duplicates and triggers the Batch process. During the Batch Process stage, in the first step the different Employees are matched by email with the existing Users in Salesforce. In the second step the PermissionSet for the users are updated to Salesforce using a Batch Commit.

Finally during the On Complete stage the Anypoint Template will log output statistics data into the console.

Considerations

To make this Anypoint Template run, there are certain preconditions that must be considered. All of them deal with the preparations in both source and destination systems, that must be made in order for all to run smoothly. Failling to do so could lead to unexpected behavior of the template.

  1. Users cannot be deleted in SalesForce: For now, the only thing to do regarding users removal is disabling/deactivating them, but this won't make the username available for a new user.
  2. Each user needs to be associated to a Profile: SalesForce's profiles are what define the permissions the user will have for manipulating data and other users. Each SalesForce account has its own profiles. In this Anypoint Template you will find a processor labeled setup Worker for upsert where to set your Profile Ids from the source account. Note that for the integration test to run properly, you should change the constant sfdc.profileId in mule.test.properties to one that's valid in your source organization.
  3. Working with sandboxes for the same account: Although each sandbox should be a completely different environment, Usernames cannot be repeated in different sandboxes, i.e. if you have a user with username bob.dylan in sandbox A, you will not be able to create another user with username bob.dylan in sandbox B. If you are indeed working with Sandboxes for the same SalesForce account you will need to map the source username to a different one in the target sandbox, for this purpose, please refer to the processor labeled setup Worker for upsert.
  4. Workday email uniqueness: The email can be repeated for two or more accounts (or missing). Therefore Workday accounts with duplicate emails will be removed from processing in the Input stage.

Salesforce Considerations

There may be a few things that you need to know regarding Salesforce, in order for this template to work.

In order to have this template working as expected, you should be aware of your own Salesforce field configuration.

###FAQ

As destination of data

There are no particular considerations for this Anypoint Template regarding Salesforce as data destination.

Workday Considerations

As source of data

There are no particular considerations for this Anypoint Template regarding Workday as data origin.

Run it!

Simple steps to get Workday to Salesforce Change Role Employee Broadcast running.

Running on premise

In this section we detail the way you should run your Anypoint Template on your computer.

Where to Download Mule Studio and Mule ESB

First thing to know if you are a newcomer to Mule is where to get the tools.

  • You can download Mule Studio from this Location
  • You can download Mule ESB from this Location

Importing an Anypoint Template into Studio

Mule Studio offers several ways to import a project into the workspace, for instance:

  • Anypoint Studio generated Deployable Archive (.zip)
  • Anypoint Studio Project from External Location
  • Maven-based Mule Project from pom.xml
  • Mule ESB Configuration XML from External Location

You can find a detailed description on how to do so in this Documentation Page.

Running on Studio

Once you have imported you Anypoint Template into Anypoint Studio you need to follow these steps to run it:

  • Locate the properties file mule.dev.properties, in src/main/resources
  • Complete all the properties required as per the examples in the section Properties to be configured
  • Once that is done, right click on you Anypoint Template project folder
  • Hover you mouse over "Run as"
  • Click on "Mule Application"

Running on Mule ESB stand alone

Complete all properties in one of the property files, for example in [mule.prod.properties] (../master/src/main/resources/mule.prod.properties) and run your app with the corresponding environment variable to use it. To follow the example, this will be mule.env=prod.

Running on CloudHub

While creating your application on CloudHub (Or you can do it later as a next step), you need to go to Deployment > Advanced to set all environment variables detailed in Properties to be configured as well as the mule.env.

Deploying your Anypoint Template on CloudHub

Mule Studio provides you with really easy way to deploy your Template directly to CloudHub, for the specific steps to do so please check this link

Properties to be configured (With examples)

In order to use this Mule Anypoint Template you need to configure properties (Credentials, configurations, etc.) either in properties file or in CloudHub as Environment Variables. Detail list with examples:

Application configuration

  • poll.frequencyMillis 60000
  • poll.startDelayMillis 1000
  • watermark.default.expression #[groovy: new GregorianCalendar(2015, Calendar.MAY, 28, 9, 00, 00)]

Workday Connector configuration

  • wday.user admin@workday
  • wday.password secret
  • wday.endpoint https://impl-cc.workday.com/ccx/service/workday/Human_Resources/v21.1

Salesforce Connector

  • sfdc.username user@company.com
  • sfdc.password secret
  • sfdc.securityToken 1234fdkfdkso20kw2sd
  • sfdc.url https://login.salesforce.com/services/Soap/u/32.0

Roles Map

  • wday.sfdc.rolesMap ['SOME_ROLE_IN_WDAY': 'SOME_ROLE_IN_SF', 'ANOTHER_ROLE_IN_WDAY': 'ANOTHER_ROLE_IN_SF' ]

API Calls

Salesforce imposes limits on the number of API Calls that can be made. Therefore calculating this amount may be an important factor to consider. The Anypoint Template calls to the API can be calculated using the formula:

1 + X + X / 200

Being X the number of Users to be synchronized on each run.

The division by 200 is because, by default, Users are gathered in groups of 200 for each Upsert API Call in the commit step. Also consider that this calls are executed repeatedly every polling cycle.

For instance if 10 records are fetched from origin instance, then 12 api calls will be made (1 + 10 + 1).

Customize It!

This brief guide intends to give a high level idea of how this Anypoint Template is built and how you can change it according to your needs. As mule applications are based on XML files, this page will be organized by describing all the XML that conform the Anypoint Template. Of course more files will be found such as Test Classes and Mule Application Files, but to keep it simple we will focus on the XMLs.

Here is a list of the main XML files you'll find in this application:

config.xml

Configuration for Connectors and Properties Place Holders are set in this file. Even you can change the configuration here, all parameters that can be modified here are in properties file, and this is the recommended place to do it so. Of course if you want to do core changes to the logic you will probably need to modify this file.

In the visual editor they can be found on the Global Element tab.

businessLogic.xml

Functional aspect of the Anypoint Template is implemented on this XML, directed by a batch job that will be responsible for creations/updates. The severeal message processors constitute four high level actions that fully implement the logic of this Anypoint Template:

  1. Job execution is invoked from triggerFlow (endpoints.xml) everytime there is a new query executed asking for updated Employees.
  2. During the Process stage, each Employee will be filtered depending on if it has an existing matching User in the Salesforce.
  3. The last step of the Process stage will group the Users and update them in Salesforce. Finally during the On Complete stage the Anypoint Template will log output statistics data into the console.

endpoints.xml

This is file is conformed by a Flow containing the endpoints for triggering the template and retrieving the objects that meet the defined criteria in the query. And then executing the batch job process with the query results.

errorHandling.xml

This is the right place to handle how your integration will react depending on the different exceptions. This file holds a Choice Exception Strategy that is referenced by the main flow in the business logic.