locked
Handling Tabs on button click RRS feed

  • Question

  • Hi,


    I am trying to open a CRM record from an IFrame on button click.I need to open a particular tab when the record is loaded instead of the General Tab.Can somebody help me out. Can we handle that in the below line of code.


    btn22.Attributes.Add("onclick", "window.open('" + serverurl + "/userdefined/edit.aspx?id={" + XYZId + "}&_CreateFromType=2&_CreateFromId=" + _id + "&etc=10008#" + "',null,'status= no, resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');");

    Thx in Advance

    Friday, May 14, 2010 6:28 AM

Answers

  • Hi,

    U just need to pass an extra pameter in your URL which you can parse in javascript.

    e.g.

    btn22.Attributes.Add("onclick", "window.open('" + serverurl + "/userdefined/edit.aspx?id={" + XYZId + "}&_CreateFromType=2&_CreateFromId=" + _id + "&etc=10008#" + "',null,'status= no, resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no &changeDefaultFocus=Yes');");

    Now in above i have added one extra parameter &changeDefaultFocus=Yes

    Now in onload() you can parse the querystring & if changeDefaultFocus=Yes then set the focus to your desired tab, see below.

     

    var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if (pair[0] == "changeDefaultFocus") { 
                 crmForm.all.tab1Tab.click();

                 break;
        }

     

     


    Muhammad Ali Khan
    http://malikhan.wordpress.com
    Tuesday, May 18, 2010 11:05 AM

All replies

  • Take a look here http://ronaldlemmen.blogspot.com/2009/02/setting-focus-to-tab.html

    Try

    crmForm.all.tab1Tab.click();


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Tuesday, May 18, 2010 9:07 AM
    Moderator
  • thx rhett.

    but where do i handle this line in my code?

    I cannot write it on Load as there are different conditions to handle this.

    From the above scenario(original post) i need to open 2nd Tab .

    When the form is opened directly in CRM i need to direct to General Tab.

    How to handle this?

     

    Thx in Advance 

    Tuesday, May 18, 2010 9:45 AM
  • Hi,

    can u tell  us what condition u want to open the 2nd tab.

    If you want to open this from a custom application, u can send a QueryString  Parameter and parse the querystring parameter in javascript and then set the focus to the 2nd tab.

    How to parse queryString in javascript, check these  link, u can find more on google.

    http://www.idealog.us/2006/06/javascript_to_p.html

    http://adamv.com/dev/javascript/querystring

    http://www.eggheadcafe.com/articles/20020107.asp

    http://www.webmasterworld.com/forum91/907.htm


    Muhammad Ali Khan
    http://malikhan.wordpress.com
    Tuesday, May 18, 2010 9:49 AM
  • thx muhammed.

    I have a custom web application embedded in an IFrame . When data is entered and submitted(button on click) a CRM form will be opened with the corresponding data pointing towards the traditional General Tab. Instead of pointing to General Tab I want to point it to Custom Tab added (lets say Tab 4). What are the parameters to be passed so that when a button on web application is clicked to open a CRM form ,the form sets the focus to the 4th tab directly.

    Thx in Advance

    Tuesday, May 18, 2010 10:36 AM
  • Hi,

    U just need to pass an extra pameter in your URL which you can parse in javascript.

    e.g.

    btn22.Attributes.Add("onclick", "window.open('" + serverurl + "/userdefined/edit.aspx?id={" + XYZId + "}&_CreateFromType=2&_CreateFromId=" + _id + "&etc=10008#" + "',null,'status= no, resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no &changeDefaultFocus=Yes');");

    Now in above i have added one extra parameter &changeDefaultFocus=Yes

    Now in onload() you can parse the querystring & if changeDefaultFocus=Yes then set the focus to your desired tab, see below.

     

    var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if (pair[0] == "changeDefaultFocus") { 
                 crmForm.all.tab1Tab.click();

                 break;
        }

     

     


    Muhammad Ali Khan
    http://malikhan.wordpress.com
    Tuesday, May 18, 2010 11:05 AM