The Art of URL Hacking in Salesforce : Part II — Salesforce Search

Shivam Vishwakarma
4 min readDec 10, 2023

--

In my previous article I had explained how one can use Salesforce URL Hacks to create a New Record with Pre-Populated values.

If you haven’t read that yet, I would really encourage you to take the time to read once.

In this Article, I’ll explain how you can control Salesforce search (Now merged with Einstein Search feature) through URL Hacks.

Note: As I had already highlighted in Part I Article, some Salesforce URL Hacks require Advance knowledge of Base64 Encoding & Decoding, and I’ll be using the same below, hence I’ll recommend you to read it once if you haven’t already.

Remember : “Your search term must have 2 or more characters”, else a Error Page will be shown for the same with exact same message mentioned above.

A] Global Search with Top/All Matching Results for All Objects.

In the Below mentioned JSON snippet, replace <YOUR_SEARCH_TERM> with the Term for which you wish to perform Global Search in all Objects in the Org.

{"componentDef":"forceSearch:searchPageDesktop","attributes":{"term":"<YOUR_SEARCH_TERM>","scopeMap":{"type":"TOP_RESULTS","namespace":"","label":"Top Results","labelPlural":"Top Results","resultsCmp":"forceSearch:predictedResults"}},"state":{}}

Post that, use

to create a Base64 Encoded version of the above mentioned JSON String.

Copy this Base64 Encoded String and Add it as suffix to “/one/one.app#”, Use this URL to Perform the Global Search.

For e.g. I want to search for Term : “sForce” in my Org :

btoa('{"componentDef":"forceSearch:searchPageDesktop","attributes":{"term":"sForce","scopeMap":{"type":"TOP_RESULTS","namespace":"","label":"Top Results","labelPlural":"Top Results","resultsCmp":"forceSearch:predictedResults"}},"state":{}}');
//Result : eyJjb21wb25lbnREZWYiOiJmb3JjZVNlYXJjaDpzZWFyY2hQYWdlRGVza3RvcCIsImF0dHJpYnV0ZXMiOnsidGVybSI6InNGb3JjZSIsInNjb3BlTWFwIjp7InR5cGUiOiJUT1BfUkVTVUxUUyIsIm5hbWVzcGFjZSI6IiIsImxhYmVsIjoiVG9wIFJlc3VsdHMiLCJsYWJlbFBsdXJhbCI6IlRvcCBSZXN1bHRzIiwicmVzdWx0c0NtcCI6ImZvcmNlU2VhcmNoOnByZWRpY3RlZFJlc3VsdHMifX0sInN0YXRlIjp7fX0=

So, the Final URL would be :

/one/one.app#eyJjb21wb25lbnREZWYiOiJmb3JjZVNlYXJjaDpzZWFyY2hQYWdlRGVza3RvcCIsImF0dHJpYnV0ZXMiOnsidGVybSI6InNGb3JjZSIsInNjb3BlTWFwIjp7InR5cGUiOiJUT1BfUkVTVUxUUyIsIm5hbWVzcGFjZSI6IiIsImxhYmVsIjoiVG9wIFJlc3VsdHMiLCJsYWJlbFBsdXJhbCI6IlRvcCBSZXN1bHRzIiwicmVzdWx0c0NtcCI6ImZvcmNlU2VhcmNoOnByZWRpY3RlZFJlc3VsdHMifX0sInN0YXRlIjp7fX0=

If I open the same in my Org, the results are as follows :

Global Search with Top/All Matching Result for “sForce” as the Search Term.

B] Object Specific Search

If in case you wish to perform Search for <YOUR_SEARCH_TERM> within a Specific Object, then you should follow the above mentioned steps in Section [A], however use the following JSON for Base64 Encoding.

{"componentDef":"forceSearch:searchPageDesktop","attributes":{"term":"<YOUR_SEARCH_TERM>","scopeMap":{"nameField":"Name","name":"<YOUR_OBJECT_API_NAME>","id":"<YOUR_OBJECT_API_NAME>","fields":"<LIST_OF_FIELDS_TO_BE_RETURNED_SEPERATED_BY_\n>","entity":"<YOUR_OBJECT_API_NAME>"}},"state":{}}

For e.g. I want to search for Term : “sForce” in my Org under Contacts Object,
[And fields parameter as LastModifiedDate\nName\nSystemModstamp\nOwnerId\nCreatedDate\nId\nLastModifiedById .
Tip : You can add more fields to this as well, all separated by \n] :

