+ Start a Discussion
Austin VillanuevaAustin Villanueva 

lightning global search url

Hi guys, is there a global search in Lightning similar to Classic that use &startURL=/_ui/search/ui/UnifiedSearchResults?str=valueToSearch ?.
If you know something please let me know. Thank you.

-Austin
Best Answer chosen by Austin Villanueva
José UreñaJosé Ureña
Hi, i want to help you all with this problem.

I noticed the string after the "aloha#" in the URL just after you use the "global search" on Salesforce Lightning is just a Base64 encoded string, so i entered on a website (https://www.base64encode.org) and pasted that string (remember, after the aloha#) and decoded it, and founded this:

{"componentDef":"forceSearch:search","attributes":{"term":"SEARCH STRING","scopeMap":{"type":"TOP_RESULTS"},"context":{"disableSpellCorrection":false,"SEARCH_ACTIVITY":{"searchId":"df6707e4-b867-a197-925b-557d75cc18dc","startTime":1503500649656,"term":"SEARCH STRING"}}}}

Inmediatelly i gone into "Encode" section of website, and tryed the following string (notice i removed the searchId and startTime parameters):

{"componentDef":"forceSearch:search","attributes":{"term":"SEARCH STRING 2","scopeMap":{"type":"TOP_RESULTS"},"context":{"disableSpellCorrection":false,"SEARCH_ACTIVITY":{"term":"SEARCH STRING 2"}}}}

Then Base64 encoded it and pasted it after the "aloha#" (resulting url was something like:  https://na30.lightning.force.com/one/one.app?source=aloha#THECOMPLETEBASE64ENCODEDSTRING).

And "voila"... Lightning Global Search working as Classic did...

 

All Answers

Diksha Goel 6Diksha Goel 6

Hey Austin,

To search Knowledge and Cases using the case subject. The URL behind the link looks like this:

/_ui/search/ui/UnifiedSearchResults?sen=ka&sen=500&str={!Case.Subject}&initialViewMode=summary&searchAll=false

sen = the objects to search (by object prefix ID) ka is Knowledge and 500 is Cases. 001 is Accounts, 003 is Contacts, etc. See a list here (http://www.fishofprey.com/2011/09/obscure-salesforce-object-key-prefixes.html).


str = the search string
initialViewMode = Initial View Mode (Summary or Detail)
searchAll = should the search run against all objects or not

Seperate each variable with a "&"

Refer this link to know more about What's not available in Lightning experience:

https://help.salesforce.com/articleView?id=lex_gaps_limitations_search.htm&type=0

Hope this helps to solve your problem.
Regards

Diksha Goel

Zen4orce Developer.
 

Austin VillanuevaAustin Villanueva
Hi Diksha, 

First of all, thank you for your response. I think this is not what I'm looking for because this one still use the UnifiedSearchResults which redirect me to the classic, what I'm looking for is something that will redirect me to lightning page instead of classic, without any type of object. Just a string to pass to the global search. If you have any info about it, let me know. I appreciate your help.

Thank you, 

Sincerely,
Austin
04~ Matt McCarthy ~2804~ Matt McCarthy ~28
Any updates on this?  I'd be interested to know if there's a solution out there for this also.
José UreñaJosé Ureña
Hi, i want to help you all with this problem.

I noticed the string after the "aloha#" in the URL just after you use the "global search" on Salesforce Lightning is just a Base64 encoded string, so i entered on a website (https://www.base64encode.org) and pasted that string (remember, after the aloha#) and decoded it, and founded this:

{"componentDef":"forceSearch:search","attributes":{"term":"SEARCH STRING","scopeMap":{"type":"TOP_RESULTS"},"context":{"disableSpellCorrection":false,"SEARCH_ACTIVITY":{"searchId":"df6707e4-b867-a197-925b-557d75cc18dc","startTime":1503500649656,"term":"SEARCH STRING"}}}}

Inmediatelly i gone into "Encode" section of website, and tryed the following string (notice i removed the searchId and startTime parameters):

{"componentDef":"forceSearch:search","attributes":{"term":"SEARCH STRING 2","scopeMap":{"type":"TOP_RESULTS"},"context":{"disableSpellCorrection":false,"SEARCH_ACTIVITY":{"term":"SEARCH STRING 2"}}}}

Then Base64 encoded it and pasted it after the "aloha#" (resulting url was something like:  https://na30.lightning.force.com/one/one.app?source=aloha#THECOMPLETEBASE64ENCODEDSTRING).

And "voila"... Lightning Global Search working as Classic did...

 
This was selected as the best answer
Austin VillanuevaAustin Villanueva
Hi José Ureña, 
Wow thanks a lot this is really helpful!! It works perfectly I tried changing the url and it works. Thanks again.

Austin
Cody CharfaurosCody Charfauros
Jose, this is great! Unfortunately I'm integrating with an app that cannot encode in Base64; does anyone know of a plain-text way where the app only has to pass one argument (name string or phone number string) into it?
C ArguelloC Arguello
I have a similar requierement, redirect from other page to glabal search using search filters, but I'm concerned about this solution beacuse I could not find any documentation about that. So salesforce may change the base64 params or even modify the search way.

I would like to speark with someone in salesforce team to confirm if this is supported solution
José UreñaJosé Ureña
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_encodingUtil.htm Enviado desde mi Samsung Mobile de Claro
C ArguelloC Arguello
Yes you're right, but that post only shows information about encoding/decoding parameters. I would like to see information about json parameters
{
  "componentDef": "forceSearch:search",
  "attributes": {
    "term": "SEARCH STRING 2",
    "scopeMap": {
      "type": "TOP_RESULTS"
    },
    "context": {
      "disableSpellCorrection": false,
      "SEARCH_ACTIVITY": {
        "term": "SEARCH STRING 2"
      }
    }
  }
}

 
Clemens MittlClemens Mittl
Did someone tried this lately?

We need exactly this funcitonality to pass parameters to the global search of Salesforce as we cannot have the Salesforce Record ID exposed to the search generating system and use it directly to open the record detail page by Salesforce ID.

For some reason i fail to replicate the same you explained above when i am using the lightning search and trying to decode the URL
Troy CenterTroy Center
CHeck this out... https://success.salesforce.com/answers?id=90630000000hKzWAAU
Kyle VargaKyle Varga
I was able to build a small Lightning app that allows this to work. If you (or your admin/developer) can  to deploy this, you'd be able to use direct URL to Salesforce. 

Lightning Application (I named it SearchApp)
<aura:application>
    <aura:attribute name="search" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    Redirecting to search results for {!v.search}
</aura:application>


Lightning Controller:
({
	doInit : function(component, event, helper) {
        // Grab search query from URL
        var searchQuery = component.get("v.search");
        
        // Convert search query into SF expected format
        var stringToEncode = '{"componentDef":"forceSearch:search","attributes":{"term":"'+ searchQuery + '","scopeMap":{"type":"TOP_RESULTS"},"context":{"disableSpellCorrection":false,"SEARCH_ACTIVITY":{"term":"'+ searchQuery + '"}}}}';
        var encodedString = btoa(stringToEncode);
        
        // Redirect user (this only works from Lightning App, won't work from components)
        window.location = "/one/one.app?source=alohaHeader#" + encodedString;

	}
})




Then, you can use https://yourcustomdomain.lightning.force.com/c/SearchApp.app?search=SEARCHQUERY and get redirected to the global search results in Lightning experience
Jill HebertJill Hebert
Kyle, thanks so much for sharing! Works like a charm! 
Austin Villanueva 58Austin Villanueva 58
Hi guys,

did anyone tried using the aloha format using /one/one.app?source=aloha#{base64code}?. If I tried using the pattern in existing and open salesforce account it works perfectly fine but if I used it with javascript to open a window it doesnt work but other paths work like "/lightning/o/Contact/list?filterName=Recent" I tried to use it with startURL="/one/one.app?source=aloha#{base64code}" it doesnt work I also tried "/one/one.app?source=aloha#{base64}" but it doesn't work. it refreshed the page and remove the base64 code in the address bar.

I hope you can help me. 

Thanks
Tyler FitzgeraldTyler Fitzgerald
Kyle, thanks so much! I literally created an account just to give your comment a thumbs up! :P
Lorenzo AlaliLorenzo Alali
Idea: https://success.salesforce.com/ideaView?id=0873A0000015BJJQA2
Troy CenterTroy Center
OP should update the best answer to Kyle Varga. Thanks Kyle! This is rad! 
Mattia AlberganteMattia Albergante
Kyle thank you for the answer, OP should definitely change the answer and in the meanwhile people will hopefully scroll down and see K's answer