Sunday, January 6, 2013

Step by step tutorial to add the missing associated views to a CRM form.

In my last blog, I have posted the URL to add the navigation link for the relationships missing in the relationship explorer. I was in a hurry and did not explain how the URL can be used to add associated view to the form navigation. This blog will explain all the URL parameters and a step by step guide to achieve it.
URL Parameters
Here is the URL to display the associated view.
http://servername/orgname/userdefined/areas.aspx?oId=<guid of the entity>&oType=<entity type code>&pagemode=iframe&security=852023&tabSet=<relationship schema name>
The URL has following parameters
  1. oId: This parameter represents the guid of the entity opened in the form.
  2. oType: This parameter represents the entity type (object type code) of the entity
  3. pagemode: This parameter is static. pagemode=iframe means that this view will be displayed like an iframe and there will be no ribbon displayed for this view. The system will display a context ribbon when user selects the associated view grid.
  4. security: This parameter is also static. I am not changing this value.
  5. tabSet: This parameter represents the schema name of the relationship.
Here are all the steps to add the associated view to the form navigation.
  1. Create a HTML web resource. I named my web resource “AssociatedView.HTML”. Here is the code for the web resource.
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>Untitled Page</title>
        <style type="text/css">html,body{font-family: Segoe UI, Tahoma, Arial;background-color: #d6e8ff;border: 0px; margin: 0px; padding: 0px;}</style>
        <script type="text/javascript" language="javascript">
    
                //debugger;
    
                //get the context
                var Xrm = window.parent.Xrm;
    
                //get the current object id
                var oId = Xrm.Page.data.entity.getId();
    
                //get the object type
                var oType = Xrm.Page.context.getQueryStringParameters().etc;
    
                //set Relationship Name
                var relName = "lead_owning_user";
    
                //building a url
                var sUrl = "/userdefined/areas.aspx?oId=" + oId + "&oType=" + oType + "&pagemode=iframe&security=852023&tabSet=" + relName;
    
               
                //get relative path with orgname as required
                var relativeUrl = Xrm.Page.context.prependOrgName(sUrl);
                
                window.location = relativeUrl;
       
        </script>
    </head>
    <body>
    </body>
    </html>
  2. The only thing you need to change is the relationship name field. To do that open the entity relationships and get the schema name of the relationship. The following screen shot is displaying the relationship between user and lead entity. The user can be the owner of multiple leads.

    image
  3. Update the JavaScript in the HTML web resource. Save and publish the web resource.
  4. Open the entity form and click on navigation button. Then select the “navigation link” as shown in the following screen short.

    image
  5. The system will display the “Navigation Link Properties” dialog as shown in above screen shot. Enter the name for the navigation link. Choose an Icon and choose the web resource created in step 1 of the tutorial. Save the changes and publish the form.
  6. Open the form. The result will look like the following screen.

    image
Happy 2013 everyone.

11 comments:

  1. Your code contains small typos:
    "(" was replaced by "undefined"

    var oId = Xrm.Page.data.entity.getId();
    var oType = Xrm.Page.context.getQueryStringParameters().etc;
    var relativeUrl = Xrm.Page.context.prependOrgName(sUrl);

    ReplyDelete
  2. Thanks mate. I have updated the code.

    ReplyDelete
  3. Hi, I am trying to implement this, however when I click on the final navigation link I just get a blank blue page. Any ideas?

    ReplyDelete
  4. Nevermind, I must've had a typo in there. It's still not working for me though. I see the sub-grid now, but it is not displaying any leads.

    ReplyDelete
    Replies
    1. That's good. It depends if the records exist for the relationship.

      Delete
    2. I had browse the url in separate window. Getting error. I want to show the subgrid in crm main page using iframe..?

      Delete
  5. This isn't working for me either, all I get is a blue screen.

    ReplyDelete
  6. worked ! but there is no ribbon bar ( CRM 2015)

    ReplyDelete
  7. Hi,
    We are trying to display associated view in iFrame on Entity form in CRM 2016 version.
    We could do that using the same format as the following url:
    https://.crm.dynamics.com/userdefined/areas.aspx?oId=%7bA6F09DF8-8B80-E511-8110-C4346BAC59AC%7d&oType=1&pagemode=iframe&security=852023&tabSet=crisp_inspectionstation_crisp_item&rof=false&inlineEdit=1
    We are getting one issue, i.e,
    In iFrame, Command bar of associated view (with rof=false&inlineEdit=1) does not show up.
    Can you provide some help on this?

    ReplyDelete

  8. My name is Leah Brown, I'm a happy woman today? I told myself that any loan lender that could change my life and that of my family after having been scammed separately by these online loan lenders, I will refer to anyone who is looking for loan for them. It gave me and my family happiness, although at first I had a hard time trusting him because of my experiences with past loan lenders, I needed a loan of $300,000.00 to start my life everywhere as single mother with 2 children, I met this honest and God fearing online loan lender Gain Credit Loan who helped me with a $300,000.00 loan, working with a loan company Good reputation. If you are in need of a loan and you are 100% sure of paying the loan please contact (gaincreditloan1@gmail.com)

    ReplyDelete