Pages

Monday, November 20, 2017

Salesforce: Time field (Beta)

This blog is written with Winter '18 release, where time field still in Beta, let us expect many improvements in Spring '18 release and beyond. This feature is enabled by default in Sandbox, but you need to request Salesforce if you would like to enable it for the production.

This function has been requested in Idea Exchange since 10 years ago, and at this moment it has 5,530 points.

There are 2 types of Time fields in Winter '18 beta:
- as a Custom field with Data Type = Time, or
- as a Formula field with Return type = Time

1. Custom field with Data Type = Time
As of now, the display in Lightning is not great, but much nicer in Classic.


As this is not formula field, users with appropriate permission able to type in the time directly into the page layout.

In Classic, you can enter the time in 24 hours format:
- "18", when you save, this will save as 6:00 PM
- "18:12", when you save, this will save as 6:12 PM
- "7:12", when you save, this will save as 7:12 AM
- "7.32", when you save, this will save as 7:00 AM  --> 18.12 (dot) will be ignored

You also can enter the time in 12 hours format with AM/PM (in Classic):
- "12 AM", when you save, this will save as 12:00 AM
- "12:30PM", when you save, this will save as 12:30 PM

While in Lightning, you need to enter in pattern of HH:MM:SS, example: 07:30:00, or  19:00:00, once stored, it will display as 07:30:00.000Z or 19:00:00.000Z


2. Formula Field return Time
Sample: MINUTE(Approved_Time__c), HOUR(Approved_Time__c)
To calculate hours and minutes between time fields, you cannot just minus or add them directly, Submission_Time__c - Approved_Time__c will return error "Incorrect parameter type for operator '-'".

To display the difference between 2 times, you can use formula field to return the formula as text, example:
IF( (MINUTE(Approved_Time__c) - MINUTE(Submission_Time__c)) >=0,
TEXT((HOUR(Approved_Time__c) - HOUR(Submission_Time__c)))
& ":" &
TEXT((MINUTE(Approved_Time__c) - MINUTE(Submission_Time__c))),
TEXT((HOUR(Approved_Time__c) - HOUR(Submission_Time__c) - 1))
& ":" &
TEXT((MINUTE(Approved_Time__c) - MINUTE(Submission_Time__c) + 60))
)

To read the complete documentation, read this article, and if you have further questions, feel free to join Custom Time Field success community.

Update since Spring '18 release, now you can calculate time field to return Number, example:
End_Time__c - Start_Time__c
This formula will return the time difference in milliseconds; 1 hour = 3,600,000 milliseconds.



Reference:


Saturday, November 18, 2017

Enable Record Type with Permission Set

Back to the basic series - permission set for the record type access.

I had a discussion with a user group member, which is subject matter expert (Salesforce biz owner) in his company. He is using Record Type to differentiate Account Type, where the different type of Account has the different layout. This is a good usage of the record type. But, he also complains his workload because of a special record type that only able create by him as the biz owner, salespeople are not allowed to create this special type of Account, but only able to see.

He would like to give the ability to a sales support user ability to create that special Account type, let's call it "Not-normal" for this blog. But, he also not able to make that sales support user have the same Profile as him.

Solution: use Permission Set
Create a new permission set and assign it to that Sales support.
When you are in the Permission Set, select Object Settings, for the object (in this case is Accounts), you will see Account: Record Type Assignments and enable Not-normal record type.



Then assign the permission set to that sales support user, I'll not discuss how to assign the permission set in this blog, but you just need to click "Manage Assignments" button.






Page-level ad