Talking about my Salesforce.com and MuleSoft experience

Edgar Moran

Software Engineer, passionate for tech stuff video and photography, Salesforce and Mulesoft developer


Our Newsletter

Subscribe to get new post notifications.

* indicates required




Creating Invoice with Line items including custom fields using NetSuite Mulesoft connector.

Edgar MoranEdgar Moran

In this post I will show how to create an Invoice with Items including custom fields using Netsuite Mulesoft connector. In order to achieve it we are going to need:

  • We need to have Netsuite Credentials (email, password, account number, roleId and depending of what environment you're going to use)
  • Create a project with AnyPoint Studio
  • Drag the HTTP connector and set the properties (to work in local environment for now) Host: localhost and port 8081
  • Drag the Netsuite connector in your flow, create the connector configuration and set the properties (is a best practice to have a Content Place Holder to grab those properties from "properties files"). Your connector should looks like this:


  • Select the Operation: Create Record and Record Type INVOICE and in the "Record Attributes section" just leave it with #[payload]
  • After that, just drag a DataWeave connector just before the Netsuite one (this will allow Dataweave to show you the attributes the connector is expecting and in some cases also cast the current transformation to the right type)
  • Then we need to start populating the values in the different fields in the NetSuite connector (mapping). This mapping will depend of what information is required and linked to the company flow.

In this next GIST I will show how the DataWeave definition looks like, so you can get a better idea:

As you can see, this payload includes Invoice information, Line Items information and also how to add custom fields values. is important to mention some of the custom fields values should be set correctly depending of the field type, for example: String fields starts with StringCustomFieldRef__, date Fields DateCustomFieldRef__ and for picklist or select list you should use SelectCustomFieldRef__. I have a sample gist with this scenarios in this gist

  • After we set the mapping, the connector is ready to execute the action once it receives the payload.
  • Next step is catch the responses in my case I will show only a status code and the internal Id if the Invoice was created correctly:
	message:"Invoice created in NetSuite",

otherwise I will need to catch the exception and the current error to make the endpoint nicer

I will set a variable with the error with this MEL expression: #[exception.cause.message] and a dataweave component to return the result like this:

	message:flowVars.detailedError as :string,

And thats about it, hopefully this will be useful as I spent a lot of time trying to figure out the situation with custom fields.

Edgar Moran

Edgar Moran

Software Engineer, passionate for tech stuff video and photography, Salesforce and Mulesoft developer