How to relate a Contact to Multiple Accounts?

Contacts to Multiple Accounts lets reps associate a single contact with multiple accounts. Every contact needs to be associated with a primary account (the account that appears in Account Name). And now, your reps can associate more accounts with each contact. The primary account represents a direct relationship; the other accounts associated with a contact represent indirect relationships.

In the Related Accounts related list, the Account Name field appears only if the user has access to the account. If they don't have access to the account, only the Account Contact Relationship fields appear.

From the Related Contacts related list, users can navigate to a contact record, but not an account record. Similarly, from the Related Accounts related list, users can navigate to an account record, but not a contact record.

1. Go to Account Settings.


2. Edit Account Settings.


3. Enable "Allow users to relate a contact to multiple accounts".


4. Go to Account page layout and add Related Contacts related list.


5. Go to Contact page layout and add Related Accounts related list.


6. Open any Account record and click "Add Relationship" button.


7. Select Contact record from different Account and click "Save" button.


8. We will be able to see the Contact from different Account associated with this Account.


Cheers!!!

Partner accounts in Salesforce

Partner accounts are Salesforce accounts that a channel manager uses to manage partner organizations, partner users, and activities when using the partner portal. Each company with which you partner should be added to Salesforce as a business account. Channel managers are associated with partner accounts by account ownership. A channel manager who owns a partner account can access all the information and manage all the activities of the partner account, including that of any partner user associated with the partner account. This allows the channel manager to easily keep up-to-date on partner activities.

Once an Account is enabled as a partner, it appears in reports and list views that are filtered on the isPartner field. Additionally, partner users can be created from contacts associated with this Account.

Selecting a partner on an account or opportunity automatically creates a reverse partner relationship so that both accounts list the other as a partner. The role you select is applied to the partner account; in the current account, the reverse role is applied.

Removing a partner from an opportunity or account removes the partner's relationship with the opportunity or account, but does not delete the partner account.

If you change the account for an opportunity that has partners, all partners are deleted from the Partners related list.

Partner accounts can’t be deleted, but can be disabled.

Disabling an account with external users permanently dsables all external users associated with the account and removes them from all communities, groups, teams, permission sets and sharing rules with which they are associated. Also, roles and groups associated with the account are permanently delted and not moved to the Recycle Bin.

Cheers!!!

How to enable SSO SAML using Salesforce as Identity Provider?

For Example,

Service Provider - https://infallibletech-dev-ed.my.salesforce.com

Identity Provider - https://techietesting-dev-ed.my.salesforce.com

1. Setup domain for the Organizations.

http://www.infallibletechie.com/2013/08/domain-registration-in-salesforce.html

2. Provide Namespace Prefix for the Organizations.

http://www.infallibletechie.com/2015/05/whats-namespace-in-salesforce.html

3. In Identity Provider Organization, go to Security Controls --> Identity Provider.


4. Click "Download Certificate" to download the certificate.


5. In Service Provider, go to Security Controls -- > Single Sign-On Settings.


6. Click "Edit" button.


7. Enable SAML Enabled.


8. Click "New" button.


9. Enter the details as below.


10. Copy the Salesforce Login URL.


11. In Identity Provider, go to Create -- > Apps. Click "New" under Connected Apps related list.


12. Enter the details as below.


13. In Service Provider, go to Domain Management --> My Domain.


14. Click "Edit" button under Authentication Configuration.


15. Enable the SAML Single Sign-On Settings.


16. In both the organizations, go to users and select one user and set the Federation Id as unique in both.


17. Make sure in the Identity Provider Organization, the user has access to the Connected App.


18. Login in to Identity Provider organization. In another tab, use the Service Provider organization URL, you will be able to login without entering credentials.

Cheers!!!

We can't log you in. Check for an invalid assertion in the SAML Assertion Validator (available in Single Sign-On Settings) or check the login history for failed logins.

If you face "We can't log you in. Check for an invalid assertion in the SAML Assertion Validator (available in Single Sign-On Settings) or check the login history for failed logins." issue, make sure in the Identity Provider Organization, the user has access to the Connected App.


Cheers!!!

How to create SSN field in Salesforce?


Note:
1. This field cannot be used in Search.

