Getting Started with Process Builder – Part 67 (How to fix MALFORMED_ID error)

Getting Started with Process Builder – Part 67 (How to fix MALFORMED_ID error)

Last Updated on June 23, 2017 by Rakesh Gupta

I want to thank, each reader, and followers of automationchampion.com, for their support and feedback(s). Some of you requested me to write a blog post to explain (1) MALFORMED_ID Error; and, (2) how to solve it. 

I have and will continue to, try my best to incorporate suggested topics, from readers and followers of my blog, in my upcoming articles.

Process Builder is a way of automating business processes. It is an upgraded version of the Workflow Rule. Whenever a user creates a process, the system automatically creates a Visual Workflow – and a Flow Trigger (which is now deprecated) – to call the Flow. Creation of the Flow happens behind the scenes; and therefore, a user does not need to interact with these ‘shadow’ (behind the scenes) Flows. Process Builder is a powerful tool for system administrators and developers to implement business processes without writing code. However, with great power comes great responsibility  If a user starts creating a new process for each requirement – or creating processes without understanding Salesforce limitations – then, a user may encounter many issues, either in future or, during testing/deployment phase.

In my last post Getting Started with Process Builder – Part 66 (How to fix FIELD_INTEGRITY_EXCEPTION Error), I discussed how to solve FIELD_INTEGRITY_EXCEPTION error by passing the correct record ID to Process Builder action. 

This article goes one step further; it explains another common error   MALFORMED_ID Error. The article shows – (1) why errors could occur; (2) how to identify errors (by using a system generated fault email/debug log); and, finally, (3) how to solve the problem.

Business Use case

Donna Serdula is working as a System administrator at Universal Containers (UC). UC implemented Account Management a few years ago in Salesforce. Serdula has a requirement from her manager that, as soon as a Contact gets created, without assigning it to an account, then auto assign such Contacts to a global account ‘Customers with no account’‘. 

Global account’ named ‘Customers with no account’? What is that?

Well, in this case, a ‘global account’ is nothing but a ‘holding place’ for unassigned contacts – i.e., contacts, that, when created, could not, or did not, get assigned to an account. 

For instance, suppose a User creates a contact named John Smith; but, at this point, the User is not sure to which account John Smith belongs to.

Leaving Account field blank, while creating a contact, may create data integrity issue(s). Therefore, it would behoove a User to collect all unassigned contacts in one central place – in our case, that would be a global account named ‘Customers with no account’ account.

Let us continue with our aforementioned John Smith use case.  Now, suppose, that few months later, the User learns that John Smith works for Acme Corporation, and therefore, he belongs to Acme Corporation Account.

So, in a situation(s) like this, to maintain data integrity, when creating a John Smith contact, the User can assign John Smith to ‘Customers with no accounts’ ‘holding’ account. And then, as soon as the User finds out that John Smith belongs to Acme Corporation, the User can click on the Contact Tab, look for John Smith, and then, update John Smith’s Account from ‘Customers with no account’ to Acme Corporation.

What is MALFORMED_ID Error?  

A user mostly encounters a MALFORMED_ID error when he/she populates(1) a lookup field, ID with invalid characters; or (2) populates an ID with length less than 15 characters

For example, while updating a contact via Process Builder if, in the place of AccountId, a user passes a 14 digit ID of an account record or ABC in place of account ID, then, the user will encounter MALFORMED_ID error.

Update Contact with Global Account ID
Update Contact with invalid Account ID

Below, I will show you how to avoid getting a MALFORMED_ID Error while using the Process Builder.

First, I will update a contact by passing a wrong ID (14 digits account ID) for contacts that are not assigned to an account when it is created. 

This will generate a MALFORMED_ID error because you are only allowed to pass 15 digits valid account ID. 

Next, I will show you how to identify the root cause behind MALFORMED_ID error followed by a way to solve it. 

Let us create a Process that generates a MALFORMED_ID error

There are few possible solutions for the above business scenario, but we will use the Process Builder and Custom Label to solve it. Follow the instructions below to create a Process for the above business requirement

