Custom Entity One Click: Difference between revisions

From Crystal Manager for Sage CRM
No edit summary
No edit summary
Line 16: Line 16:


   <script src="../../custompages/CRMTogether/CRViewer.js" type="text/javascript" language="JavaScript"></script>
   <script src="../../custompages/CRMTogether/CRViewer.js" type="text/javascript" language="JavaScript"></script>
Enter the following script code into the page
----
  var ButtonGroup;
  //set the name of your CRM
  var CRMName="CRM71";
 
  function addButton(name, caption, imgname, reportname, pdfformat, createcomm, CE, CE_ID, LE)
  {
 
    getButtonGroup();
   
    var rowCount = ButtonGroup.rows.length;
    var row = ButtonGroup.insertRow(rowCount);
 
    var cell1 = row.insertCell(0);
    cell1.innerHTML='<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0><TR><TD><A id="'+name+'1" CLASS=ButtonItem HREF="" ><IMG SRC="/'+
      CRMName+'/Themes/img/color/Buttons/'+imgname+'" BORDER=0 ALIGN=MIDDLE></A></TD><TD>&nbsp;</TD><TD><A id="'+
      name+'2" CLASS=ButtonItem HREF="" >'+caption+'</A></TD></TR></TABLE>';
 
    var item1=document.getElementById(name+"1");
   
    var item2=document.getElementById(name+"2");
 
    item1.href=buildURL("CRViewer/NewWindow.aspx")+"rptname="+reportname;
    item1.href+="&CE="+CE;
    item1.href+="&CE_ID="+CE_ID;
    item1.href+="&LE="+LE;
    if (pdfformat==true)
    {
      item1.href+="&pdfformat=Y";
    }
    if (createcomm==true)
    {
      item1.href+="&createcomm=Y";
    }
   
    item2.href=item1.href;
 
  }
 
  function getButtonGroup()
  {
    var ButtonGroup_col=document.getElementsByTagName("TABLE");
    for(var i=0;i<ButtonGroup_col.length;i++)
    {
      ButtonGroup=ButtonGroup_col[i];
      if (ButtonGroup.className=="ButtonGroup")
      { 
        break;
      }
    }
  }
 
  function buildURL(PagePath)
  {             
    var strFileName = PagePath;
    var strPath = document.URL;
    if (strPath.indexOf("eware.dll")!=-1)
    {
      var arrayApp = strPath.split("eware.dll"); 
      PagePath="CustomPages/"+PagePath;
    }else{
      var arrayApp = strPath.split("CustomPages");
      arrayApp[0]+="CustomPages/";
    }
 
    var arrayContext = strPath.split("?");
    var strAppPath = arrayApp[0];
    var strContextInfo = arrayContext[1];
    strAddr= strAppPath + PagePath+"?"+strContextInfo+"&";
    return strAddr;
  }
 
  function CRMTogether_Onload()
  {
    //here we add in the button
    addButton("Report", "Report", "edit.gif","testerrpt.rpt", true, true,"comm_testerid", "test_testerid","libr_testerid");
  }
 
  window.onload=CRMTogether_Onload;
----

Revision as of 17:49, 21 April 2012

coming soon...

There is some manual work to create a one click button into a custom entity in CRM.

We provide the details here as well as sample code.

The button is created by add in some code to the custom content which adds in a button when the page is loaded.

Create a folder within the CRM "CustomPages" folder. In our example we will call this folder "CRMTogether".

Create a file there called "CRViewer.js".

Select a CRM screen that exists on the page you wish to create the button.

Within the "custom content" of that screen enter a path to the script

 <script src="../../custompages/CRMTogether/CRViewer.js" type="text/javascript" language="JavaScript"></script>

Enter the following script code into the page


 var ButtonGroup;
 //set the name of your CRM
 var CRMName="CRM71";
 
 function addButton(name, caption, imgname, reportname, pdfformat, createcomm, CE, CE_ID, LE)
 {
 
   getButtonGroup();
   
   var rowCount = ButtonGroup.rows.length;
   var row = ButtonGroup.insertRow(rowCount);
  
   var cell1 = row.insertCell(0);

cell1.innerHTML='

<A id="'+name+'1" CLASS=ButtonItem HREF="" ><IMG SRC="/'+ CRMName+'/Themes/img/color/Buttons/'+imgname+'" BORDER=0 ALIGN=MIDDLE></A> <A id="'+ name+'2" CLASS=ButtonItem HREF="" >'+caption+'</A>

';

   var item1=document.getElementById(name+"1");
   
   var item2=document.getElementById(name+"2");
 
   item1.href=buildURL("CRViewer/NewWindow.aspx")+"rptname="+reportname;
   item1.href+="&CE="+CE;
   item1.href+="&CE_ID="+CE_ID;
   item1.href+="&LE="+LE;
   if (pdfformat==true)
   {
     item1.href+="&pdfformat=Y";
   }
   if (createcomm==true)
   {
     item1.href+="&createcomm=Y";
   }
   
   item2.href=item1.href;
 
 }
 
 function getButtonGroup()
 {
   var ButtonGroup_col=document.getElementsByTagName("TABLE");
   for(var i=0;i<ButtonGroup_col.length;i++)
   {
      ButtonGroup=ButtonGroup_col[i];
      if (ButtonGroup.className=="ButtonGroup")
      {  
        break;
      }
   }
 }
 
 function buildURL(PagePath)
 {               
   var strFileName = PagePath;
   var strPath = document.URL;
   if (strPath.indexOf("eware.dll")!=-1)
   {
     var arrayApp = strPath.split("eware.dll");  
     PagePath="CustomPages/"+PagePath;
   }else{
     var arrayApp = strPath.split("CustomPages");
     arrayApp[0]+="CustomPages/";
   }
  
   var arrayContext = strPath.split("?");
   var strAppPath = arrayApp[0];
   var strContextInfo = arrayContext[1];
   strAddr= strAppPath + PagePath+"?"+strContextInfo+"&";
   return strAddr; 
 }
 
 function CRMTogether_Onload()
 {
   //here we add in the button
   addButton("Report", "Report", "edit.gif","testerrpt.rpt", true, true,"comm_testerid", "test_testerid","libr_testerid");
 }
 
 window.onload=CRMTogether_Onload;