2. This field cannot be used in SQOL "WHERE" and "ORDER" clauses.

To know more, check the below link

http://www.infallibletechie.com/2014/11/textencrypted-field-in-salesforce.html

Cheers!!!

How to fire validation rule only in update operation in Salesforce?

Use NOT(ISNEW()) to fire validation rule only in update operation in Salesforce.

Sample Validation rule:

AND(
 NOT(ISNEW()),
 ISCHANGED( City__c ),
 ISCHANGED( State__c )  
)

Cheers!!!

Service Life Cycle in Field Service Lightning Salesforce

Field Service Lightning offers a predefined list of Service statuses. The Service status reflects the service state in the system and follows its whole lifecycle – from service creation to service completion. The out-of-the-box service statuses are:

● New
● Assigned
● Dispatched
● Travel
● On Site
● Completed
● Incomplete
● Canceled

Cheers!!!

Getting Started with Field Service Lightning Salesforce

Follow the below steps after installing the Field Service Lighting Managed Packages.

1. Go to Service Types tab and click "New Service Type" button.


2. Create a new Service Type.


3. Go to Locations tab and click "New Location" button.


4. Create a new Location.


5. Go to Resources tab and click "New Resource" button.


6. Create 2 or more Resources.



7. Go to Employee Absences tab and click "New Employee Absence" button.


8. Create Employee Absences.


9. Go to Field Service tab.

10. Save the Location Filtering.


11. Select Create Service option.


12. Create 2 or more Service records.



13. You can see the records in the GANTT Chart.


Cheers!!!

Shield Platform Encryption in Salesforce

Shield Platform Encryption gives your data a whole new layer of security while preserving critical platform functionality. It enables you to encrypt sensitive data at rest, and not just when transmitted over a network, so your company can confidently comply with privacy policies, regulatory requirements, and contractual obligations for handling private data.

Classic encryption lets you protect a special type of custom text field, which you create for that purpose. With Shield Platform Encryption you can encrypt a variety of widely-used standard fields, long with some custom fields and many kinds of files. Shield Platform Encryption also supports person accounts, cases, search, approval processes, and other key Salesforce features.

For implementation, check the below link

http://www.infallibletechie.com/2016/11/how-to-enable-platform-encryption-in.html

To know more, check the below link

https://resources.docs.salesforce.com/202/latest/en-us/sfdc/pdf/salesforce_platform_encryption_implementation_guide.pdf

Note:

Manage Encryption Keys - Permission to manage Shield Platform Encryption.

View Encrypted Data - Permission to view the encrypted fields.

Cheers!!!

ReferenceError:key is not defined Salesforce Lightning issue

To fix "ReferenceError:key is not defined" Salesforce Lightning issue, declare the variable inside the for loop. Check the below example.

Sample Code:

                for ( var key in conts ) {
                    custs.push({value:conts[key], key:key});
                }

Cheers!!!

Permission Import Personal Contacts depends on permission(s): Create Account, Create Contact, Edit Account, Edit Contact

We get Permission Import Personal Contacts depends on permission(s): Create Account, Create Contact, Edit Account, Edit Contact, when try to move Account or Contact object permission.

To avoid this issue, we have to give Create and Edit access for Account and Contact. After the deployment we can remove it directly by going to that profile.

Cheers!!!

How to find whether the record is modified in Salesforce?

CreatedDate and LastModifiedDate fields are date time fields.

These two field values will be same when create a record. If the record is modified, it will not be same since the last modified time will be different from the time created.

Even though the record is modified on the same day, time will be different. So, using these two fields we can easily identify whether the record is modified.

CreatedDate = LastModifiedDate - Record is created.

CreateDate != LastModifiedDate - Record is updated after creation.

Cheers!!!

Failed to save undefined: Cannot remove design attributes when the component implements a Lightning Page interface.: Source

If you face "Failed to save undefined: Cannot remove design attributes when the component implements a Lightning Page interface.: Source" issue, do the following

1. Remove implements attribute from the component.

2. Remove the usage of the component.

Cheers!!!

Radio Buttons in Lightning Component in Salesforce

Sample code:

Lightning Component:

