Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Link between ribbon button and web resource

Posted on by Microsoft Employee

Hi all, I started to work with my current company as an apprentice developer and I am very new to the CRM world. I am developing an html page that needs to be opened upon the click of a ribbon button. The problem is that whenever I export the solution the link stays the same (eg the url of the webresource still points to my dev environment). How would I link the two without having to manually create the button every time I import this solution?

Thanks,

Christian

*This post is locked for comments

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Link between ribbon button and web resource

    Yes, you need Rest endpoints to retrieve the value from the configuration entity. Assuming your entity name is Configuration and you have 2 fields i.e. name & value then you can use the below script to retrieve the record with the name as "AppURL"

    --------------------------------------------------

    var req = new XMLHttpRequest();
    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/new_configurations?$select=new_configurationid,new_value&$filter=new_name eq 'AppURL'", true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("Prefer", "odata.include-annotations=\"*\",odata.maxpagesize=1");
    req.onreadystatechange = function() {
        if (this.readyState === 4) {
            req.onreadystatechange = null;
            if (this.status === 200) {
                var results = JSON.parse(this.response);
                for (var i = 0; i < results.value.length; i++) {

    // Your value will be returned here.
                    var new_value = results.value[i]["new_value"];
                }
            } else {
                Xrm.Utility.alertDialog(this.statusText);
            }
        }
    };
    req.send();

    --------------------------------------------------

    URL:

    xxxx.crm.dynamics.com/.../new_configurations$select=new_configurationid,new_value&$filter=new_name eq 'AppURL'

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Link between ribbon button and web resource

    you can use Java script to retrieve the environment url.

    Take a look getServerUrl and getClientUrl ( based on your CRM Version)

    msdn.microsoft.com/.../gg334511(v=crm.5).aspx

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Link between ribbon button and web resource

    One more question, how would I retrieve the url from the new record? Do I need to use REST points?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Link between ribbon button and web resource

    Never thought of that, that's really helpful. Thank you!

  • Verified answer
    Daniel Wikell Profile Picture
    Daniel Wikell 2,360 on at
    RE: Link between ribbon button and web resource

    Hi and welcome to the world of CRM!

    One good practice when it comes to environment specific values like your URL is to create a custom entity "Configuration" or something similar. Within that entity you can add custom fields that corresponds to your various environment specific values. Since this is data in an entity, it won't be affected by solution imports and will thus be unique within each instance of CRM.

    In your javascript code for the button you can then query CRM and retrieve the single configuration entity (you should probably only ever have one instance of this in each environment) and read the URL from the field value and use that instead of a hard coded value.

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans