Pages

Wednesday, October 19, 2016

Salesforce: Customizable Campaign Influence Model

Prior Winter '17 release, when you have multiple Campaigns associated to the Opportunity, the Primary Campaign gets 100% of the Influence credit and any other Campaigns get 0%.

This was frustrating for a multitude of reasons, but with Winter 17 this is an issue of the past. The new model provides flexible revenue attribution across multiple campaigns. Rather than just 100% of the credit given to the primary campaign on an opportunity, you can now do a first-touch, or last-touch attribution, or anything else in between.

For example you could give 50% credit to the last-touch, 25% attribution to the campaign prior to the last and 25% attribution to the first-touch. Or create a model that would evenly distribute credit for an opportunity across all campaigns that the lead touched, or set up a model that distributes 100% of the credit to the last campaign the lead touched.

Only thing you need to really worry about here is what to do with all your historic Opportunities. You can do a clean-up to get them into the new model or just start with this on new Campaigns only. This great new feature works in Classic as well as Lightning.


Prior Winter '17 Campaign Influence
  • Campaign added in Campaign Influence related list in Opportunity and marked as Primary Campaign Source will be shown in Opportunity related list in Campaign. The campaign will be auto populate as Primary Campaign Source field in Opportunity.
  • There is only one Primary Campaign Source for one Opportunity.


Enable Campaign Influence in Winter 17
Setup | Customize | Campaigns | Campaign Influence | Campaign Influence Settings



1. Admin
  • Assign yourself with "CRM User" Permission Set License
  • Create a Permission Set e.g. name it as "Campaign Influence", add  "Campaign Influence" permission to the permission set, and assign it to yourself

2. New standard objects added to the org.
  • CampaignInfluence
  • CampaignInfluenceModel

3. Campaign page layout
  • Existing Opportunities related list will be disappeared
  • Add new related list called "Influenced Opportunities"
  • If you select "Salesforce Model" as Campaign Influence Model, existing Opportunities in Campaigns related list will stay, otherwise it will be removed.

4. Opportunity page layout
  • Existing Campaign Influence related list will be disappeared
  • Add new related list called "Campaign Influence" (different logo - old with opportunity logo, new with campaign logo)
  • If you select "Salesforce Model" as Campaign Influence Model, existing Campaigns in Opportunities related list will stay, otherwise it will removed. While Primary Campaign Source value in Opportunity field will be always stay.

Campaign Influence Model 
When you enable this new Campaign Influence, by default Salesforce will provide a model called "Salesforce Model", this model will server as Primary model and Locked - campaign influence records for a locked model can only be added or edited via workflows and the API. Your users can’t add records manually in Salesforce.

You can add new model suit to your business requirements. If you set up more than one influence model, designate one of them as the primary model. The primary model’s records appear in the Campaign Influence related list on opportunities and the Influenced Opportunities related list on Campaigns.


Reference:


Thursday, October 13, 2016

Salesforce: Contact Sharing Setting

When Account sharing rule is Private, options for Contact sharing will be: Private or Controlled by Parent only.

Use case with following sharing setting:
- Account: Private
- Contact: Controlled by Parent

For Account that user suppose do not have access to, but if any Contacts that user owned are linked to the Account. Contact Owner will be able to access the Account (read-only). But, this does NOT apply for indirect contact linked to Account via Related Contact to Multiple Account relationship.

Sample: screenshot below is all accounts visible to user:



and this is all contacts visible to user:



When user received a contact link to the account that user has no access "Google", in this sample "Mann, Saman", user will be able to see that contact. Furthermore, if the Account have multiple Contacts, user will be able to see all Contacts for that Account, in sample below "Li. Linda", even user does not own the contact:



Because now user own a contact Mann, Saman which is linked to Google account, user will be able to read Google account, furthermore user will also able to access Li, Linda although not owned by the user, because user have read access to the Account.




Notes:
1. Contact Owner will NOT able to link his/her Contact to an Account if the user do not have read access. The same also applicable for Related Contact to Multiple Account feature.

2. If your Organization-Wide Default for Contact is set to Controlled by Parent, you will not see Sharing button in Contact page layout.

3. All access to the contact is determined by the user's accessibility to the Account for that Contact.
But, since Contact is a special standard object with owner field (different with normal M-D relationship), contact have Owner. Even Contact sharing setting is set to Controlled by Parent, contact owner will be able to edit contact, and this would not related to the user accessibility to the Account.