<aura:component >
<ui:inputRadio text="Sample1" label="Sample 1" name="Role" change="{!c.onGroup}"/><br/>
    <ui:inputRadio text="Sample2" label="Sample 2" name="Role" change="{!c.onGroup}"/><br/>
    <ui:inputRadio text="Sample3" label="Sample 3" name="Role" change="{!c.onGroup}"/><br/>
    <ui:inputRadio text="Sample4" label="Sample 4" name="Role" change="{!c.onGroup}"/><br/>
    <ui:inputRadio text="Sample5" label="Sample 5" name="Role" change="{!c.onGroup}"/>

</aura:component>

Lightning Controller:

({
    onGroup: function(cmp, evt) {
        var selected = evt.getSource().get("v.text");
        alert(selected);
    }

})

Output:


Cheers!!!

How to specify an opportunity record type when converting lead?

The Opportunity Record Type selected is the default for the converter profile.

1. Go to Profiles.

2. Select the Profile.

3. Select Object Settings.


4. Select Opportunity Object.

5. Click Edit button.

6. Set the Record Type which should be Opportunity's record type during lead conversion as default.


7. Click "Save" button.

Cheers!!!

Get Record Type ID by Name

Sample Code:

        String strObject = 'Account';
        String rtName = 'Marketing';

        Schema.DescribeSObjectResult d = getDescribSObject(strObject);        
        Map<String,Schema.RecordTypeInfo> rtMapByName = d.getRecordTypeInfosByName();
        Schema.RecordTypeInfo rtByName = rtMapByName.get(rtName);
        Id recTypeId = rtByName.getRecordTypeId();


        public static Schema.DescribeSObjectResult getDescribSObject(String strObject) {
            Schema.DescribeSObjectResult d;
            if(strObject.equals('Account')) {
                        d = Schema.SObjectType.Account;
                }
        }

(Or)

Id devRecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Test').getRecordTypeId();

Cheers!!!

System.QueryException: unexpected token: 's'

When you face System.QueryException: unexpected token: 's'  issue, use String.escapeSingleQuotes() method to avoid that.

Sample SOQL:

        String SOQL = 'SELECT Id, Name, ( SELECT Id, Name FROM Contacts ), CountryLookup__r.Name FROM Account WHERE Name LIKE \'%' + String.escapeSingleQuotes(ld.Company) + '%\' LIMIT 100';
        List < Account > = listAccount = Database.query(SOQL);

Cheers!!!

Failed to save undefined: descriptor is null

If you face Failed to save undefined: descriptor is null, please set type attribute.

Sample Code:

    <aura:attribute name="functionalrole" type="String"/>

Cheers!!!

How to set properties in Custom Lightning Component in Salesforce?

Sample Code:

Lightning Component:

<aura:component implements="flexipage:availableForAllPageTypes">
    <aura:attribute name="height" type="Integer" default="100"/>
    <aura:attribute name="width" type="Integer" default="100"/>
    <aura:attribute name="styl" type="String"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<button style="{!v.styl}">
        Testing the Properties
    </button>
</aura:component>

Lightning Controller:

({
doInit : function(component, event, helper) {
        var styl = "background-color:green;text-align:center;color:red;font-weight:bold;height:" + component.get("v.height") + "px;width:" + component.get("v.width") + "px;";
        component.set("v.styl", styl);
}
})

Lightning Design:


<design:component>
    <design:attribute name="height" label="Height" description="Height"/>
    <design:attribute name="width" label="Width" description="Width"/>
</design:component>

Output:


Cheers!!!

Apostrophe in SOQL causes unexpected token: 's' issue

SOQL Injection can occur in Apex code whenever your application relies on end user input to construct a dynamic SOQL statement and you do not handle the input properly.

To prevent SOQL injection, use the escapeSingleQuotes method. This method adds the escape character (\) to all single quotation marks in a string that is passed in from a user. The method ensures that all single quotation marks are treated as enclosing strings, instead of database commands.

Sample SOQL:

        String strText = 'Test';
        String SOQL = 'SELECT Id, Name FROM Account WHERE Name = \'' + String.escapeSingleQuotes(strText) + '\'';
        List<Account> listAcct = Database.query(SOQL);
        system.debug('test ' + listAcct);

Cheers!!!

