Default Sort Order of sObjects
- The label of the sObject type.
For example, an Account sObject will appear before a Contact.
- The Name field, if applicable.
For example, if the list contains two accounts named A and B respectively, account A comes before account B.
- Standard fields, starting with the fields that come first in alphabetical order, except for the Id and Name fields.
For example, if two accounts have the same name, the first standard field used for sorting is AccountNumber.
- Custom fields, starting with the fields that come first in alphabetical order.
For example, suppose two accounts have the same name and identical standard fields, and there are two custom fields, FieldA and FieldB, the value of FieldA is used first for sorting.
Not all steps in this sequence are necessarily carried out. For example, if a list contains two sObjects of the same type and with unique Name values, they’re sorted based on the Name field and sorting stops at step 2. Otherwise, if the names are identical or the sObject doesn’t have a Name field, sorting proceeds to step 3 to sort by standard fields.
For text fields, the sort algorithm uses the Unicode sort order. Also, empty fields precede non-empty fields in the sort order.
This is an example of sorting a list of Account sObjects. This example shows how the Name field is used to place the Acme account ahead of the two sForce accounts in the list. Since there are two accounts named sForce, the Industry field is used to sort these remaining accounts because the Industry field comes before the Site field in alphabetical order.
var userId = $A.get(“$SObjectType.CurrentUser.Id”);
Sometimes we get such a scenario, we may need to create CaseMilestones- especially when you are doing data migration from Salesforce-to-Salesforce; but Salesforce does not allow to create CaseMilestone through custom means.
But we can follow the below steps to insert it in new org same as we have in current org (assuming that you have setup Entitlement and Milestone in new org same as existing org)
- Create case with Entitlement with these key fields:
- SlaStartDate: Copy it from Current Case
- EntitlementId = Can be given.
- IsStopped = can be set to pause the milestone- especially for active milestones. Later we can resume this by setting value to false.
- If we provide Entitlement Field while creating the case as mentioned above, system automatically creates related Milestone with StartDate as SlaStartDate of Case record.
- Now you can update the completion date of CaseMilestone record same as Completion Date of existing CaseMilestone in old org.
Periodically throughout your day you check your opportunities report, and after opening it, you always edit a filter to show New Business or Existing Business. (The Type filter includes both New Business and Existing Business by default.)
Instead of loading the report, editing the filter, and reloading the report, create two bookmarks. One with a filter value parameter for New Business, and one with a filter value parameter for Existing Business. Take note of the opportunities report URL.
Edit the URL to set the Type filter value to New Business by appending the parameter &fv0=New%20Business. The full, bookmarked URL reads:
Let’s take a closer look at what the parameter means.
- & — Denotes a new parameter in the URL. If no other parameters are present in the URL, then substitute ? in place of &.
- fv0 — The fv stands for “filter value,” and is the name of the parameter. The 0 is the numerical order in which the filter appears in the report. (The first filter is 0, the second filter is 1, the third is 2, and so forth.) Standard filters don’t count in this order, and can’t be filtered using URL parameters, although they appear as the first three filters on any report. To set the value of the fifth filter in the report, specify fv4. In our example, we’re filtering the first field filter in the report, the Type filter.
The order in which filters appear in Lightning Experience on the report run page isn’t necessarily the order that filters appear in the report. Locked filters are listed beneath unlocked filters on the run page, but aren’t necessarily ordered after all the unlocked filters. To see the order of filters in your report, refer to their order in the Report Builder. Alternatively, make a GET call to /services/data/v39.0/analytics/reports/<report ID>/describe and note their order in the JSON response.
- =New%20Business — Specifies that the Type filter value is New Business.
The parameter value must be URI encoded, which means certain characters (such as spaces) must be written in a format that URLs can understand. In our example, the space (‘ ‘) between “New” and “Business” becomes %20 when URI encoded.
When you navigate to your opportunity report through the URL with a filter value parameter, the report opens filtered and ready to read.
- Only field filters support edits from URL parameters. Standard filters (role hierarchy filters, scope filters, date filters), cross filters, and row limit filters aren’t supported. Standard, cross, and row limit filters don’t count when listing filters — fv0 is the first field filter.
- Chart filters aren’t supported.
- Filter operators (like equals and greater than) can’t be modified via URL parameters.
- You can’t change the field being filtered via URL parameters.
- You can’t add new filters to reports using filter value URL parameters. You can only modify existing filters.
- You can’t delete filters from reports using filter value URL parameters. Setting a blank value filters by no text or numerals, but doesn’t remove the filter.
Requirement: a SAQL query to find the number of WEEKDAYS between two dates. Specifically, can use this SAQL query in a Compute Expression
SAQL Expression: Here dataset name is “cases”. Start date is Created Date of a Case record and End Date is ClosedDate of Case.
Algorithm is copied from here: https://help.salesforce.com/articleView?id=000004526&type=1.
q = load "cases"; q = filter q by ClosedDate_sec_epoch != 0; q = foreach q generate daysBetween(toDate("24-06-1985", "dd-MM-yyyy"), toDate(CreatedDate_sec_epoch)) % 7 as standardDateDiff, daysBetween(toDate(CreatedDate_sec_epoch), toDate(ClosedDate_sec_epoch)) % 7 as targetDatesDiff, Id as CaseId; q = foreach q generate (case when standardDateDiff == 0 then (case targetDatesDiff when 1 then 2 when 2 then 3 when 3 then 4 when 4 then 5 when 5 then 5 when 6 then 5 else 1 end) when standardDateDiff == 1 then (case targetDatesDiff when 1 then 2 when 2 then 3 when 3 then 4 when 4 then 4 when 5 then 4 when 6 then 5 else 1 end) when standardDateDiff == 2 then (case targetDatesDiff when 1 then 2 when 2 then 3 when 3 then 3 when 4 then 3 when 5 then 4 when 6 then 5 else 1 end) when standardDateDiff == 3 then (case targetDatesDiff when 1 then 2 when 2 then 2 when 3 then 2 when 4 then 3 when 5 then 4 when 6 then 5 else 1 end) when standardDateDiff == 4 then (case targetDatesDiff when 1 then 1 when 2 then 1 when 3 then 2 when 4 then 3 when 5 then 4 when 6 then 5 else 1 end) when standardDateDiff == 5 then (case targetDatesDiff when 1 then 0 when 2 then 1 when 3 then 2 when 4 then 3 when 5 then 4 when 6 then 5 else 0 end) when standardDateDiff == 6 then (case targetDatesDiff when 1 then 1 when 2 then 2 when 3 then 3 when 4 then 4 when 5 then 5 when 6 then 5 else 0 end) else 999 end) as result, targetDatesDiff as targetDatesDiff, CaseId as CaseId; q = foreach q generate (floor(targetDatesDiff / 7) * 5) + result as WeekDaysOpened, CaseId as CaseId; q = limit q 2000;
1. Ensure “Enable Case Feed Actions and Feed Items” is enabled under support settings. To modify Support settings : Go | Setup | Customize | Cases | Support Settings.
2. If you do not find the setting “Enable Case Feed Actions and Feed Items” under support settings, make sure “Feed Tracking” is enabled for case object. To enable Feed Tracking: Go | Setup | Customize | Chatter | Feed Tracking | Select Case object | Enable Feed Tracking.
3. The email Deliverability settings | Access level must be set to ‘All Email’ or this component will not render.
4. Please note that if you not at all find the Email Publisher action to add on Case page layout, it is because “Email to Case” is not enabled for the organization. To Enable: Go | Setup | Customize | Cases | Email to Case.