How to show DateTime in Visualforce page in User's Time Zone instead of GMT in Salesforce?

Sample Code:


  1. <apex:page StandardController="Opportunity">  
  2.   
  3.     GMT:   
  4.     <apex:outputText value=" {0,date,M/d/yyy h:mm a}">  
  5.         <apex:param value="{!Opportunity.LastModifiedDate}"/>  
  6.     </apex:outputText>  
  7.     <br/>  
  8.     User Time Zone:   
  9.     <apex:outputField value="{!Opportunity.LastModifiedDate}"/>  
  10.       
  11. </apex:page>  

Output:



For using apex:outputText tag use


  1. <apex:page>  
  2.       
  3.     <table>  
  4.         <tr>  
  5.             <td><apex:outputText value="User Local Time Zone time is: {! NOW() }" /></td>  
  6.         </tr>  
  7.         <tr>  
  8.             <td><apex:outputText value="GMT Time Zone time is: {0,date,yyyy.MM.dd G 'at' HH:mm:ss z}"><apex:param value="{! NOW() }" /></apex:outputText></td>  
  9.         </tr>  
  10.     </table>  
  11.   
  12. </apex:page>  

Note:
<apex:outputText value="{!NOW()}" />  - it will show GMT time.
<apex:outputText value=" {!NOW()}" /> - it will show time in your local time zone (note that blank space has been added before the left brace).

How to delete an account in Salesforce1 Mobile App?

1. Switch to the account by clicking Change Account.

2. Log Out from the app.


How to override a Standard Action with a Lightning Component in Salesforce?

Add lightning:actionOverride to the list of interfaces in the aura:component tag.

Sample Code:

  1. <aura:component implements="lightning:actionOverride" >  
  2.       
  3. </aura:component>  

Output:


How to find Accounts with specific Contact Role associated with it in Salesforce?

1. Create a report with Accounts and Contacts Report Type.

2. Select With Contact Roles as the Cross Filter.

3. Add the Role under the Cross Filter.


Only event organizers can update this field: [WhoId] issue in Salesforce

We get this exception if we are updating an Event which is child of another event.

SELECT Id, IsChild, IsGroupEvent FROM Event WHERE Id = 'IdOfEvent'  


How Child Events get Created in Salesforce? 
While creating a new event/editing an existing event, we have the ability to invite people. So, for the invitees(users/contacts/leads), Salesforce internally creates separate events for each invitee with the flag isChild=TRUE.

When you are updating the events, ignore events where IsChild = true.

How to remove specific key and its value from JSON in MuleSoft using DataWeave?

Sample Code:

  1. %dw 2.0  
  2. output application/json  
  3. ---  
  4. payload filterObject ((value, key) -> (key as String != "Test"))  

In the above code
1. filterObject is used to filter JSON payload.
2. key as String is used since key is not an equivalent to String.
3. != is used to select all keys and values except "Test".

The above code removes key "Test" and it's values from the payload.

How to import the RAML file from Anypoint Platform Runtime manager from the design center?

1. Go to the Runtime Manager.


2. Select the environment.

3. Select the project.

4. Click on the .zip file to download the project.


5. Extract the downloaded file.

6. Create a new Mule project. Select the Design Center


7. Log in using the credentials.

8. Select the project.

9. Click Ok.

10. Click Finish.

11. Run the project.


12. Go to the browser and open the URL. Example localhost:8081/flights.



How to Delete Assets in Anypoint Platform Exchange?

1. Go to Exchange.

2. Select the Asset published.

3. Click Delete Version to Delete Assets in Anypoint Platform Exchange.


SOQL with parent field reference

1. Always use Parent Id instead of Parent.Id.

Example:
Use AccountId instead of Account.Id in the Query.


2. Use inner join query instead of using Parent object field reference. Make sure the parent object field is indexed for selective.

Example:
List < Contact > listContacts = [ SELECT Id FROM Contact WHERE Account.Name = 'Test' ];//Takes more time to execute
List < Contact > listContacts1 = [ SELECT Id FROM Contact WHERE AccountId IN ( SELECT Id FROM Account WHERE Name = 'Test') ];//Takes less time to execute


What is Transport Layer Security (TLS)

Transport Layer Security (TLS) is a protocol that provides authentication, privacy, and data integrity between two communicating computer applications. It's the most widely-deployed security protocol used today and is used for web browsers and other applications that require data to be securely exchanged over a network, such as web browsing sessions, file transfers, VPN connections, remote desktop sessions, and voice over IP (VoIP).

Google Chrome
Connections are automatically negotiated at the highest grade.
If you are using Google Chrome version 22 or greater, TLS 1.1 is automatically supported.  TLS 1.1 & 1.2 are automatically enabled from version 29 onwards.

Microsoft Internet Explorer
Open Internet Explorer
From the menu bar, click Tools >  Internet Options > Advanced tab
Scroll down to Security category, manually check the option box for Use TLS 1.1 and Use TLS 1.2

Servers
Registry path: HKLM SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols

Simple API using MuleSoft to query Salesforce using record Id

Listener Configuration:






Salesforce Query Configuration:





Transform Message Configuration:


Logger Configuration:



Output:



How to get field values in onsuccess method of lightning-record-edit-form?

Sample Code:

