CRM 2011: Adding the Show article checkbox to a custom entity

Answered CRM 2011: Adding the Show article checkbox to a custom entity

  • Thursday, April 12, 2012 5:19 PM
     
     

    Hi all, Is there anyway to add the 'Show Article' checkbox to a custom entity ?

    Thanks and best regards..

All Replies

  • Thursday, April 12, 2012 6:06 PM
     
     

    Hi,

      not sure it's the best solution, but you can always do it this way:

    1. Add a lookup to the article
    2. Add a javascript that will fire in form.onload
    3. In that javascript, add a checkbox control to your form (in the same way you would do it for an html button.. You might add a web resource to the form and replace that web resource with checkbox in the onload)
    4. Make sure you have an iframe added to the form. It should be hidden by default
    5. When adding a checkbox, specify onclick handler
    6. In the onclick handler, replace iframe source (and make iframe visible/hidden)
    7. IFrame source should be set to the following url:

           http://server/organization/cs/articles/viewer/content.aspx?id={ARTICLE_ID}

          Just replace ARTICLE_ID with the ID of your article (it will be stored in the lookup)

      


    Alex Shlega, GotchaHunter.Net

  • Thursday, April 19, 2012 11:08 AM
     
      Has Code

    I tried to do something similar using javascript

    I have added lookup for articles and radio button show article and an iFrame so that when the lookup for articles is not null the radio button is enabled and when the radio button is set to yes the article is shown in the iFrame.

    Below is the code that I have used:

    function kbarticle_onchange()
    {
        if(Xrm.Page.getAttribute("intercom_kbarticle").getValue() == null)
            Xrm.Page.ui.controls.get("intercom_showarticle").setDisabled(true);
        else
            Xrm.Page.ui.controls.get("intercom_showarticle").setDisabled(false);
    }
    
    function showarticle_onchange()
    {
        if (Xrm.Page.getAttribute("intercom_showarticle").getValue() == "0") 
        {
            Xrm.Page.getControl("IFRAME_articleiframe").setVisible(false);
        }
    
        else if (Xrm.Page.getAttribute("intercom_showarticle").getValue() == "1") 
        {
            var strOrgURL = location.hostname;
            var strOrgName = Xrm.Page.context.getOrgUniqueName();
    
            var article = Xrm.Page.getAttribute("intercom_kbarticle").getValue();
            var articleid
            if(article != null)
            {
                articleid = article[0].id;
                alert(articleid);
            }
    
            Xrm.Page.getControl("IFRAME_articleiframe").setVisible(true);
            Xrm.Page.getControl("IFRAME_articleiframe").setSrc("http://" + strOrgURL + "/" + strOrgName + "/cs/articles/viewer/content.aspx?id=" + articleid);
        }
    }

    everything goes well except that the the article is never displayed in the iFrame, it just display a blank form.

    Please advise..

  • Thursday, April 19, 2012 11:53 AM
     
      Has Code

    Hi Mostafa,

    Try to debug your js code and make sure URL is correct.

    var URL="http://" + strOrgURL + "/" + strOrgName + "/cs/articles/viewer/content.aspx?id=" + articleid ;
    Xrm.Page.getControl("IFRAME_articleiframe").setSrc(URL);



  • Thursday, April 19, 2012 1:30 PM
     
      Has Code

    Vikram,

    I have tried to open the URL in internet explorer and it opened the same blank page, then I tried the below URL:

    http://" + strOrgURL + "/" + strOrgName + "/main.aspx?etc=127&extraqs=%3fetc%3d127%26id%3d%257b"

    +articleid+"%257d%26pagemode%3diframe%26preloadcache%3d1334836501871&pagetype=entityrecord

    which is the article form URL, it displays only the form ribbon and an error for the rest of the record.

    Please advise, I need only to display the article contents not the full form

    Best regards..


    • Edited by mo32 Thursday, April 19, 2012 1:30 PM
    •  
  • Thursday, April 19, 2012 1:50 PM
     
     Answered

    Hi Mostafa,

    I have tried to open the URL in internet explorer and it opened the same blank page-The reason is that your article is not published one please make sure your article should be published one.


    • Edited by _Vikram Thursday, April 19, 2012 1:52 PM
    • Marked As Answer by mo32 Thursday, April 19, 2012 2:41 PM
    •