Wednesday, April 13, 2016

Developer: Number fields and decimals observations....

If a field is created in Salesforce with Type as Number and Decimal places as 2, you will find that while the UI displays the number as 250.00 when you query the record using WorkBench you will be surprised to see the amount displayed as 250.0.

Now if the amount were to be entered as 250.01 thru the UI then on querying the field thru Workbench you will see the amount as 250.01.

In my case; I was doing a fixed length integration with an external system with a custom REST API created by me; surprisingly the output files did not have any issues and there was nothing for me to
do.

I thought this is just something good to know and depending on your situation you might have to take appropriate action.

Developer: How to validate and test Outbound Messages when integrating between systems?

If you are using the Workflow Outbound Message feature to integrate data with other systems then there is a need to validate data going from Salesforce. Basically, you need a staging area where you can route these XML messages and validate the data being sent.

Solution

Enter the url https://requestb.in/ in your browser and click on 'Create a request bin'.
A new bin URL will be created which you can use to route messages to before you test with the destination system.

Take this newly generated URL and use this as the destination endpoint URL for your XML message.

Execute a transaction that will cause the outbound XML message to be sent.
Load the request bin URL in your browser and you should see your message there.

Salesforce will keep sending these messages to the request bin as it does not receive an ACK message from the bin. Simply, navigate to the Monitor--Outbound Messages and delete the message so that salesforce stops posting messages over and over again to the RequestBin.

Admin: About Salesforce Deletes and Truncates....

Salesforce Standard objects do not provide the option to truncate tables. So, if you are loading lots of data in a standard object say Case or Accounts and needs rounds of iteration to load and delete records then you end up using the mass delete from the UI or the delete by ID's option of the data loader.

What if you custom objects in which you have tons of data being loaded and validated? Is there a easy way to manage data?


Solution

Well, Salesforce has a customizeable setting for custom objects called Enable Custom Object Truncate.

Truncating is a fast and easy way of deleting data.

Click on Your Name-->Setup-->Customize-->User Interface
Select Enable Custom Object Truncate.

Once you check this setting, locate the desired custom object and you should see a button called Truncate next to the Delete button.

Hit the Truncate button to delete transaction records related to the object; the meta-data is left untouched. The Delete button serves a different purpose and will outright delete your object so be wary of hitting that button by mistake.

Wednesday, April 6, 2016

Developer: Calculating DueDate excluding weekends

Very often while working with Cases and Entitlements you run into situation where you need to calculate the DueDate excluding weekends and in some cases Holidays are loaded in the system and your DueDate is to factor in Holidays as well.

For the purpose of this post, I am just considering that the requirement is to calculate DueDate excluding weekends.

Solutions

Identify the field which will act as the Start date from which to calculate the Due date.
Identify the field which will store the NumofDays that are to be be added to Start Date

Add a formula field to your object as follows:

CASE( 
MOD(DATEVALUE(SlaStartDate) - DATE(1900, 1, 7), 7), 
0, (DATEVALUE(SlaStartDate )) + SLANumOfDays__c + FLOOR((SLANumOfDays__c-1)/5)*2, 
1, (DATEVALUE(SlaStartDate )) + SLANumOfDays__c + FLOOR((SLANumOfDays__c)/5)*2, 
2, (DATEVALUE(SlaStartDate )) + SLANumOfDays__c + FLOOR((SLANumOfDays__c+1)/5)*2, 
3, (DATEVALUE(SlaStartDate )) + SLANumOfDays__c + FLOOR((SLANumOfDays__c+2)/5)*2, 
4, (DATEVALUE(SlaStartDate )) + SLANumOfDays__c + FLOOR((SLANumOfDays__c+3)/5)*2, 
5, (DATEVALUE(SlaStartDate )) + SLANumOfDays__c + CEILING((SLANumOfDays__c)/5)*2, 
6, (DATEVALUE(SlaStartDate )) - IF(SLANumOfDays__c>0,1,0) + SLANumOfDays__c + CEILING((SLANumOfDays__c)/5)*2, 
null)

Display the field on the UI, it will display the DueDate excluding weekends but does not factor in Holidays.

To factor in Holidays definitely require coding and will be addressed in another post.