web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Link between ribbon button and web resource

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Verified answer
    Daniel Wikell Profile Picture
    2,360 on at

    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.

  • Community Member Profile Picture
    on at

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

  • Community Member Profile Picture
    on at

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

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    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

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    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'

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans