Work Market Developer Portal

WorkMarket Developer Portal

We are building the modern work market,
a frictionless exchange between businesses and workers.
See API Docs

    

Salesforce Integration (Sample)

Want Help?

WorkMarket's Professional Services team can help you integrate your Salesforce instance with the WorkMarket platform. Contact us at solutions@workmarket.com.

This sample integration demonstrates creating an assignment in WorkMarket from a corresponding object in Salesforce, including pricing, location, scheduling, and custom field information.

Salesforce Integration Video

There is a video on our product video site that highlights the WorkMarket integration with Salesforce.

Setup

Setting this demo up in your salesforce environment requires a few customizations in the following areas:

  • Custom Labels for environment-specific constants
  • Custom object to represent a WorkMarket Assignment in SF
  • The Apex classes and trigger included in this repo

Follow the instructions below to get started.

Custom Labels

This relies on Custom Labels for storing certain constants related to the integration. You will need to create the following Custom Labels in your SF instance:

Label Name
Description
Example

WM_API_Error_Email

Email to receive error messages

you@yourdomain.com

WM_API_Token

WM API token (not access token)

SdnpUD319F9fda98uFaZpi92fxXxaYhmqcJ2aL

WM_API_Secret

WM API secret

VeC315dwF9ablGXikVx

WM_URL

The base URL of the WM environment you are use

WM_CF_Default_Grp_ID

ID of your default custom fields group in WM

539

WM_CF_Object_SF_ID

ID of the Salesforce Object ID field in your custom field group.

8943

Custom Assignment Object

For this sample code, we have created a custom Assignment object that represents a WM assignment. You could pull these fields from a customized Case, Opportunity, or whatever you prefer to use. You'll want to create a layout for this object as well to make it usable.

Field Name
API Name
Data Type

Address 1

Address_1__c

Text(120)

Address 2

Address_2__c

Text(120)

Assign By Email

Assign_By_Email__c

Text(100)

Assigned Resource

Assigned_Resource__c

Lookup(Contact)

Assignment ID

Assignment_ID__c

Text(12) (External ID) (Unique Case Insensitive)

City

City__c

Text(120)

Country

Country__c

Text(3)

Custom Field 1

Custom_Field_1__c

Text(8)

Description

Description__c

Long Text Area(32768)

End Time (Site Local)

End_Time_Site_Local__c

Date/Time

Group

Group__c

Picklist

Max Hours/Units

Max_Hours_Units__c

Number(5, 0)

Max Hours @ Secondary Rate

Max_Hours_Secondary_Rate__c

Number(4, 0)

Postal Code

Postal_Code__c

Text(12)

Pricing Type

Pricing_Type__c

Picklist ("Flat Rate", "Hourly", "Dual Rate Hourly", "Per Unit")

Rate

Rate__c

Currency(5, 2)

Resource Email

Resource__c

Text(100)

Resource Name

Resource_Name__c

Text(128)

Resource Phone

Resource_Phone__c

Phone

Secondary Rate

Secondary_Rate__c

Currency(5, 2)

Skills & Specialties

Skills_Specialties__c

Text Area(255)

Special Instructions

Special_Instructions__c

Long Text Area(32768)

Start Time (Site Local)

Start_Time_Site_Local__c

Date/Time

State / Province / Region

State_Province_Region__c

Text(4)

Status

Status__c

Picklist ("Draft", "Published to WorkMarket")

Template

Template__c

Picklist

Title

Title__c

Text(255)

View in WorkMarket

View_in_Work_Market__c

Formula (Text) "$Label.WM_URL & '/assignments/details/' & Assignment_ID__c"

Apex Classes

Got MuleSoft?

WorkMarket has a certified MuleSoft Connector which can make integrating with your workflows a breeze. Learn more.

For this sample integration, you'll need 4 Apex classes and 1 trigger class. You can get the source code from our public GitHub repository listed below.

Tying it All Together

Now that you've added the required Custom Labels, created the Assignment custom object, and added the Apex classes & trigger, let's bring it all together.

Create a new Assignment object and enter (at least) the following fields:

  • Title
  • Description
  • Start date / time
  • Location Address fields (Address 1, Address 2, City, State, Postal Code, Country)
  • Pricing Type
  • Rate
  • Max Hours/Units (if "Hourly", "Unit", or "Dual Rate Hourly" selected)
  • Max Hours @ Secondary Rate (if "Dual Rate Hourly" selected)

Set the Status field to "Draft" and Save.

Change the status to "Published to WorkMarket" and Save.

Wait a few seconds and refresh the Assignment details page. If you see a number in the Assignment ID field, it worked! Click the "View In WorkMarket" link to see it.