Contact Free trial Login

Workday Connector 13.0 Examples - Mule 4

Anypoint Connector for Workday (Workday Connector) provides two financial management services examples that enable you to see how to configure Workday Connector using Anypoint Studio and Anypoint Design Center’s Flow Designer:

Prerequisites

You must have:

  • Access to Workday

  • Your Workday username, password, and tenant name

Add a Fund to the Workday Financial Management Service (Studio Example)

This example uses the Invoke operation to insert a fund in the Workday financial management service.

Configure HTTP Listener

Configure HTTP Listener to initiate a Mule flow when a call is made to the / account path on localhost, port 8081.

This example uses variables for some field values. You can either:

  • Replace the variables with their values in the code.

  • Provide the values for each variable in a properties file and then refer to that file from the connector configuration.

If you don’t know how to use a properties file, see Configuring Property Placeholders.

To configure HTTP Listener:

  1. Create a new Mule project in Studio.

  2. In the Mule Palette view, search for http and select the Listener operation:

    Select the Listener operation in the Mule Palette view.

    Select the Listener operation

  3. Drag the Listener operation onto the canvas.

  4. In the Listener configuration, click + next to the Connector configuration field to add a global element.

  5. Click OK to accept the defaults.

  6. Set the Path field to /:

    Listener configuration
    Figure 1. Set the Path field in the Listener configuration.

Add a Transform Message Component to Attach the Metadata

To add and configure a Transform Message component:

  1. In the Mule Palette view, search for transform and select Transform Message:

    Select the Transform Message component
    Figure 2. Select Transform Message in the Mule Palette view.
  2. Drag the Transform Message component onto the canvas, to the right of the Listener component.

  3. In the Transform Message configuration, overlay the brackets in the Output section with this XML:

    %dw 2.0
    output application/xml
    ns ns0 urn:com.workday/bsvc
    ---
    {
      ns0#Put_Fund_Request @(ns0#Add_Only: true, ns0#version: "v35.0"): {
        ns0#Fund_Data: {
          ns0#Fund_Name: "I.M.F",
          ns0#Fund_Type_Reference: {
            ns0#ID @(ns0#'type': 'Fund_Type_ID'): "FUND_TYPE-6-3"
          }
        }
      }
    }

The following XML shows sample input to the Transform Message component

<ns0:Put_Fund_Request xmlns:ns0="urn:com.workday/bsvc" Add_Only="true" version="v35.0">
  <ns0:Fund_Data>
    <ns0:Fund_Name>I.M.F</ns0:Fund_Name>
    <ns0:Fund_Type_Reference>
      <ns0:ID type="Fund_Type_ID">FUND_TYPE-6-3</ns0:ID>
    </ns0:Fund_Type_Reference>
  </ns0:Fund_Data>
</ns0:Put_Fund_Request>

The following screenshot shows the corresponding output, as it appears in the Output section of the Transform Message configuration:

Transform Message output
Figure 3. Output in the Transform Message configuration

Add and Configure the Financial Management Operation

  1. In the Mule Palette view, search for workday and select the Financial management operation.

  2. Drag the Financial management operation onto the canvas, to the right of the Transform Message component.

  3. In the Financial management configuration, click + next to the Connector configuration field to add a global element.

  4. Configure the global element as follows:

    • Configuration Name: My_Workday_Connection

    • Connection: Basic authentication api

    • Password: ${workday.password}

    • Host Name: Leave the default, impl-cc.workday.com

    • Tenant Name: ${workday.tenantName}

    • Username: ${workday.userName}

  5. Click Test Connection to ensure your username, password, and tenant name are correct.

  6. Click OK.

  7. In the properties window, select Put_Fund in the Operation field.

Add a Logger Component to Display the Response in the Mule Console

  1. In the Mule Palette view, search for logger and select Logger (Core).

  2. Drag the Logger component onto the canvas, to the right of the Financial management component.

  3. Configure the following fields:

    Field Value

    Display Name

    Enter Log Response.

    Message

    Enter `#[payload]`.

    Level

    Leave the default, INFO.

  4. Save the project.

  5. Test the app by sending a request to / on port 8081.

  6. You will receive an XML response similar to this one:

<wd:Put_Fund_Response xmlns:wd="urn:com.workday/bsvc" wd:version="v35.0">
    <wd:Fund_Reference wd:Descriptor="I.M.F">
        <wd:ID wd:type="WID">THE_WID_ID_NUMBER</wd:ID>
        <wd:ID wd:type="Fund_ID">FUND-6-399</wd:ID>
    </wd:Fund_Reference>
</wd:Put_Fund_Response>

XML for the Financial Management Example

Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:

?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns:workday="http://www.mulesoft.org/schema/mule/workday"
	xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/workday http://www.mulesoft.org/schema/mule/workday/current/mule-workday.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<workday:config name="My_Workday_Connection" doc:name="Workday Config" >
		<workday:basic-authentication-api-connection password="${workday.password}" tenantName="${workday.tenantName}" userName="${workday.userName}" />
	</workday:config>
	<http:listener-config name="HTTP_Listener_config1" doc:name="HTTP Listener config" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<workday:config name="My_Workday-Connection" doc:name="Workday Config" >
		<workday:basic-authentication-api-connection password="${workday.password}" tenantName="${workday.tenantName}" userName="${workday.userName}" />
	</workday:config>
	<flow name="workday-13-test-exampleFlow" >
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config1" path="/"/>
		<ee:transform doc:name="Transform Message" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
ns ns0 urn:com.workday/bsvc
---
{
  ns0#Put_Fund_Request @(ns0#Add_Only: true, ns0#version: "v35.0"): {
    ns0#Fund_Data: {
      ns0#Fund_Name: "I.M.F",
      ns0#Fund_Type_Reference: {
        ns0#ID @(ns0#'type': 'Fund_Type_ID'): "FUND_TYPE-6-3"
      }
    }
  }
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<workday:financial-management doc:name="Financial management" config-ref="My_Workday-Connection"/>
		<logger level="INFO" doc:name="Log Response"  message="#[payload]"/>
	</flow>
</mule>

Create a Workday Position Request (Flow Designer Example)