Failed to save undefined: The attribute "aria-hidden" was not found on the COMPONENT markup://c:svg

If you face Failed to save undefined: The attribute "aria-hidden" was not found on the COMPONENT markup://c:svg, go to the svg or svgicon component and check the attribute name.

Sometimes it will be ariahidden instead of aria-hidden.

Cheers!!!

Failed to save undefined: No COMPONENT named markup://use found : [markup://c:AppAssignmentComponent]

If you face Failed to save undefined: No COMPONENT named markup://use found : [markup://c:AppAssignmentComponent], use <span> instead of <use>.

Note:
Make sure you have created the svg or svgicon lighting component.

Cheers!!!

No COMPONENT named markup://svg found : [markup://c:AppAssignmentComponent]

If you face No COMPONENT named markup://svg found : [markup://c:AppAssignmentComponent] issue instead of using <svg> try <c:svg>.

Note:
Make sure you have created the svg lighting component.

Cheers!!!

Salesforce Interview Questions with Answers Part 35

1. When will you use Process builder or Workflow?

http://www.infallibletechie.com/2016/07/what-is-difference-between-process.html

2. When a new opportunity is created I need to update the status as Processing, what will you use? Process Builder or Workflow? Why?

Workflow Field Update is preferable because if field update is done using Process builder, then record will go through complete Save cycle again.
If field update is done using Workflow field update, then Custom validation rules, duplicate rules, and escalation rules will not run again.

3. You have a customer sitting in front of you and giving his requirements. You go into your org to check something. How do you identify if you are in FORCE.COM or Salesforce.com ?

Setup keyword in the URL says that we are in Force.com.

4. How can we avoid View State memory error?

http://www.infallibletechie.com/2012/09/view-state-in-salesforce.html

5. what is transient ? is it class level or Object level?

http://www.infallibletechie.com/2016/01/what-is-use-of-transient-keyword-in.html

Class level.

6. Can we use SOSL within triggers? Can we use SOSL within APEX classes?

We can't use SOSL in Triggers Because the apex developer's guide says SOSL statements evaluate to a list of lists of sObjects, where each list contains the search results for a particular sObject type. The result lists are always returned in the same order as they were specified in the SOSL query. SOSL queries are only supported in Apex classes and anonymous blocks.You cannot use a SOSL query in a trigger.

7. What is External ID? How it is used? Can it have duplicates?

http://www.infallibletechie.com/2014/11/what-is-external-id-in-salesforce.html

It can contain duplicates. But if unique check box is checked, then it cannot contain duplicates.

8. How is deployment process carried out in FORCE.COM IDE?

Backup from target is archived and then deployed to target.

9. What are the WSDLs that Salesforce offers?

Enterprise WSDL
Partner WSDL
Apex WSDL
Metadata WSDL
Tooling WSDL
Delegated Authentication WSDL

10. What is stateless and state full?

Stateless and State full determines whether to maintain variable value inside the Batch class.

http://www.infallibletechie.com/2014/06/how-to-maintain-variable-value-inside.html

11. If you want an secure interface which one will you use? SOAP or REST?

SOAP

12. Can we update a record in Before Insert using Trigger.New?

No.

13. Is Static at class level? 

Yes.

14. What is the maximum number of records returned by SOQL ? 

It depends upon the context. Inside the Apex controller it is 50,000.

Cheers!!!

What is the difference between Process builder and Workflow?

Process Builder:

You can use the Process Builder to perform more actions than with workflow:

1. Create a record
2. Update any related record
3. Use a quick action to create a record, update a record, or log a call
4. Launch a flow
5. Send an email
6. Post to Chatter
7. Submit for approval
8. Call apex methods
9. But the process builder doesn’t support outbound messages.

Workflow:

Workflow does only 4 actions

1. Create Task
2. Field Update
3. Email Alert
4. Outbound Message

Cheers!!!

How to have different Community Builder page content based on profile?

1. Go to the page in Community Builder and select Page Variations tab. Click "New Page Variation" button.


2. Select your page option.


3. Give any name and click "Create" button.


4. Edit the page variation.

5. Do the required changes.

6. Select Manage Visibility.


7. Select the profile to view this change.

Cheers!!!