Search code examples
javascripthtmldynamics-crmdynamics-crm-2015

ms dynamics crm 2015 web resources html body onload function


I added an easy navigation link at my custom entity. This link calls a web resource::

<script> function TweetOnLoad(){ var tweetWord = window.parent.Xrm.Page.data.entity.attributes.get("new_name").getValue(); var dynamicUrl ="http://localhost:3000/?tw="+tweetWord ; location.href = dynamicUrl; } </script> 

body onload="TweetOnLoad()"

But there is a problem: I couldn't call the TweetOnLoad function on body tag, because crm doesn't allow. How can I handle this problem?


Solution

  • Is this an iFrame/WebResource, if so, you are probably better off to pass a URL parameter of the "new_name" attribute.

    From what you have though, move the JavaScript to the end of the HTML body tag and then call your function.

    function TweetOnLoad(){ 
       var tweetWord = window.parent.Xrm.Page.data.entity.attributes.get("new_name").getValue(); 
       var dynamicUrl ="http://localhost:3000/?tw="+tweetWord; 
       location.href = dynamicUrl; 
    }
    
    TweetOnLoad();