Side notes related to Opportunity:
If Account is Private, this will cause Opportunity become Private.
The same with Contact, Opportunity Owner will be able to access (read-only) Account because Opportunity is linked to Account.


Reference:


Wednesday, October 12, 2016

How to use Salesforce Analytics REST API for troubleshooting?

Use case: there is a report created with the same fields name, how to check if the field is come for which object easily? If we edit the report, it will not tell us the existing fields are come from which object.



Solution:

A. Using Workbench to call Analytics REST API
Documentation about this API - Salesforce Reports and Dashboards REST API.

1. Login to Workbench, select  utilities | REST Explorer

2. Execute this service /services/data/v37.0/analytics/reports/00O3B000000FiSd
change 00O3B000000FiSd to your Report Id.


3. Click Show Raw Response link.

4. Scroll down and look for "reportMetadata".


From here, we can see the 1st Created By come from Account, while 2nd Created By come from Contact.


B. Extract Report Metadata 
Use Force.com IDE or Mavensmate to open particular report metadata. Same as above, 1st Created By come from Account, while 2nd Created By come from Contact.




Reference: Salesforce Reports and Dashboards REST API 




Salesforce: Relate Contact with Multiple Accounts

In Summer 16 release, Salesforce introduces a feature to relate Contact with Multiple Accounts. The good thing is this feature is applicable for both Classic and Lightning UI, and in Salesforce1 as well. In Winter' 17 this feature even gets better, see this release notes.
  • Compact Layouts are now supported
  • Validation Rules are now supported
  • Triggers are now supported
  • Account-contact relationships can now be viewed


When you enable this feature, all of your existing relation between Contact and Account will not change, and they would become "Direct" relation - Account directly lookup from Contact will be called Direct. There will be a new related list called Related Contacts for Account Page layout, and Related Accounts for Contact Page layout.

You can see the Direct information from the new "Related Contacts" related list in Account Page layout, or "Related Accounts" related list in Contact Page layout. Personally, I would remove existing Contacts related list in Account, so users do not confuse with two almost similar related lists. You should modify Related Contacts related list to add all existing fields from Contacts and add Direct.


Setup
  • Navigate to Setup | Accounts | Account Settings
  • Enable "Allow users to relate a contact to multiple accounts"
Once enabled, you can define following actions:



Related Contacts related list from Apple Soft account page layout:



Related Accounts related list from a Contact page layout name Kim Bon:


You can add Custom field and Field Dependency for Account Contact Relationship from Setup | Customize | AccountsAccount Contact Relationship | Fields


Security Model

Add Relationship
All user (with read access to the Account) able to Add Relationship.
Click "Add Relationship" button from Related Contacts (in Account) or Related Accounts (in Contact), then fill in the account-contact relationship information.

Edit Relationship
Only user able to edit contact will be able to Edit Relationship.
Click View Rel (in Salesforce Classic) or View Relationship (in Lightning Experience) link. Then click "Edit Relationship" button.

Remove Relationship
Only user able to edit contact will be able to Remove Relationship.
Click Remove link and OK button to confirm.


Object
The object name for this is "AccountContactRelation", this is different with the old "AccountContactRole", which no longer supported in Lightning.


Reference:



Tuesday, October 11, 2016

Salesforce: Setting SSO (Single Sign On)

SSO is a process that allows network users to access all authorized networks without having to separately log in to each resource.

Salesforce can be configured as Identity Provider (IdP) using Salesforce Identity, or as Service Provider (SP).
Identity Provider is a trusted service that enables users to access other websites and services without logging in again.
Service Provider is a website or service that hosts apps and accepts identity from an identity provider.

Flow below show when user accessing Salesforce and authenticated by IdP, Salesforce is SP in this scenario.



Another flow when user accessing IdP and will be redirect to Salesforce as SP.


This blog would discuss on setup Salesforce as Service Provider and initiate SSO process:
1. User make a request to Salesforce
2. User is redirected to IdP with SAML Request
3. User authenticates & return with a SAML Response
4. Salesforce process the Response, create a session for user and return to requested resource

User open a specific my domain https://customername.my.salesforce.com, without need to enter username and password, user will be auto redirect to access Salesforce.

To setup SSO:
1. Enable My Domain in Salesforce
Refer to this documentation My Domain to create a custom domain name.

