function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
S@uravvS@uravv 

how to naviagte to a url(It has no parameter) and prefil the search box through aura component?

Prepoluate a page without URL parameters, The page has alightning web component
Best Answer chosen by S@uravv
S@uravvS@uravv
Hi Danish! Thankyou for you help,

Actually I wanted to pass a field value from the record page through the URL. But since It did not have any parameter i was wondering how.
When I tried to append url by (?id=xyz), It was automatically refreshing the page and the appended part of url was removed.

I got a solution, I needed to include the namespace. Instead of appending (?id=xyz) I should be appending (?c__id=xyz) to the url. It worked.

Thanks a lot.

All Answers

Danish HodaDanish Hoda
Hi Saurav,
You can simply use navigateToUrl without specifying any param.
For prefill, you can use value={data} inside search box and define data as a variable in js like @track  var zip = "Default value"
S@uravvS@uravv
Thankyou Danish for your help,

When I did as you said, It opens the page with the search box written "Default value". 
Here is my controller (From where I am naviagting to the LWC app page),
 doInit : function(component, event, helper) {
       var urlEvent = $A.get("e.force:navigateToURL");
         urlEvent.setParams({
          "url": "https://myDomain/n/sample_Form"   
        });
       setTimeout(function(){
          $A.get("e.force:closeQuickAction").fire();
        },0.000001);
        urlEvent.fire();
        }

In LWC controller

@track sVal='Default value';
in HTML file
<input type="text"
                    value={sVal} 
                    autofocus="autofocus"                  
                    placeholder="Enter Name"
                    autocomplete="on"
                    minlength="1"
                    onkeyup={handleKeyChange}
                    /> 
Danish HodaDanish Hoda
Hi Saurav,
​​​​​​this is what you had expected, right?
S@uravvS@uravv
Hi Danish! Thankyou for you help,

Actually I wanted to pass a field value from the record page through the URL. But since It did not have any parameter i was wondering how.
When I tried to append url by (?id=xyz), It was automatically refreshing the page and the appended part of url was removed.

I got a solution, I needed to include the namespace. Instead of appending (?id=xyz) I should be appending (?c__id=xyz) to the url. It worked.

Thanks a lot.
This was selected as the best answer