Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


Use TRIMLEFT or TRIMRIGHT in Calculated Fields

Post Author: Joe D365 |

Calculated fields are still relatively new to CRM, but there have been some enhancements in the latest update that already expands their capabilities. In today's blog, we will show you how to use some of these capabilities. Let's get started!

Say for example you have a company that uses social security numbers or some other type of number that you don't want all employees to have access to, but you still need some employees to have access to part of the number for other purposes. By using a combination of secure fields and the TRIMLEFT or TRIMRIGHT function with calculated fields, you can achieve this. For our example today, we are going to use the telephone number field and show a new field that displays the last four digits of the phone number. First off, we need to create a new field called Last Four:

You can see that we selected Calculated for Field Type. When you click Edit you will be able to set up the calculations. It looks the same as creating a Business Rule, doesn't it? In this Calculation, it's checking to see if the Main Phone contains data, and if it does, it will perform the TRIMLEFT calculation to the data in that field and will set the new field to that calculated value. In other words, if the Main Phone contains data, it trims the first nine characters from that field and displays the remaining characters in the new field.

In the following view, the calculated field took the phone number, stripped off the first nine characters, and put the remaining characters in the Last Four field. In this case, because the phone numbers had 13 characters exactly, including spaces and symbols, it left only four in the new field.

If you have a field that has a variable length for characters, you may be left with more or fewer characters in your calculated field. This process works best for fields where the length is constant, like a custom account number field, which could be populated by one of our PowerPacks, PowerAutoNumber. You can then use field level security to hide the original field if necessary, so that only certain people can see the full value of the field and others can only see a partial value, which they may need to do something like identify a customer by the last four digits of their account number or social security number.

Hopefully this post helps you understand calculated fields a little bit better! And until next time, happy CRM'ing!

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

PowerObjects Recommends