1. To solve the above business requirement, you must first create a Global account (Customers with no account) as shown in the following screenshot:

2. Click on Setup | Build | Create | Custom Labels.
3. Click on New Custom Labels, it will open the new window for you. Now create a new custom label to store the Global account ID (Customers with no account) – remove the one characters from account Id to make it 14 digits, as shown in the following screenshot:

CUSTOM LABEL – TO STORE Account ID
Custom label – To store account ID

4.  Our next task is to create a Process Builder on the Contact object to update the account Id, if the contact is not associated with an account. Click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder.
5.
 To create a new process from scratch, click on the New Button available on Process Management page. A popup will appear where you must enter the Name (Use
Assign contact to global account as a name)API Name and Description as shown in the screenshot below: 

Define Process Properties
Define Process Properties

6. Click on Object node to add object and then select Contact object. For the entry criteria, Select when a record is created or edited, as shown in the screenshot below.

Once done, click on the Save button.

7. The next task is to add Process Criteria. To do this, click on Add Criteria, and then, enter NameType of action and set filter conditions as shown in the following screenshot.

  •  [Contact].AccountId Is null Boolean True

8. The next step is to add an Immediate action to the Process, to associate contact with the global account, as shown in the following screenshot:

Choose a Custom Label
Choose a Custom Label

–> If you don’t know about custom Label and how to use it in Process Builder, then you must read this article Getting Started with Process Builder – Part 60 (Just say no to hard-coded ID)

Once you’re done click on Use this Formula (#5) button. Add a row to associate a contact with global account – in our case, ‘Customers with no account’.

At the end, Update Records action should look like the following screenshot: 

Update Records - Update contact's account
Update Records – Update contact’s account

9. Once done, click on the Save button, it will redirect you to Process canvas. Finally, the Process will look like the following screenshot:

Don’t forget to activate the Process by clicking on the Activate button.

It’s time to test the Process

Create a contact record with no account associated with it, as shown in the following screenshot:

Create a new contact
Create a new contact without any associated account

Once you’re done, click on the Save button. Boooommmm, you encounter MALFORMED_ID error, as shown in the following screenshot:

MALFORMED_ID Error
MALFORMED_ID Error

–> As mentioned earlier, the reason behind the error is, we are updating Contact record’s Account_Id field with invalid record Id – in the current scenario, with a 14 digit record ID instead of a 15 digit record ID.

If you see MALFORMED_ID errors, it means that the field is expecting a valid Salesforce ID. A valid Salesforce ID means that an ID that meets ID field’s requirements, to resolve MALFORMED_ID error.

Resolve MALFORMED_ID error

To fix the MALFORMED_ID error in a Process Builder or a Flow, you have to pass the correct Id for a lookup field. As we are using Custom Label to pass Account Id, now we will update the custom label with correct ID for the account. 

Perform the following steps to solve the MALFORMED_ID error in a Process:

1. Click on Setup | Build | Create | Custom Labels
2. Open Global account ID Custom Label by clicking on the Name, that you created a moment back. Then, click on the Edit button and update Account Id field with correct ID, as shown in the following screenshot:

Update custom label with valid Account ID
Update custom label with valid Account ID

3. Once done, click on the Save button. 

–> If you are using Process Builder to dynamically pass the ID (Like [Account].Id or something like this) then update your Process. At the end, you have to make sure that you are passing correct ID through the lookup field. 

It’s time to test the Process

Create a contact record with no account associated with it, as shown in the following screenshot:

Create a new contact
Create a new contact with no account

Once you are done, click on the Save button. Notice that, Contact is created and assigned to the Global account (Customers with no account) record by the Process. 

Proof of concept
Proof of concept
Technical Editor and Proofreader: - Munira Majmundar

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

 

One thought on “Getting Started with Process Builder – Part 67 (How to fix MALFORMED_ID error)

  1. Nice tip.
    I had a problem on the Process Criteria, where I was picking [Contact].Account.Id instead of [Contact].AccountId (without the dot ‘.’). Once I changed it, it worked.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.