Pages

Wednesday, March 27, 2013

Tips on Analytic Snapshots

click image for higher resolution image

Salesforce: Activities Archived

One day, a user comes to me, "Why I do not see some of my activities in the report, although they are visible in the page layout related list from an object"?

This is because Salesforce archive activities (tasks and events) that are over a year old, for activity with criteria:
  • Events with an ActivityDateTime or ActivityDate value greater than or equal to 365 days old
  • Tasks with an IsClosed value of true and an ActivityDate value greater than or equal to 365 days old
  • Tasks with an IsClosed value of true, a blank ActivityDate field, and created date is greater than or equal to 365 days ago

If you are using Data Loader, you need to select Export All instead of Export, and if using other API tools, make sure it calls queryAll() instead of query() function.

You also can filter on the isArchived field to find only the archived records. You can update or delete archived records, though you cannot update the isArchived field. If you use the API to insert activities that meet the criteria listed below, the activities will be archived during the next run of the archival background process.

Even the activities are archived, users will still see the activities in the Lightning page (under Activities component), Salesforce does not delete the records, so you can open the activity if you have the Activity Id. 

The activities archived will no longer show in the Salesforce report and standard API call.

If you are using Einstein Analytics dataflow, archived records will not be retrieved from the sfdcDigest node, feel free to vote this idea.


Last updated: 7-Jan-2021

Tuesday, March 26, 2013

Salesforce: Account Team Member and Account Share

Account Team Member and Account Share only available in Enterprise and Unlimited edition (included Developer edition). An account team is a team of users that work together on an account. You can add a user into Account Team manually from Account Team related list in the Account Page Layout.


After click Add button, you can specify Account Access, Contact Access, Opportunity Access, Case Access, and Team Role. If your default sharing in OWD is Private for that object, you will see Private, Read-Only, and Read/Write options in the picklist. You can add up to 5 users every time you add team members manually. 


But, the manual process is not fun when you need to add users into hundreds of account team members. So, here is the solution, use Data Loader to mass create AccountTeamMember records and AccountShare records.

1. Account Team Member
The API name is AccountTeamMember, you need to populate the following fields when mass inserts into AccountTeamMember: 
- AccountId
- UserId
- TeamMemberRole

Note: creating this record will not allow users added into AccountTeamMember to access Contact, Opportunity, Case if the sharing setting is Private. TeamMemberRole value can be different from values defined in Team Role. 

Purpose: it will show user added to Account Team related list.

2. Account Share
The API name is AccountShare, you need to populate following fields when mass insert into AccountShare: 
- AccountId
- UserOrGroupId
- AccountAccessLevel
- CaseAccessLevel [optional]
- ContactAccessLevel [optional]
- OpportunityAccessLevel [optional]
You can set Private, Read-Only, and Read/Write in the above fields optional if default sharing in OWD is set to Private.

Note: user added into Account Share will access Case, Contact, and Opportunity records with  Read-Only or Read/Write permission, even if it is not shown in Account Team related list.


Here is more information on mass create manual sharing rules with the Data Loader, click here.


Mass upload/insert non-English characters to Salesforce


We can mass upload / insert data to Salesforce easily using Data Loader or other API tool. But, if we get the data in Excel file with non-English characters, non-English characters will be come ??, This  is happened if we save the CSV file directly from Ms Excel.

To upload in non-English characters correctly, the file should be in UTF-8. Here step by step needs to be done, to avoid Ms Excel limitation in process non-English characters.

[ MS Excel ]
1. Open the *.xlsx file from MS Excel
2. Click File | Save As
3. Give a file name and choose "Unicode Text (*.txt)" for "Save as type :" and click Save

[ MS Notepad ]
4. Open the unicode text file using Microsoft Notepad. Some characters can appear as a box. This is because Notepad cannot display some unicode characters, but you can ignore it at this point.
5. It must be the tab delimitered file. Replace tabs with comma (,)
- Select tab character by dragging the character between two column headers and press Ctrl+C
- Replace all tab characters with comma using Replace function (Ctrl+H)
6. In Notepad, click Save As
7. Give a file name and change Encoding: to "UTF-8"
8. Click Save.

[ Windows File Explorer]
9. Change the file extension from "*.txt" to "*.csv". The file icon should be changed to MS Excel now. If it is not changed, check Windows Folder options. (Windows Start menu > Control Panel > Folder Options > View tab > uncheck "Hide extensions for known file types"). This will show the file extensions. Try changing the file extension again.

[ MS Excel ]
10. Open this CSV file from Excel and verify if the data is okay.
*** If you find any problem in this step, you should NOT save the file from Excel. It will cause the encoding problem!! Just check the data only in Excel. If you see a data problem at this stage, fix the data from the original spreadsheet and repeat the steps again. Or, you can change it from Notepad but should ensure that the file is saved as UTF-8 format.

You can download sample csv file with non-English characters saved in UTF-8 encoding here.

Salesforce Time-Dependent Workflow and Entry Criteria

Time-Dependent Workflow is a very nice feature out-of-the-box from Salesforce. You can easily configure it to do action such as: create task, send email alert, field update and send outbound message. The actions will only trigger when before or after certain date or hour as configured.

Actions for Time-Dependent Workflow is exactly the same with Immediate Workflow, and you can share the same actions between Time-Dependent Workflow with Immediate Workflow, depend on your business needs, even to combine Time-Dependent and Immediate workflow in the same workflow rule.

One thing you need to note when create Time-Dependent Workflow is the Evaluation Criteria, make sure it is set to created or created, and any time it’s edited to subsequently meet criteria only. Created, and every time it’s edited will NOT allow you to have Time-Dependent Actions.



I get a request from my user to change a running Time-Dependent Workflow from 7 days before Birth date to 14 days before Birth date. Here is the step:
  1. Take a screenshot of existing Time-Dependent Workflow with the actions (for backup purpose)
  2. Deactivate the workflow
  3. Delete all Time-Based Workflow queue related to the workflow, from Setup - Monitor - Time-Based Workflow, you can take screenshots as backup purpose.
  4. Edit Time-Dependent Workflow, once step 3 done, you will see Edit link next to the time trigger. For this sample, let's modify the day to 14 days.
  5. Activate the workflow rule

Notes:
1. Deactivate workflow rule (step 2 above)
This activity will NOT delete time-dependent actions are placed in the workflow queue.

2. All existing data will NOT trigger again for the Workflow
Because it already met the entry criteria earlier. So, if your Entry Criteria is 'Evaluate the rule when a record is created, and any time it’s edited to subsequently meet criteria', you need to make the record to 'meet' the criteria again:
  • Update the record NOT to meet the criteria, then update it back to meet the criteria.
  • Example: if we are using Rule Criteria "Birth date NOT EQUAL TO null", we need to make it to null (make sure to backup), then populate the original Birth date back, so it will meet the criteria again.

3. Monitoring
You can monitor record in queue to be triggered for Time-Based Workflow from Setup - Monitor - Time-Based Workflow. You can select some criteria to monitor the queue or just leave all to --None-- and hit Search button.


Limitation and Idea:
The time based workflow queue is not queryable via Apex, or the API or run a report.
Vote for this idea to have ability to export Queue of Time Based Workflow.



Friday, March 22, 2013

How to report Chatter records following by users?

As of the Salesforce Spring '13 release, the maximum number of people and records a user can follow in Chatter is 500. Once a user hits 500, the user is unable to follow any user or record; if you need more than 500 limits, you can log a case to Salesforce support to get this number increased to 2000.

Question, how do you check the number of people + records that have been followed? Easy answer, click on the user profile, and it will show in the right panel of count and items "Following". Then, you can click "Show All (number)" to see all records and people that user are following.



But, is there a way to list all the following items for all users? We cannot find this in the Chatter report. If you are familiar with SOQL or Data Loader, this is possible...

The object that stores all 'following' is EntitySubscription.
EntitySubscription represents a subscription for a user following a record or another user. A user can subscribe to a record or to another user. EntitySubscription is available in API version 18.0 and later.

Here is the simple SOQL:
Select e.Id, e.SubscriberId, e.ParentId From EntitySubscription e order by e.SubscriberId
SubscriberId here is UserId, and ParentId is any object or user following.

If you do not want to auto-follow the records you created (so you do not easily hit max 500), you can configure it from Setup - Personal Setup - My Chatter Settings - My Feeds. Uncheck Automatically follow records that I create.

There are also applications in AppExchange you can install to auto-unfollow Chatter items based on a set of rules; this app was created by Salesforce Lab:
- Cloud Swarm 3 - Chatter Auto Follow - Unmanaged - EE / UE / DE
- Chatter Unfollow Rules - Managed


Reference:

Page-level ad