javascript code for a custom button in isv.config RRS feed

  • Question

  • I have added a button for opportunity in the Grid. I need to write javascript for that. If its a simple one we can go for in-line javascript code. But my code will be too large. where can I write this code and attach the method to the button click event. I heard writing the custom javascript code in global.js is unsupported. So Kindly let me know which is a better approach...thanks in advance.
    Wednesday, November 24, 2010 10:18 AM


All replies

  • Hello, Bittu.

    You can develop and place JavaScript code to js file and load it dynamically - http://nishantrana.wordpress.com/2010/03/23/loading-external-javascript-files/

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    • Proposed as answer by Faisal Fiaz Wednesday, November 24, 2010 4:05 PM
    Wednesday, November 24, 2010 10:38 AM
  • Hello Andriy,


    Thanks a lot, I will that solution and will get back to you.

    Thursday, November 25, 2010 6:11 AM
  • Hello Andriy,


    I tried the solution in the link... none of them are working.....any other options...

    Tuesday, November 30, 2010 7:12 AM
  • Hello, Bittu.

    Can you paste the full code of ISV button you tried to implement?

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Tuesday, November 30, 2010 7:14 AM
  • Hello Andriy,

    Below is the button I added to the grid in ISV config file

    <Entity name="opportunity">
            <Button Icon="/_imgs/Picon.gif" JavaScript="var scriptElement=document.createElement('&lt;script type='text/javascript’&gt;'); scriptElement.src='/isv/ExtJs/customscript.js';scriptElement.attachEvent('onreadystatechange',loadScript); document.getElementsByTagName('head')[0].insertAdjacentElement('beforeEnd',scriptElement); function loadScript(){if(event.srcElement.readyState=='loaded' || event.srcElement.readState=='complete'){ ValidateUserRole();}}" WinParams="" WinMode="0">
                <Title LCID="1033" Text="Request" />
                <ToolTip LCID="1033" Text="Click to Request" />


    below is the code I wrote in a separate javascritp file (customscript.js) which is placed under isv/extjs folder...

    function ValidateUserRole() {

        alert('validating user role');
        //code for validating user role

    the error I'm getting is 'object expected' ...possibly because it is not able to find 'ValidateUserRole' method....please help me since the ValidateUserRole has too much of code in it.




    Wednesday, December 1, 2010 5:11 AM
  • Hello, Bittu.


    Try to use following approach:

    var url="/isv/ExtJs/customscript.js";
    var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Wednesday, December 1, 2010 6:50 AM