Pages

Thursday, April 11, 2013

Delete Campaign in Salesforce


Background: a user come to me that she does not see Delete button, she would like to delete a campaign created by mistake.

As usual, I check user profile and page layout:
- User Profile have Delete permission on Campaign object - checked
- Page Layout have Delete button - checked
So, what is the caused ...?

Finding.... Campaign is not the same with other objects. You need to enable Marketing User permission selected in the user detail. Once enabled and both items above checked, the user should see 'Delete' button for Campaign, the same for 'New' button to create Campaign.

From Setup | Manage Users | User | look for user | Edit | enable Marketing User | Save


Marketing User permission in user detail allows a user to manage Campaigns, users with enabled Marketing User checkbox has the right to create and manage campaigns, including:
  • Create a new campaign
  • Edit an existing campaign
  • Delete an existing campaign
  • Update campaign statistics
  • Import leads into a campaign*
  • Mass update the status for members of a campaign*
  • Configure advanced campaign setup to define member status values
  • Change the campaign member type
  • Run campaign reports across multiple campaigns
  • Add Contact and Lead to Campaign from a report using Add to Campaign

* In order to use the campaign import wizards, the user must also have the Marketing User profile (or have "Import Leads" permission).

Create permission for Campaign object will enable:
- New button in Recent item and List Views
- Clone button in Campaign Page Layout

Edit permission for Campaign object will enable:
- Edit Campaign link in Recent item
- Edit button in Campaign Page Layout
- Manage Members (with: Add Members - Search & Edit Members - Search option) in Campaign Page Layout


Reference:


Saturday, March 30, 2013

Salesforce: Change Account Owner


Do you realize when account owner is changed using Salesforce.com UI, the new owner will also gain ownership of:
  • All Notes and open Activities for the Account (completed Activities will not be transferred)
  • All Contacts tagged to the Account owned by old owner
  • All open Opportunities tagged to the Account, including closed Opportunities if you select the Transfer closed opportunities, and Opportunities owned by other owner if you select Transfer open opportunities not owned by the existing account owner, see screenshot below:

Above scenario will also correct for mass transfer from Setup | Data Management | Mass Transfer Records | Transfer Accounts.

But, if  you change Account owner through API, or API tool such as: Data Loader, only the Account Owner will be change, it will not change owner of Contact, Opportunity and other objects related.


Reference:

Last Update: 17 May 2016

Thursday, March 28, 2013

Salesforce: Formula field best practice


Formula field in Salesforce is great feature for user, it simplify complex filter conditions for SOQL queries, list views, and reports.

Let's say we have CloseDateAge formula field, we can use it in report filter CloseDateAge range = Current FY.

Or in SOQL
SELECT Id, Name
  FROM Opportunity
 WHERE CloseDateAge__c >  14
   AND CloseDateAge__c <= 21

Everyone is happy because they can get the data they need with very little effort, right? Wait a minute.

Indexes
By default, formula fields don’t have indexes. So when you create and use a formula field such as CloseDateAge with very large objects (say, objects that have more than one million of records), the SOQL queries and reports using the formula field as a filter might perform slower because your queries and reports have to perform full scans to find target records.

You can workaround by create trigger or workflow to update a field. It's work, but it requires overhead and is not intuitive.

Since the Winter ’13 release, you have been able to contact salesforce.com Customer Support to create a custom index on a formula field, provided that the function that defines the formula field is deterministic. But, Salesforce cannot index formula fields that:
  • Reference other entities (i.e., fields accessible through lookup fields)
  • Include other formula fields that span over other entities
  • Use dynamic date and time functions (e.g., TODAY, NOW)
A formula is also considered non-deterministic when it includes:
  • Owner, autonumber, divisions, or audit fields (except for CreatedDate and CreatedByID fields)
  • References to fields that Force.com cannot index:
  • Multi-select picklists
  • Currency fields in a multicurrency organization
  • Long text area fields
  • Binary fields (blob, file, or encrypted text)
  • Standard fields with special functionalities:
  • Opportunity: Amount, TotalOpportunity, Quantity, ExpectedRevenue, IsClosed, IsWon
  • Case: ClosedDate, IsClosed
  • Product: Product Family, IsActive, IsArchived
  • Solution: Status
  •    Lead: Status
  •    Activity: Subject, TaskStatus, TaskPriority

The CloseDateAge field above is a perfect example of a non-deterministic formula field that Force.com cannot index. So what can you do when you can’t create an indexed formula field to hide complex filter logic? Go back to square one: Put your filter logic in your filters!

So, in the SOQL above, change it to
SELECT Id, Name
  FROM Opportunity
 WHERE ((CloseDate = LAST_N_DAYS:21)
   AND  (CloseDate < LAST_N_DAYS:14))


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.


Page-level ad