Sunday, September 17, 2023

No Code: Salesforce Inbound Integration Using Standard APIs



Salesforce provides a powerful feature which allow the external system to integrate with Salesforce without any code on salesforce platform. Using Salesforce Standard APIs we can achieve it.
Salesforce Developer needs to provide the standard URI link to third party system.

Prerequisites

Access to Salesforce org either via Username Password or Connected App.


Lets dive into it and understand it with a demo using workbench.


Open workbench REST Explorer using this link

CRUD Operation using REST API

1. Get Data

External system wants to get a record detail from Salesforce. Click on GET radio button and enter the below URI and click on execute.

URI: /services/data/v58.0/sobjects/<Object Name>/<salesforce record ID>
Full URI will be 
https://<doamin_name>.salesforce.com/services/data/v58.0/sobjects/<Object Name>/<salesforce record ID>


    If the salesforce id doesnot exist in the org then the response would look like this:

 


Get records using a SOQL query

If other system wants to get the query result then use the below URL
URI: /services/data/v58.0/query/?q=Select+Id,Name+from+Account+LIMIT+10

Here every space is replaced by '+' operator.

2. POST Data (Insert)

External system wants to create a record in Salesforce. Click on POST radio button and enter the below URI and click on execute.

URI: /services/data/v58.0/sobjects/<Object Name>

3. PATCH (Update)

External system wants to update a record in Salesforce. Click on PATCH radio button and enter the below URI and click on execute.

URI: /services/data/v58.0/sobjects/<Object Name>/<salesforce record ID>

4. Delete

External system wants to update a record in Salesforce. Click on PATCH radio button and enter the below URI and click on execute.

URI: /services/data/v58.0/sobjects/<Object Name>/<salesforce record ID>











Sunday, September 3, 2023

SOSL In Salesforce

 

Introduction to SOSL 

Salesforce Object Search Language (SOSL) is used to write queries to search text against the search index.

Always create filters that are selective, when building efficient SOSL queries. By default, SOSL queries scan all entities. The search engine can return maximum of 2,000 records after matching the searched term or text.

SOSL statements are basically used to find or search the text format data, email, and phone fields for multiple objects, including custom objects, that we have access to in a single query.


SOSL Syntax: 

FIND {Search Text} [IN Name/Email/Phone/All] RETURNING sObject(Fields to return);
Example: SOSL to search 'Pepsi' text in all fields and return Account Object’s name, industry as result.

FIND {Pepsi} IN ALL FIELDS RETURNING Account (Name, Industry);

Note: We can use multiple objects as returning data in SOSL.

Example: SOSL to search ‘Pepsi’ text in all fields and return Account Object’s name, industry and Contact Object’s name, email as result.

FIND {Pepsi} IN ALL FIELDS RETURNING Account (Name, Industry), Contact (Name, Email);

Saturday, September 2, 2023

GIT Commands To Commit Salesforce Changes Using Command Prompt

 


1.  Download the git. To download click on this link:

https://git-scm.com/downloads


2.  After the installation, open Command Prompt and check whether git is installed properly or not. Run this command:

git --version 


3.  Now Go to a directory where you want to clone the project from Git. Run Command:

cd foldername


4.  Next step is to initialize the Git in that folder. Run Command:

git init


5.  After the initialization is completed, then we need to clone the project from Git into our local desktop. Run Command:

git clone https://gitlab.eng.abc.com/SFstar/it-sfdc.git

(You can get this URL from your git repository)


6.  Go inside the last directory which is it-sfdc in my case. Run Command:

cd it-sfdc


7.  Next, checkout our feature branch where we need to commit our changes for the upcoming release. Run Command:

git checkout FeatureBranch_Release_12Dec2023


8.  Once the feature branch is checked out it is always recommended to pull the changes. Or lets say someone has checked out this feature branch yesterday and today he is adding his components to that branch. In that case he needs to pull the changes if some other developer has added his own components. Run Command:

git pull


9.  Now start adding your changes to the local files or replace your files with the modified code.


10. Check the status of modified files. Run Command:

Git status

At this time, we will see all the modified files names in 

red color.


11. If you have completed the modification, its time to add them. Run Command:

git add force-app/main/default/objects/ABC__c/

Or

git add .


Note: first command will add only the particular component 

i.e. ABC object but the second command will add all the 

changed components.


12. Write a command to check the status of the modified files after adding

git status

This time all the files names will come in green color.


13. Next step is to commit the changes to git. Run command: 

git commit -m "adding changes part of SF story"


14.  At the end we need to push the code. Run Command:

git push