none
How to open a web page from CRM 2011 on condition

    Question

  • Hi Techies,

    I have a requirement where i need to open a webpage , so that user can select something on webpage , Upon selection it should be able to autofill values in crm fields.

    Actual requirement is, When ever user enters Zip by selecting Country, It should fill City, State automatically by retrieving from our own database, i can do it by creating a web service and fill it with the response.

    But there are some situations where there will be 2 cities for the same Zip code, If that is the case i should open a web page like below

    Depending upon the selection, I should be able to autofill the City, State .

    Could some one please suggest me the correct approach.

    Thanks in Advance.


    Sreeni Pavalla

    Monday, April 16, 2012 2:29 PM

Answers

All replies

  • How about opening the webpage as showModalDialog with JavaScript and read the return value and fill up the values in the CRM fields?
    Monday, April 16, 2012 2:44 PM
  • Hi,

    you can develop a custom page aspx/silverlight page, where you can pass zipcode as parameter and populate cities and populate your page back based on user selection.

     


    Mahain : Check My Blog
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Monday, April 16, 2012 3:25 PM
  • Thank you for the reply Linn and Mahender.

    I have already created a web page where i can send Zip code, I am able to open up a custom web page. But after selection how can i get the response back to CRM page and set the values to appropriate fields.. That is the question now

    and also i f i have only one record, I should not show up the page, I should be simply able to autofill the values.

    Please Advise

    Thank you,


    Sreeni Pavalla

    Monday, April 16, 2012 3:42 PM
  • You can reference the following example about opening the webpage as showModalDialog with JavaScript and returning the value from the ASPX page.

    http://briancaos.wordpress.com/2009/12/02/using-modal-windows-from-c-code/

    On change event of the ZIP field attribute, open the ASPX page with showModalDialog

    var result = window.showModalDialog("../AutofillZip/ZIP.aspx?zipcode=" + Xrm.Page.getAttribute("new_zipcode").getValue());

    Then, on Select event of the ASPX page, return the value in window.returnValue with client script.
    protected void btnSelect_Click(object sender, EventArgs e)
    {
      Session["MySession"] = "this is the data to return from my modal window";
      StringBuilder sb = new StringBuilder();
      sb.AppendLine(@"<script language=""javascript"" type=""text/javascript"">");
      sb.AppendLine(@"  var address = new Object();");
      sb.AppendLine(@"  address.city = document.getElementById("city").value;");
      sb.AppendLine(@"  address.countryregion = document.getElementById("countryregion").value;");
      sb.AppendLine(@"  window.returnValue = address;");
      sb.AppendLine(@"  window.close();");
      sb.AppendLine(@"</script>");
      ClientScript.RegisterClientScriptBlock(GetType(), "close", sb.ToString());
    }

    And the fill up the CRM fields based on the return value.

    But if your ASPX page is hosted in the different domain, you may not be able to catch the return value.

    Monday, April 16, 2012 4:10 PM
  • Hi,

    you can try to access MS CRM form field using "parent.document" from your custom webpage.


    Mahain : Check My Blog
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Monday, April 16, 2012 4:20 PM
  • Thanks Linn and Mahender.

    Is there anyway that you can explain how do i need to integrate web application with CRM and what changes i need to do in web.config?

    Your help is appreciated.

    Thanks


    Sreeni Pavalla

    Friday, April 20, 2012 12:51 PM
  • You can refer to the answer of Jehanzeb.Javeed in the following thread.

    http://social.microsoft.com/Forums/en/crmdevelopment/thread/f9dac869-86b0-4e7c-9c42-b4a49d415c26

    Saturday, April 21, 2012 8:57 AM
  • Hi Sreeni,

    In MS CRM 2011 deploying custom page in ISV folder is not supported you should deploy it under defferent website. but you still want to do that you can refer : http://nishantrana.wordpress.com/2011/01/20/could-not-load-file-or-assembly-microsoft-crm-version5-0-0-0-cultureneutral-publickeytoken31bf3856ad364e35-or-one-of-its-dependencies-the-system-cannot-find-the-file-specified-or-deploying/


    Mahain : Check My Blog
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Saturday, April 21, 2012 6:41 PM
  • Thanks for the replies Linna and Mahender.

    After adding http handler remove to the custom web site web.config, I am getting the following error.

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

    Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.

    Source Error:
    Line 14:   <system.web>
    Line 15:     <compilation debug="true" targetFramework="4.0"/>
    Line 16:     <authentication mode="Windows">
    Line 17:     </authentication>
    Line 18:     <authorization>

    Could you please advice.

    Thanks,


    Sreeni Pavalla

    Monday, April 23, 2012 12:18 PM
  • After removing the authentication tag from web.config, I can see the below error.

    Microsoft CRM Error Report:
    Error Description:
    An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Error Details:
    Exception of type 'System.Web.HttpUnhandledException' was thrown.

    Full Stack:
    [NullReferenceException: Object reference not set to an instance of an object.]
       at Zip.Page_Load(Object sender, EventArgs e)
       at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    
    [HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.]
       at System.Web.UI.Page.HandleError(Exception e)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
       at System.Web.UI.Page.ProcessRequest()
       at System.Web.UI.Page.ProcessRequest(HttpContext context)
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    
    

    Other Message:

    Error Number:

    Source File:
    Not available

    Line Number:
    Not available

    Error Trace:
    Date: 04-23-2012

    Time: 04:36:14

    Server: localhost
    Request URL:

    http://localhost/ISV/AutoZip/Zip.aspx

    Please advice.

    Thanks,

    Microsoft CRM Unhandled Error Details:
    <style></style>

    Server Error in '/' Application.

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:
    [NullReferenceException: Object reference not set to an instance of an object.]
       Zip.Page_Load(Object sender, EventArgs e) +75
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24
       System.Web.UI.Control.LoadRecursive() +70
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3063
    

    Basic Server & Client Information:
    <iframe frameBorder="0" id="ifrmDebug" src="/VoltInformationSciencesInc/home/home_debug.aspx" style="border-bottom:#999999 1px solid;border-width:100%;height:100%;border-border-right:#999999 1px solid;"></iframe>
    What the End User would have seen:
    <iframe frameBorder="0" id="ifrmEnduser" src="/_static/blank.htm" style="border-bottom:#999999 1px solid;border-width:100%;height:100%;border-border-right:#999999 1px solid;"></iframe>
    Copy to Clipboard:
    The error information has been copied to the clipboard.

    Sreeni Pavalla

    Monday, April 23, 2012 12:22 PM
  • Hi Sreeni,

    In this case,I think you can create a html page(as webresource).

    at that event you can call this webresource and with one input parameter ie. Postal code.

    now it will check how many records are in crm  for this postal code. if more than one record than it will open this html page otherwise no need to show this page.

    if the response answered your question, please take a minute and mark the response as an answer.


    Monday, April 23, 2012 1:06 PM