locked
problem with ISV buttons RRS feed

  • Question

  • hi

    I have few ISV buttons like Process, Return, Approved etc. on form

    These buttons are displayed based on some condition so i have written code to hide some of these buttons based on some condition.

    Suppose for some condition i am displaying only Process button but not Return and Approved buttons.

    I am doing this through java script.

    Problem is when form is loaded buttons are hidden properly but when i enlarge the form hidden buttons are displayed again on form.

     

     

     

    Thursday, August 26, 2010 6:39 AM

Answers

All replies

  • Have you included code to hide buttons on form onload ???
    Mahain : http://mahenderpal.wordpress.com
    Thursday, August 26, 2010 6:46 AM
    Moderator
  • Yes Mahender
    Thursday, August 26, 2010 6:51 AM
  • This problem will occur sometime. (Not sure on the root cause)

    Approch 1:

    Empty the OuterHTML instead of emptying the span or disabling the button

    var lis = document.getElementsByTagName('LI');
    var i = 0;
    while (i < lis.length)
    {
      if (lis[i].getAttribute('title') == '<<Your Title>>')
      {
       lis[i].outerHTML=''; // instead of lis[i].outerHTML='<SPAN></SPAN>'
      }
      i = i + 1;
    }

    Drawback: It will be a difficult task to re enable the button. We have to rebuild the span with attach event (easy way is to copy the span tag content onload)

    Approch 2:

    Handle window resize event onLoad.

    window.onresize = function()
    {
    var lis = document.getElementsByTagName('LI');
    var i = 0;
    while (i < lis.length)
    {
      if (lis[i].getAttribute('title') == '<<Your Title>>')
      {
       lis[i].style.display="none";
      }
      i = i + 1;
    }
    }

    Thanks & Regards
    Vinoth

    Thursday, August 26, 2010 7:00 AM
  • Just use the window.onresize event by setting this in your onload.

    window.attachEvent('onresize', theHideButtonFunction);

    function theHideButtonFunction()

    // Place your button hiding code here


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Thursday, August 26, 2010 7:01 AM
    Moderator
  • Thursday, August 26, 2010 7:02 AM
    Moderator
  • Thanks to all of you

    It is a great help to me.

    Thursday, August 26, 2010 7:07 AM