A financial position shows the current balances for assets, liabilities, and equity in an organization. This example creates a Workday position request:

  1. Create a Mule application in Flow Designer.

  2. Add and configure HTTP Listener as a trigger for your flow.

  3. Set the Path field to /create_position and use the default configuration for the HTTP Listener connection.

  4. Add the Transform DataWeave component to your flow.

  5. Provide this transformation script to DataWeave:

    %dw 2.0
    
    ns ns0 urn:com.workday/bsvc
    
    
    output application/xml
    ---
    {
      ns0#Create_Position_Request: {
        ns0#Business_Process_Parameters: {
          ns0#Auto_Complete: true,
          ns0#Run_Now: true
        },
        ns0#Create_Position_Data: {
          ns0#Supervisory_Organization_Reference: {
            ns0#ID @("ns0:type": "Organization_Reference_ID"): "SUPERVISORY_ORGANIZATION-6-226"
          },
          ns0#Position_Data: {
            ns0#Job_Posting_Title: "General Manager"
          },
          ns0#Position_Group_Restrictions_Data: {
            ns0#Availability_Date: "2019-07-06",
            ns0#Earliest_Hire_Date: "2019-07-08"
          },
          ns0#Edit_Assign_Organization_Sub_Process: {
            ns0#Business_Sub_Process_Parameters: {
              ns0#Skip: true
            }
          },
          ns0#Request_Default_Compensation_Sub_Process: {
            ns0#Business_Sub_Process_Parameters: {
              ns0#Skip: true
            }
          },
          ns0#Assign_Pay_Group_Sub_Process: {
            ns0#Business_Sub_Process_Parameters: {
              ns0#Skip: true
            }
          },
          ns0#Assign_Costing_Allocation_Sub_Process: {
            ns0#Business_Sub_Process_Parameters: {
              ns0#Skip: true
            }
          }
        }
      }
    }
  6. Input to Workday Connector is as follows:

    <ns0:Create_Position_Request xmlns:ns0="urn:com.workday/bsvc">
      <ns0:Business_Process_Parameters>
        <ns0:Auto_Complete>true</ns0:Auto_Complete>
        <ns0:Run_Now>true</ns0:Run_Now>
      </ns0:Business_Process_Parameters>
      <ns0:Create_Position_Data>
        <ns0:Supervisory_Organization_Reference>
          <ns0:ID ns0:type="Organization_Reference_ID">SUPERVISORY_ORGANIZATION-6-226</ns0:ID>
        </ns0:Supervisory_Organization_Reference>
        <ns0:Position_Data>
          <ns0:Job_Posting_Title>General Manager</ns0:Job_Posting_Title>
        </ns0:Position_Data>
        <ns0:Position_Group_Restrictions_Data>
          <ns0:Availability_Date>2019-07-06</ns0:Availability_Date>
          <ns0:Earliest_Hire_Date>2019-07-08</ns0:Earliest_Hire_Date>
        </ns0:Position_Group_Restrictions_Data>
        <ns0:Edit_Assign_Organization_Sub_Process>
          <ns0:Business_Sub_Process_Parameters>
            <ns0:Skip>true</ns0:Skip>
          </ns0:Business_Sub_Process_Parameters>
        </ns0:Edit_Assign_Organization_Sub_Process>
        <ns0:Request_Default_Compensation_Sub_Process>
          <ns0:Business_Sub_Process_Parameters>
            <ns0:Skip>true</ns0:Skip>
          </ns0:Business_Sub_Process_Parameters>
        </ns0:Request_Default_Compensation_Sub_Process>
        <ns0:Assign_Pay_Group_Sub_Process>
          <ns0:Business_Sub_Process_Parameters>
            <ns0:Skip>true</ns0:Skip>
          </ns0:Business_Sub_Process_Parameters>
        </ns0:Assign_Pay_Group_Sub_Process>
        <ns0:Assign_Costing_Allocation_Sub_Process>
          <ns0:Business_Sub_Process_Parameters>
            <ns0:Skip>true</ns0:Skip>
          </ns0:Business_Sub_Process_Parameters>
        </ns0:Assign_Costing_Allocation_Sub_Process>
      </ns0:Create_Position_Data>
    </ns0:Create_Position_Request>
  7. Select the connector.

  8. Select the web service and the operation with content. In this example, the content is the payload.

    Ensure that the values are available as menu items in the Service and Operation fields. The names become available once the connector loads the metadata for them. Do not type the names manually.

  9. Set up, test, and save a Workday configuration for the connection to the Workday server, for example:

    • Name: My Workday Config

    • Connection: Basic Authentication Api

    • Username: my_user_name

    • Password: my_password

    • Tenant Name: my_tenant_name

    • Host Name: impl-cc.workday.com

    If the connection test is unsuccessful, correct any invalid connection parameters and retest the connection.

  10. Add the Logger component to your flow and set payload as the message.

  11. Deploy, sync, or run the app.

  12. To test the app, open http://<Deployment_url>:8081/create_position from a browser or from an app such as cURL.

    The response is as follows:

    <wd:Create_Position_Response xmlns:wd="urn:com.workday/bsvc" wd:version="v35.0">
      <wd:Event_Reference>
      <wd:ID wd:type="WID">WID_VALUE</wd:ID>
      </wd:Event_Reference>
      <wd:Position_Reference>
        <wd:ID wd:type="WID">WID_VALUE</wd:ID>
        <wd:ID wd:type="Position_ID">P-11158</wd:ID>
      </wd:Position_Reference>
    </wd:Create_Position_Response>

    The logger displays this message:

    {Create_Position_Response={Event_Reference={ID=WID_VALUE}, Position_Reference={ID=P-11158}}}