You need to sign in to do that
Don't have an account?
Benjamin Zerbib 3
Double returns number with decimal part
Hello everybody!
I have a short Apex Class that is supposed to paste a number in a Text field.
it's working but my issue is that it is pasting the number with a decimal value (example: '3.0' instead of '3').
How can I resolve this small issue, please?
Here is my code in case you need it:
Thanks a lot!
Benji
I have a short Apex Class that is supposed to paste a number in a Text field.
it's working but my issue is that it is pasting the number with a decimal value (example: '3.0' instead of '3').
How can I resolve this small issue, please?
Here is my code in case you need it:
public class CMC_Automation_Code { @InvocableMethod public static void updateAccount(List<String> AccountIds){ Double CMC_Value = 0; Account con=[SELECT Id, CMC_Auto_Number__c FROM Account where Id in:AccountIds]; List<Account> AccList = [SELECT Id, CMC_Auto_Number__c, CreatedDate FROM Account where CMC_Auto_Number__c != null order by CreatedDate desc limit 1]; if(AccList != null && AccList.size()>0){ CMC_Value = AccList[0].CMC_Auto_Number__c +1; } con.Global_Account_ID__c = 'CS-' + String.valueOf(CMC_Value); update con; } }
Thanks a lot!
Benji
As the CMC_Value is a Double value you are seeing even the decimal part.
try using the intValue();
For better understanding, you can check the below snippet of how it behaves.
count__c is a field on the account object.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
All Answers
As the CMC_Value is a Double value you are seeing even the decimal part.
try using the intValue();
For better understanding, you can check the below snippet of how it behaves.
count__c is a field on the account object.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
It's working!