Select to view content in your preferred language

passing variable to textbox

906
4
08-31-2021 12:37 PM
LeLuong
Regular Contributor

All,

I'm using web appbuilder developer.  I'm trying to learn to pass variable from 1 widget to another.  I see that if you have a parameter from url (ex: ...webappbuilder/?id=1&find=123456789) then the textbox in"Near Me Widget" will have that value in it. (Picture attached).  Could you please help locate the codes that makes it happened?  I've never done customizing widget before and now what I'm trying to do in my case is to take that account # from the url to pass to a attribute field in edit widget so users don't have to type in the account number again.  Any help is greatly appreciated. 

 

 URLparameter.PNG

 

0 Kudos
4 Replies
LefterisKoumis1
Emerging Contributor

You just need to capture the value after the field 'find' . THe variable valueReceived should give the value to use in the widget.

urlSubstring = location.search.substring(1);
                console.log(urlSubstring);
                if (urlSubstring.indexOf("?") > 0) {
                    var myparams1 = urlSubstring.split('?');
                    urlSubstring = myparams1[1];
                }
                if (urlSubstring) {
                    var params = urlSubstring.split('&&');
var variablesPair = params;
                        if ((index = variablesPair.indexOf("=")) >= 0) {
                            var varReceived = variablesPair.substring(0, index);
                            var valueReceived = variablesPair.substring(index + 1);

 

LeLuong
Regular Contributor

Pardon me for more stupid questions. Now that I have the string, do you know how I can tell my field equal to the  "valueReceived" when users click save?  and all these codes should happen in widget.js file of Edit widget right ?  Thank you so much for your help and patience.


0 Kudos
LefterisKoumis1
Emerging Contributor

Like I heard before, there are no stupid questions, only stupid answers.

Not sure what do you mean save? Do you mean search? Yes, the code should be in the widget that you want to get the value from the URL.

0 Kudos
LeLuong
Regular Contributor

When I pick a feature to edit (using Edit widget), I'd like the account # users searched for pops in the account field ?  Is it do-able ?  In case it's too hard to insert the acct# there I'll settle with having the acct# automatically saved when users click save edit.  Hope I make sense to you.  Thanks.

EditWidget.PNG

0 Kudos