Tip: Using Decimal class with Strings in Apex

CEO

Today I came across an interesting problem that reminded me of my Java days. A piece of Apex code written by some other developer was broken, when I did my fixes.

Here is some background about the broken code, lets say the file name is “ScaryMovie.cls

  • It tries to query a Number(18, 0) field from Sobject, lets say sobject is Mock__c, and number field is “Counter__c

  • Appends the number field to a String to create a URL

Read More: https://abhinav.fyi/tip-using-decimal-class-with-strings-in-apex/

Abhinav Gupta

First Indian Salesforce MVP, rewarded Eight times in a row, has been blogging about Salesforce, Cloud, AI, & Web3 since 2011. Founded 1st Salesforce Dreamin event in India, called “Jaipur Dev Fest”. A seasoned speaker at Dreamforce, Dreamin events, & local meets. Author of many popular GitHub repos featured in official Salesforce blogs, newsletters, and books.

https://abhinav.fyi
Previous
Previous

Fixed – “Compile Error: Type is not visible: test”

Next
Next

Force.com Developer Console Navigation Trick