locked
Set focus on CRM fields from Silverlight application RRS feed

  • Question

  • Hi Experts,

    I have a silverlight application which opens from Ribbon button click.From that application I have give one functionality to interact with Account entity and when the account form will open the focus should be on some specified field.

    I tried from, form load using Jscript it is working but If I normally open the form from crm the focus is going to that field.

    Can you please suggests me How i will do this separately from CRM and Silvelight.

    Wednesday, December 5, 2012 5:14 AM

Answers

  • Hi Experts,

    After some experiment I  done this from silverlight using C# and and use javascript inside the crm form.

     

    1)      string extraqs = "Parameter_Source=1";

    hbtn.NavigateUri = new System.Uri(_serverUrl + "/main.aspx?etc=1&id=%7b" + firstObjet.ProviderNameId1 + "%7d&pagetype=entityrecord&extraqs="+extraqs, System.UriKind.Absolute);

    2) Then Added a Jscript web resource and within this captures the variable info like below.

    function setFocus()
    {
    var param=Xrm.Page.context.getQueryStringParameters();
    var source=param["Parameter_Source"];
    if (source==undefined)
    { return; }
    else if(source=="1")
    {    
       Xrm.Page.getControl("field_name").setFocus(true);
       }
    }

    3)  Add the web resource to corresponding formLoad with parameter as Parameter_Source and datatype SafeString

    Thank you.



    • Marked as answer by Ashis_K Wednesday, December 5, 2012 11:01 AM
    • Edited by Ashis_K Wednesday, December 5, 2012 11:01 AM
    Wednesday, December 5, 2012 11:00 AM

All replies

  • Hi,

    you should be able to implement this once you have Xrm object, check this.


    Contact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Wednesday, December 5, 2012 6:28 AM
    Moderator
  • Hi Experts,

    After some experiment I  done this from silverlight using C# and and use javascript inside the crm form.

     

    1)      string extraqs = "Parameter_Source=1";

    hbtn.NavigateUri = new System.Uri(_serverUrl + "/main.aspx?etc=1&id=%7b" + firstObjet.ProviderNameId1 + "%7d&pagetype=entityrecord&extraqs="+extraqs, System.UriKind.Absolute);

    2) Then Added a Jscript web resource and within this captures the variable info like below.

    function setFocus()
    {
    var param=Xrm.Page.context.getQueryStringParameters();
    var source=param["Parameter_Source"];
    if (source==undefined)
    { return; }
    else if(source=="1")
    {    
       Xrm.Page.getControl("field_name").setFocus(true);
       }
    }

    3)  Add the web resource to corresponding formLoad with parameter as Parameter_Source and datatype SafeString

    Thank you.



    • Marked as answer by Ashis_K Wednesday, December 5, 2012 11:01 AM
    • Edited by Ashis_K Wednesday, December 5, 2012 11:01 AM
    Wednesday, December 5, 2012 11:00 AM