Anypoint Studio Visual Editor
-
In the Anypoint Studio Visual Editor, click the Global Elements tab at the base of the canvas to access a list of all global elements in an application.
-
Click Create to add a new global element.
-
In the Choose Global Type wizard, navigate the directories or use the filter to select the type of global element you wish to create, then click OK.
-
Define the configurable parameters of your global element in the Global Element Properties window that appears, then click OK to save.
To create a new global element from within a local element you placed in your flow:
-
Click one of the pieces of your flow whose global element you want to create/configure. A box should appear around the element in the flow — take for instance, an IMAP connector that has been clicked on:
-
In the properties pane that appears below the canvas, click the plus icon next to the Connector Configuration or similar reference field dropdown menu. (Click the Edit icon to edit an existing global element you may have already created.)
-
Fill in the required fields for the type of global element you set out to create.
-
XML Editor or Standalone
-
In the XML Editor in Studio, or other text editor, open your XML configuration file for your Mule application.
-
Create a global element for your Mule flow element above and outside any <flow> you may have defined already in your application.
-
Define the attribute values that your local element will reference, within the global element you create.
-
To configure a local element in the flow to reference a global element, add a
config-ref
orconnector-ref
attribute inside the local element, which appears inside the<flow>
. The example below has a global element for the Salesforce connector (sfdc:config
) -
The flow includes a Salesforce connector (
sfdc:create
) that references the global Salesforce element, named "Salesforce1":<sfdc:create config-ref="Salesforce1" type="" doc:name="Salesforce Connector">
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/sfdc http://www.mulesoft.org/schema/mule/sfdc/current/mule-sfdc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<sfdc:config name="Salesforce1" username="username" password="password" doc:name="Salesforce" securityToken="IQZjCdweSF45JD90Me2BWLLVDo">
<sfdc:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW"/>
</sfdc:config>
<flow name="Contacts_to_SFDC" doc:name="Contacts_to_SFDC">
...
<sfdc:create config-ref="Salesforce1" type="" doc:name="Salesforce Connector">
<sfdc:objects ref="#[payload]"/>
</sfdc:create>
</flow>
</mule>