btoa('{"componentDef":"forceSearch:searchPageDesktop","attributes":{"term":"sForce","scopeMap":{"nameField":"Name","label":"Contact","name":"Contact","id":"Contact","fields":"LastModifiedDate\nName\nSystemModstamp\nOwnerId\nCreatedDate\nId\nLastModifiedById","entity":"Contact"}},"state":{}}');
//Result : eyJjb21wb25lbnREZWYiOiJmb3JjZVNlYXJjaDpzZWFyY2hQYWdlRGVza3RvcCIsImF0dHJpYnV0ZXMiOnsidGVybSI6InNGb3JjZSIsInNjb3BlTWFwIjp7Im5hbWVGaWVsZCI6Ik5hbWUiLCJsYWJlbCI6IkNvbnRhY3QiLCJuYW1lIjoiQ29udGFjdCIsImlkIjoiQ29udGFjdCIsImZpZWxkcyI6Ikxhc3RNb2RpZmllZERhdGVcbk5hbWVcblN5c3RlbU1vZHN0YW1wXG5Pd25lcklkXG5DcmVhdGVkRGF0ZVxuSWRcbkxhc3RNb2RpZmllZEJ5SWQiLCJlbnRpdHkiOiJDb250YWN0In19LCJzdGF0ZSI6e319

So, the Final URL would be :

/one/one.app#eyJjb21wb25lbnREZWYiOiJmb3JjZVNlYXJjaDpzZWFyY2hQYWdlRGVza3RvcCIsImF0dHJpYnV0ZXMiOnsidGVybSI6InNGb3JjZSIsInNjb3BlTWFwIjp7Im5hbWVGaWVsZCI6Ik5hbWUiLCJsYWJlbCI6IkNvbnRhY3QiLCJuYW1lIjoiQ29udGFjdCIsImlkIjoiQ29udGFjdCIsImZpZWxkcyI6Ikxhc3RNb2RpZmllZERhdGVcbk5hbWVcblN5c3RlbU1vZHN0YW1wXG5Pd25lcklkXG5DcmVhdGVkRGF0ZVxuSWRcbkxhc3RNb2RpZmllZEJ5SWQiLCJlbnRpdHkiOiJDb250YWN0In19LCJzdGF0ZSI6e319

If I open the same in my Org, the results are as follows :

Object Specific Search with All Matching Results for “sForce” as the Search Term in Contact Object.

C] Setup Search Top/All Matching Results

If in case you wish to perform Search for <YOUR_SEARCH_TERM> within Salesforce Setup, then you should follow the above mentioned steps in Section [A], however use the following JSON for Base64 Encoding.

{"componentDef":"forceSearch:search","attributes":{"term":"<YOUR_SEARCH_TERM>","scopeMap":{"labelPlural":"Setup","namespace":"Setup","type":"TOP_RESULTS"}},"state":{}}

For e.g. I want to search for Term : “Shivam” in my Org’s Setup :

btoa('{"componentDef":"forceSearch:search","attributes":{"term":"Shivam","scopeMap":{"labelPlural":"Setup","namespace":"Setup","type":"TOP_RESULTS"}},"state":{}}');
//Result : eyJjb21wb25lbnREZWYiOiJmb3JjZVNlYXJjaDpzZWFyY2giLCJhdHRyaWJ1dGVzIjp7InRlcm0iOiJTaGl2YW0iLCJzY29wZU1hcCI6eyJsYWJlbFBsdXJhbCI6IlNldHVwIiwibmFtZXNwYWNlIjoiU2V0dXAiLCJ0eXBlIjoiVE9QX1JFU1VMVFMifX0sInN0YXRlIjp7fX0=

So, the Final URL would be :

/one/one.app#eyJjb21wb25lbnREZWYiOiJmb3JjZVNlYXJjaDpzZWFyY2giLCJhdHRyaWJ1dGVzIjp7InRlcm0iOiJTaGl2YW0iLCJzY29wZU1hcCI6eyJsYWJlbFBsdXJhbCI6IlNldHVwIiwibmFtZXNwYWNlIjoiU2V0dXAiLCJ0eXBlIjoiVE9QX1JFU1VMVFMifX0sInN0YXRlIjp7fX0=

If I open the same in my Org, the results are as follows :

Setup Search with Top/All Matching Result for “Shivam” as the Search Term.

I hope you enjoyed this article 📖 & found it insightful! 🔍!
Do hit the clap button👏 if you liked the article & leave a comment✍ if you have any queries/suggestions.

Enjoying the content? Don’t miss out on my future posts! Hit ‘Follow’ button to be the first to know about my new publications 🔔. Can’t wait to share more! 🚀🎉

Thanks for reading!

--

--

Shivam Vishwakarma

I'm a Salesforce Developer & CRM Analytics Enthusiast! Visit my LinkedIn to know more about me : linkedin.com/in/shivamashokvishwakarma