Salesforce Org to Org User Broadcast

(0 reviews)


Broadcasts changes to users in Salesforce A to Salesforce B in real time. The detection criteria, and fields to move are configurable. Additional systems can be added to be notified of the changes. Real time synchronization is achieved via rapid polling or outbound notifications.

This template uses watermarking to ensure that only the most recent items are synchronized and batch to efficiently process many records at a time.


⚠ Your browser has cookies disabled. You must have all cookies enabled for video playback to work

License Agreement

This template is subject to the conditions of the MuleSoft License Agreement. Review the terms of the license before downloading and using this template. You can use this template for free with the Mule Enterprise Edition, CloudHub, or as a trial in Anypoint Studio.

Use Case

As a Salesforce admin I want to migrate users from one Salesforce organization to another one.

This template serves as a foundation for setting an online sync of users from one Salesforce instance to another. Everytime there is new user or a change to an existing user, the integration polls for changes in Salesforce source instance and updates the user in the target organization.

What about passwords? When a user is updated in the target instance, the password is not changed and therefore there is nothing of concern in this case. The password set in case of user creation is not being covered by this template considering that many different approaches can be selected.

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 template leverages the Mule batch module.

The batch job is divided in Process and On Complete stages.

The integration is triggered by a scheduler defined in the flow that is going to trigger the application, querying the newest Salesforce updates or creates matching a filter criteria and executing the batch job.

During the Process stage, each Salesforce user is filtered depending on if it has an existing matching user in the Salesforce Org B.

The Process stage then groups the users and creates or updates them in Salesforce Org B.

Finally during the On Complete stage the template logs output statistics data to the console.


To make this 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 for the template to run smoothly. Failing 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 or 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 a user has for manipulating data. Each Salesforce account has its own profiles. In this template there's a processor labeled Prepare for Upsert that maps your Profile Ids from the source account to the target account. Note that for the integration test to run properly, you should change the constant DEFAULT_PROFILE_ID in BusinessLogicTestIT to one that's valid in your source test 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. For example, if you have a user with username bob.dylan in sandbox A, you cannot create another user with username bob.dylan in sandbox B. If you are working with sandboxes for the same Salesforce account, map the source username to a different one in the target sandbox, for this purpose, refer to the processor labeled Prepare for Upsert.

Salesforce Considerations

Here's what you need to know about Salesforce to get this template to work:

As a Data Source

If the user who configured the template for the source system does not have at least read only permissions for the fields that are fetched, then an InvalidFieldFault API fault displays.

java.lang.RuntimeException: [InvalidFieldFault [ApiQueryFault 
[ApiFault  exceptionCode='INVALID_FIELD'
exceptionMessage='Account.Phone, Account.Rating, Account.RecordTypeId, 
ERROR at Row:1:Column:486
No such column 'RecordTypeId' on entity 'Account'. If you are attempting to
use a custom field, be sure to append the '__c' after the custom field 
name. Reference your WSDL or the describe call for the appropriate names.'

As a Data Destination

There are no considerations with using Salesforce as a data destination.

Run it!

Simple steps to get this template running.

Running On Premises

In this section we help you run this template on your computer.

Where to Download Anypoint Studio and the Mule Runtime

If you are new to Mule, download this software:

Note: Anypoint Studio requires JDK 8.

Importing a Template into Studio

In Studio, click the Exchange X icon in the upper left of the taskbar, log in with your Anypoint Platform credentials, search for the template, and click Open.

Running on Studio

After you import your template into Anypoint Studio, follow these steps to run it:

  • Locate the properties file, in src/main/resources.
  • Complete all the properties required as per the examples in the "Properties to Configure" section.
  • Right click the template project folder.
  • Hover your mouse over Run as.
  • Click Mule Application (configure).
  • Inside the dialog, select Environment and set the variable mule.env to the value dev.
  • Click Run.

Running on Mule Standalone

Update the properties in one of the property files, for example in, and run your app with a corresponding environment variable. In this example, use mule.env=prod.

Once your app is all set and started, there is no need to do anything else. The application polls Salesforce to see if there are any newly created or updated objects and synchronizes them.

Running on CloudHub

When creating your application in CloudHub, go to Runtime Manager > Manage Application > Properties to set the environment variables listed in "Properties to Configure" as well as the mule.env value.

Once your app is all set and started, you need to define Salesforce outbound messaging and a simple workflow rule. This article will show you how to accomplish this.

The most important setting here is the Endpoint URL which needs to point to your application running on CloudbHub, eg. Additionally, try to add just few fields to the Fields to Send to keep it simple for now.

Once this all is done, every time when you make a change in an account in the source Salesforce org, this account will be sent as a SOAP message to the HTTP endpoint of the running application in CloudHub.

Deploying a Template in CloudHub

In Studio, right click your project name in Package Explorer and select Anypoint Platform > Deploy on CloudHub.

Properties to Configure

To use this template, configure properties such as credentials, configurations, etc.) in the properties file or in CloudHub from Runtime Manager > Manage Application > Properties. The sections that follow list example values.

Application Configuration

Scheduler Configuration

  • scheduler.frequency 60000
  • scheduler.startDelay 0

Batch Aggregator Configuration

  • page.size 100

Watermarking default last query timestamp e.g. 2017-12-13T03:00:59Z

  • watermark.defaultExpression 2017-12-13T03:00:59Z

Salesforce Connector configuration for company A

  • sfdc.a.username bob.dylan@orga
  • sfdc.a.password DylanPassword123
  • sfdc.a.securityToken avsfwCUl7apQs56Xq2AKi3X

Salesforce Connector configuration for company B

  • sfdc.b.username joan.baez@orgb
  • sfdc.b.password JoanBaez456
  • sfdc.b.securityToken ces56arl7apQs56XTddf34X
  • 00f10000003JzFxAAX

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. User Broadcast Template calls to the API can be calculated using the formula:

1 + X + X / ${page.size}

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

Divide by ${page.size} because by default, for each upsert API call, users are gathered in groups of a number defined by the ${page.size} property. Also consider that calls are executed repeatedly every polling cycle.

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

Customize It!

This brief guide provides a high level understanding of how this template is built and how you can change it according to your needs. As Mule applications are based on XML files, this page describes the XML files used with this template. More files are available such as test classes and Mule application files, but to keep it simple, we focus on these XML files:

  • config.xml
  • businessLogic.xml
  • endpoints.xml
  • errorHandling.xml


This file provides the configuration for connectors and configuration properties. Only change this file to make core changes to the connector processing logic. Otherwise, all parameters that can be modified should instead be in a properties file, which is the recommended place to make changes.


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

  1. During the Process stage, each Salesforce User is filtered depending on if it has an existing matching user in the Salesforce Org B.
  2. The last step of the Process stage groups the users and create/update them in Salesforce Org B.
  3. Finally during the On Complete stage the Template logs output statistics data into the console.


This file is conformed by two flows.

  • Scheduler flow - Contains the Scheduler endpoint that periodically triggers the watermarking flow and executes the batch job process.
  • Watermarking flow - Contains watermarking logic to query Salesforce for updated or created users who meet the defined criteria in the query since the last polling. The last invocation timestamp is stored using the Object Store component and updated after each Salesforce query.


This file handles how your integration reacts depending on the different exceptions. This file provides error handling that is referenced by the main flow in the business logic.


Published by
MuleSoft Organization
Published onJul 16, 2019
Asset overview

Asset versions for 2.1.x

Asset versions


SalesforceNo values left to add
BroadcastNo values left to add