locked
How to provide access to external web page passing entity field data as query param? RRS feed

  • Question

  • I added a custom field to the Phone Call entity named new_callid.

    I want to add some kind of UI element to the Phone Call entity's form that when clicked would cause an external web page to be involved with the value of the new_callid field passed as a query parameter.

    For example, a URL like this:

    http://myserver/myapp?callid=<value of the phone call's new_callid field>

    I played around with various option but was unable to find a way to support this.

    Is this possible?

    Thanks!

    Tuesday, July 1, 2014 2:51 PM

All replies

  • Hello,

    yes, It is possibile... in JScript I use this code:

    System.Net.XmlHttpRequest getProjectRequest = new System.Net.XmlHttpRequest();
                    getProjectRequest.Open("GET", "http://myserver/app" + "?workItemId=" + worKItemId + "&refreshTime=" + Date.Now.GetTime(), true);
                    getProjectRequest.SetRequestHeader("Accept", "application/json");
                    getProjectRequest.SetRequestHeader("Content-Type", "application/json; charset=utf-8");
                    getProjectRequest.SetRequestHeader("Cache-Control", "no-cache");
                    getProjectRequest.SetRequestHeader("X-HTTP-Method", "GET");

    getProjectRequest.OnReadyStateChange = delegate()
                    {

     if (getProjectRequest.ReadyState == ReadyState.Loaded)
                        {
                            if (getProjectRequest.Status == 200)
                            {
                                object jsonResponse = JSON.Parse(getProjectRequest.ResponseText);

                            }

                       }

                   }

    This piece of code is used in Jscript method. It is in c# because I use Script# to convert it in javascript code to put in CRM


    Alessandro Graps

    Wednesday, July 2, 2014 7:55 AM
  • Thanks!

    I'm not clear where I'd be using this code.

    How is this getting plugged into CRM so a user can request that my page load when a C when a Phone Call entity form is open?

    How does my CallID (I assume the workItemID in your example) field get retrieved from the Phone Call entity field?

    Regards, Grant

    Wednesday, July 2, 2014 1:13 PM
  • Don't add any field on the form for creating button because this is unsupported. The supported way is to create a HTML web resource using following code:-

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <style type="text/css"> #Button1 { width: 122px; } </style> <script language="javascript" type="text/javascript"> // <![CDATA[ function Button1_onclick() { } // ]]> </script> </head> <body> <p> <input id="Button1" type="button" value="Open Form" onclick="return Button1_onclick()" /></p> </body> </html>

    In design mode of form click insert-->webresource and add this web resource on the form where required. Now you can write code in function function Button1_onclick()  to open the form.

    Regards Faisal

    Wednesday, July 2, 2014 1:29 PM
  • Thanks!  OK, I have it so I now get a button that when clicked gives control to a JavaScript method.

    However, how can the page get the value of a custom field of my Phone Call entity?

    Regards, Grant

    Wednesday, July 2, 2014 1:48 PM
  • OK, I think I'm almost there...

    I found an article which seems to indicate I can pass the value of form fields to my page.

    http://www.dynamic-crm.com/crm-javascript/

    Specifically, in my Web Resource Properties in the General tab in the "Custom Parameter(data)" I set "field1=subject".

    However, what I get in my page's query params decodes to a parameter of "field1" and a value of "subject".

    What I want is the value of subject, not the word "subject".

    The example shows a similar syntax apparently working to pass an address and zip to Bing maps.

    Regards, Grant

    Wednesday, July 2, 2014 2:19 PM
  • Put an alert:-

    alert(parent.Xrm.Page.data.entity.attributes.get("ADD_ATTRIBUTE_SCHEMA_NAME_HERE").getValue());

    like

    alert(parent.Xrm.Page.data.entity.attributes.get("subject").getValue());


    Regards Faisal


    Wednesday, July 2, 2014 2:19 PM
  • I think you don't need parameters as you need to pass data between pages. Using parent.Xrm.... you can directly access the attribute vales.

    Regards Faisal

    Wednesday, July 2, 2014 2:35 PM
  • Hot Damm!  You da man!

    OK, looking good.  I think I have all the techniques I need to craft a complete solution.

    Two follow-up questions:

    1) Right now I show a web resource (my page) which is just showing a button.  However it shows up inside a box and takes up more space than it needs (I found I needed at least 2 lines in the formatting.)  Anyway to hide the boarder?  Any other options for hosting a UI element that would load my page?

    2) In CRM is there a way to package a set of enhancements for distribution to customers/users?  Specifically I want to:

    -- Add a customer field to the Phone Call entity.

    -- Add the field to the Phone Call entity Form.

    -- Add a Web Resource containing my page.

    -- Add the Web Resource to the Phone Call entity Form.

    Wednesday, July 2, 2014 2:36 PM
  • 1) edit button in Visual Studio. You won't be able to get it 100% right

    2) solutions are used to transfer development between enviornments.

    Please make this as answered.


    Regards Faisal

    Wednesday, July 2, 2014 3:20 PM