2. Enable Single Sign-On in Salesforce
Navigate to Setup | Security Controls | Single Sign-On Settings
Click Edit button "SAML Enabled"

3. SAML Single Sign-On Settings in Salesforce
In the same page as above, click New button in "SAML Single Sign-On Settings".
You need to get "Identity Provider Certificate" and upload the cert file - the authentication certificate issued by your Identity Provider.
- Identity Provider Certificate: upload cert file provided by IdP
- Entity ID: specify Salesforce base domain (https://saml.salesforce.com) or the custom domain.

4. Configure in IdP
- SAML version: only version 2.0 support for now
- Login URL: this would be Salesforce Login URL stated in SSO setting endpoints, example: https://johanyu.my.salesforce.com?so=00D90000000H7oz
- Entity ID: as defined in step 3 above
- Start Page URL: if you would like your users redirect to a specific page after login


Reference:




Thursday, October 6, 2016

Salesforce: Coding Editors

We discussed about Trigger syntax earlier. This blog, we'll continue with coding editor. To write a trigger, you need in a 'good' coding editor. Salesforce provide option of coding editors with its own benefits, from online editor within Salesforce environment until desktop application.

Please note that you can only write / edit code not directly in Production org. But you need to deploy from a sandbox or developer edition org., but we'll not discuss that in this blog.

1. Setup Menu
Setup | Customize | Object Name (such as Lead, Account, etc) | Triggers - click New button to create new trigger or Edit link to edit existing trigger.

This is the most basic editor, but also the most easiest and quickest way to code. You do not need to install anything, just login to Salesforce and make sure you have the right permissions.
When you create new trigger from here, it will provide basic trigger syntax, but no coloring, auto complete and etc. that offered by more advanced coding editor. Because as this is online coding, you need to have good internet connection.



2. Developer Console
Login to Salesforce, click your name at top right menu | Developer Console - this will open a popup window for Developer Console. Click File | New | Apex Trigger to create new trigger, or File | Open to open existing trigger.



Provide Name and select a sObject to start create new trigger.


Same as coding editor from setup menu, Developer Console is online tool so you do not need to install anything. But, compare to editor in setup menu, Developer Console have more advantages, from: color coding, auto completion, it even tell you if you have syntax error, or field not available online (see Problems tab from above screenshot).

Within Developer Console, you can run SOQL query from Query Editor, but you need to click few menu to get the object schema: File - Open - Objects - object name.



3. Force.com IDE
Follow this step to install Force.com IDE to your computer. This is the most common coding editor use by Salesforce developers. Force.com IDE is a plug-in for Eclipse to interact with Salesforce, this mean you need to setup Eclipse in your computer, then add the plug-in.

It is much more powerful then online coding editors mentioned above, on top of features offered by online editor, with Force,com IDE you can do deployment between org. (in comparison with Change Set only for org. related within a Production org.), and many more.



Although this tool is mean for developer, but admin also can take advantages of this tool to search or edit metadata, watch this on YouTube Hands-on Training: Get started with the Force.com IDE for Admins.

The only issue I always heard that this tool is pretty heavy, that's mean you need to have a powerful computer, if you are using Windows machine, you should run 64-bit OS, my experience running Force.com with 32-bit Windows machine is not really, very slow and keep hanging.

Force.com IDE offer more advanced SOQL by showing object schema.



4. MavensMate
Same as Force.com IDE, you need to install MavensMate on your computer, it is also a plug-in that you need to add on top other editor, but instead of Eclipse, with MavensMate you can choose to use Sublime Text 3, Atom, or Visual Studio Code.

Follow this link to install MavensMate. This tool is not really by Salesforce, but it is open source project. MavensMate getting more popularity recently, according to David Liu said this is the best coding editor to code Salesforce.

This tool offer about the same functionality with Force.com IDE, but in different layout and setting. 



Some user do not like Force.com IDE, because of (some items refer from An Easier Way to Delete Apex Classes From Production):
  • The Force.com IDE is very ‘heavyweight’ and is known for being quite buggy sometimes and unpleasant to use
  • They have a number of dependencies (a compatible version of Java, different IDE version etc)
  • Connectivity to Salesforce via the Force.com IDE may be an issue
  • It's very slow when you are using Windows 32-bit machine.

5. Others IDE
I'll not go to the detail for each others IDE, but here is the list:
For complete other IDE, refer to this blog by Jitendra Zaa.