Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Plugin Custom dataprovider virtual entity zipcodes

Posted on by 55

I have the following idea to get addresses filled by zipcode and housenumber.

We are in the Netherlands and there is a webservice which returns address, municipality and geocodes.

https://api.postcodes.nl/1.0/address/?apikey=c7f43b848829511052e5701459d0d6904aace84cb2************************&nlzip6=1118CZ&streetnumber=354

Response is: 

{"status":"ok","results":[{"nlzip6":"1118CZ","streetname":"Evert van de Beekstraat","city":"Schiphol","municipality":"Haarlemmermeer","province":"Noord-Holland","latitude":"52.303780","longitude":"4.750269","phoneareacode":"020"}]}

With invalid request we get:
{"status":"error","errorcode":11,"errormessage":"no results"}


I would like to be able to call this from the accountcard where I have a field zipcode + housenumber.
I have tried with Javascript but run into the Cross-Origin Resource Sharing (CORS) limitations.

So I was thinking:
Can't we attach this to a virtual entity where we can do a lookup with Javascript and webapi call easily.

This webservice doesn't support multiple retrieve but when we can limit this to get this one records with parameters it will work I guess.

Or are there better ways to get this up and running.

If the virtual entity is the way to go I need the custom dataprovider but I am not used to create plugins with VS.

Thanks

 
  • MRCBob Profile Picture
    MRCBob 55 on at
    RE: Plugin Custom dataprovider virtual entity zipcodes

    I managed to get this working by the 3rd link with some additions:

    You need to add the jquery library https://jquery.com/download/ to the form before your own JS.

    I added the compressed version.

    In the JS script I needed to add a few lines in the top to get $ working.:

    if (typeof($) === 'undefined') {
    $ = parent.$;
    jQuery = parent.jQuery;
    }

    $.ajax({
    url: “ad4:51643/.../GetCode”,
    dataType: “jsonp”, //set data type as jsonp for cross domain request
    contentType: “application/json; charset=utf-8”,
    data: “city=Florida”, //pass value for city parameter
    success: function (data) {
    alert(“Name:” + data);
    },
    error: function (data) {
    if (data.responseText != “done”) {
    alert(“ERROR: ” + data.responseText);
    }
    else {
    alert(_msgSendRequest);
    }
    }
    });

    This part you need to modify for your own purpose, I didn't get the data: "city=Florida" in this part above but I kept it there.

  • Verified answer
    RajarajanS Profile Picture
    RajarajanS on at
    RE: Plugin Custom dataprovider virtual entity zipcodes

    Hello Partner, 

    Virtual entities is a way with which you can achieve the above requirement. You can retrieve and store the data in CRM and use it as required. More info docs.microsoft.com/.../create-edit-virtual-entities

    Here is some links you can refer-

    nishantrana.me/.../using-webclient-to-call-external-service-from-crm-online-sandboxed-plugin-http-post-and-json

    dynamicscrmcoe.com/calling-external-web-services-sandboxed-plugin

    www.inogic.com/.../make-cross-domain-web-service-request-through-client-side-scripting-in-dynamics-crm

    These should help you.

    If helpful, Please mark answer as Verified.

    Best Regards, 

    Raj

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans