Hi,
I am currently trying to implement an Address Auto Completion Control.
As probably most users, we created our own entity "Country".
I would like to populate the Country lookup field on the front-end so the user can see the populated address.
I've started updating the account record using the WebApi with the lookup value and this works fine. But of course the user would have to refresh the page to see the change, which is not optimal.
I've seen this video of @AndrewButenko where he talks about enabling the Lookup as a bound property.
https://www.youtube.com/watch?v=NEQtbfQrAMU
I can build and upload my control, but I don't get it working - but also don't get an error.
I am using the Bing Address Completion Control from the pcf.gallery:
https://pcf.gallery/bing-address-autocomplete/
This is some code snippets.
I am just trying to set the lookup to to some static value, to check if in theory it could work.
Thanks for any help!
Microsoft.Maps.loadModule('Microsoft.Maps.AutoSuggest', {
callback: () => {
var options = {maxResults: 5};
var manager = new Microsoft.Maps.AutosuggestManager(options);
manager.attachAutosuggest('#searchBox', '#searchBoxContainer', (suggestionResult) => {
_this.street = suggestionResult.address.addressLine;
_this.city = suggestionResult.address.locality;
_this.county = suggestionResult.address.district;
_this.state = suggestionResult.address.adminDistrict;
_this.country = suggestionResult.address.countryRegion;
_this.zipcode = suggestionResult.address.postalCode;
_this.value = suggestionResult.formattedSuggestion || "";
_this.country_lookup[0].id = "{57916099-646b-e911-a828-000d3ab017db}";
_this.country_lookup[0].name = "Ireland";
_this.country_lookup[0].entityType = "dev_country";
_this.notifyOutputChanged();
});
},
errorCallback: () =>{alert("Error with loading of module Microsoft.Maps.AutoSuggest.");}
});
}
private selectedSuggestion(suggestionResult: Microsoft.Maps.ISuggestionResult): void {
alert(suggestionResult.formattedSuggestion);
this.value = "";
this.street = "";
this.city = "";
this.county = "";
this.state = "";
this.country = "";
this.zipcode = "";
this.country_lookup = [];
this.value = suggestionResult.formattedSuggestion || "";
this.notifyOutputChanged();
}
public getOutputs(): IOutputs {
return {
value: this.value,
street: this.street,
city: this.city,
county: this.county,
state: this.state,
country: this.country,
zipcode: this.zipcode,
country_lookup: this.country_lookup
};
}