LWC HTML:

  1. <template>  
  2.   
  3.     <div class="slds-box slds-theme_default">  
  4.   
  5.         <lightning-record-edit-form record-id="0013i00000362blAAA"    
  6.                                     object-api-name="Account"    
  7.                                     onsuccess={handleSuccess}>    
  8.   
  9.             <lightning-messages></lightning-messages>    
  10.             <lightning-output-field field-name="Name"></lightning-output-field>    
  11.             <lightning-input-field field-name="Industry"></lightning-input-field>    
  12.             <lightning-input-field field-name="Description"></lightning-input-field>    
  13.             <lightning-input-field field-name="Rating"></lightning-input-field>    
  14.             <lightning-button class="slds-m-top_small"    
  15.                             variant="brand"    
  16.                             type="submit"    
  17.                             name="update"    
  18.                             label="Update">    
  19.             </lightning-button>    
  20.   
  21.         </lightning-record-edit-form>   
  22.       
  23.     </div>  
  24.   
  25. </template>  

LWC JavaScript:

  1. import { LightningElement } from 'lwc';  
  2.   
  3. export default class Sample extends LightningElement {  
  4.   
  5.     handleSuccess( event ) {    
  6.     
  7.         const payload = event.detail;            
  8.         var objJSON = JSON.parse(JSON.stringify(payload));  
  9.         alert(objJSON["fields"]["Industry"]["value"]);    
  10.     
  11.     }  
  12.   
  13. }  

LWC meta.xml:

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">  
  3.     <apiVersion>47.0</apiVersion>  
  4.     <isExposed>false</isExposed>  
  5.     <targets>  
  6.         <target>lightning__Tab</target>  
  7.     </targets>  
  8. </LightningComponentBundle>  

Output:


How to relate Lead to EmailMessage and EmailMessageRelation?

Sample Code:

  1. EmailMessage emailMessage = new EmailMessage();  
  2. emailMessage.status = '3'// email was sent  
  3. emailMessage.fromName = 'Magulan Duraipandian'// from name  
  4. emailMessage.subject = 'This is the Subject!'// email subject  
  5. emailMessage.htmlBody = '<html><body><b>Hello</b></body></html>'// email body  
  6. //Lead Id  
  7. String[] toIds = new String[]{'00Q3i0000018EKHEA2'};   
  8. emailMessage.toIds = toIds;  
  9. // additional recipients who don’t have a corresponding contact, lead or user id in the Salesforce org (optional)  
  10. //emailMessage.toAddress = 'emailnotinsalesforce@toexample.com, anotherone@toexample.com';  
  11. insert emailMessage; // insert  
  12.   
  13. // Add Email Message Relation for id of the sender  
  14. EmailMessageRelation emr = new EmailMessageRelation();  
  15. emr.emailMessageId = emailMessage.Id;  
  16. emr.relationId = '00Q3i0000018EKHEA2'// Lead Id  
  17. emr.relationType = 'FromAddress';  
  18. insert emr;  

Salesforce getUpdated() SOAP method

getUpdated()
Retrieves updated records for the specific time interval.

Example:
getUpdated("Account", StartTime, EndTime)

Reference link is below

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_getupdated.htm

Note:
There is a limit of 600,000 IDs in the result GetUpdatedResult[]. If your getUpdated() call returns more than 600,000 IDs, an exception EXCEEDED_ID_LIMIT is returned. You can correct the error by choosing start and end dates that are closer together.

How to check API Request Limit using Apex in Salesforce?

Using OrgLimit Class, we can check API Request Limit using Apex in Salesforce.

Sample Code:

  1. Map < String,System.OrgLimit > limitsMap = OrgLimits.getMap();  
  2. System.OrgLimit apiRequestsLimit = limitsMap.get( 'DailyApiRequests' );  
  3. System.debug( 'Limit Name: ' + apiRequestsLimit.getName() );  
  4. System.debug( 'Usage Value: ' + apiRequestsLimit.getValue() );  
  5. System.debug( 'Maximum Limit: ' + apiRequestsLimit.getLimit() );  

Output:


How to set start URL in Salesforce login URL?

User startURL in the login URL to set start URL in Salesforce login URL.


Salesforce Scope Parameter

Salesforce uses below scopes.

api - Allows access to the current, logged-in user’s account using APIs, such as REST API and Bulk API. This value also includes chatter_api, which allows access to Chatter REST API resources.
chatter_api - Allows access to Chatter REST API resources only.
custom_permissions - Allows access to the custom permissions in an organization associated with the connected app, and shows whether the current user has each permission enabled.
full - Allows access to all data accessible by the logged-in user, and encompasses all other scopes. full does not return a refresh token. You must explicitly request the refresh_token scope to get a refresh token.
id - Allows access to the identity URL service. You can request profile, email, address, or phone, individually to get the same result as using id; they are all synonymous.
openid - Allows access to the current, logged in user’s unique identifier for OpenID Connect apps.
Use the openid scope in the OAuth 2.0 user-agent flow and the OAuth 2.0 web server authentication flow to receive a signed ID token conforming to the OpenID Connect specifications in addition to the access token.
refresh_token - Allows a refresh token to be returned when you are eligible to receive one. Then the app can interact with the user’s data while the user is offline, and is synonymous with requesting offline_access.
visualforce - Allows access to customer-created Visualforce pages. Doesn’t allow access to standard Salesforce UIs.
web - Allows the ability to use the access_token on the web, and includes visualforce, allowing access to customer-created Visualforce pages.

Reference Link - https://help.salesforce.com/articleView?id=sso_provider_addl_params_scope.htm&type=5