Report JSON API: Difference between revisions

From Accelerator for SageCRM
No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 5: Line 5:
Example
Example


...image here...
[[File:graph sample.png]]


Any JSON API file must have the name
Any JSON API file must have the name
Line 12: Line 12:


The "_js.asp" tells the system that this data is JSON so it parses it correctly. If not then the page will just display as normal.  
The "_js.asp" tells the system that this data is JSON so it parses it correctly. If not then the page will just display as normal.  
The should include the "reportobjects.js" file
[[File:include reportobjects.png]]


CONTEXT
CONTEXT
Line 59: Line 63:
   myreport.reportdetails.push(_companyboxlong);
   myreport.reportdetails.push(_companyboxlong);


a. Here we show how to display a List based on an array of items
b. Here we show how to display a List based on an array of items


   var samplelist=JSON.clone(_reportItem);
   var samplelist=JSON.clone(_reportItem);
Line 67: Line 71:
   samplelist.data=getListSection(qsamplelist, "company", ["comp_name","comp_website"]);
   samplelist.data=getListSection(qsamplelist, "company", ["comp_name","comp_website"]);
   myreport.reportdetails.push(samplelist);
   myreport.reportdetails.push(samplelist);
c. You can also add in raw HTML (since 5.2.2.1)
  var _reportdetails=JSON.clone(_reportItem);
  _reportdetails.name='rawreportdetailshtml';
  _reportdetails.componenttype='html';
  _reportdetails.element="div";
  _reportdetails.data="<span style=\"background-Color:red\">this is raw html in the details area</span>";
  myreport.reportdetails.push(_reportdetails);


FOOTER
FOOTER
Line 78: Line 90:
   _footer.data="<span style=\"background-Color:blue\">this is raw html in the footer</span>";
   _footer.data="<span style=\"background-Color:blue\">this is raw html in the footer</span>";
   myreport.reportfooter.push(_footer);
   myreport.reportfooter.push(_footer);
Ability to add a "title"
  var sampletitlex=JSON.clone(_reportItem);
  sampletitlex.name='sampletitlex';
  sampletitlex.componenttype='title';
  sampletitlex.data="sampletitlex text";
  myreport.reportdetails.push(sampletitlex);

Latest revision as of 12:18, 23 June 2023

A sample asp file is provided that has code demonstrating the details for the API.

The file is an ASP page and it generates JSON that the app knows how to process.

Example

Any JSON API file must have the name

  NAME_js.asp

The "_js.asp" tells the system that this data is JSON so it parses it correctly. If not then the page will just display as normal.

The should include the "reportobjects.js" file

CONTEXT

The requests come in the format

 NAME_js.asp?SID=324333&entity=company&id=46

And the context is set with the "entity" and "id" querystring values

To create a report

 var myreport= JSON.clone(_reportClass);
 myreport.name="test101";
 //title
 myreport.title="Sample Report";

Reports have 3 sections

 1. reportheader
 2. reportdetails
 3. reportfooter

HEADER

Here we show how to add in some raw html to the header

 var _header=JSON.clone(_reportItem);
 _header.name='rawheaderhtml';
 _header.componenttype='html';
 _header.element="div";
 _header.data="this is raw html in the header";
 myreport.reportheader.push(_header);

DETAILS

a. Here we show how to display a screen based on a CRM screen

 var _companyboxlong=JSON.clone(_reportItem);
 _companyboxlong.name='companyboxlong';
 _companyboxlong.componenttype='screen';
 var qCompany=CRM.Findrecord("company,vsummarycompany","comp_companyid="+Request.QueryString("id"));
 var companyboxlong=getScreenSection("company",qCompany,"companyboxlong","Some title");
 _companyboxlong.data=companyboxlong;
 myreport.reportdetails.push(_companyboxlong);

b. Here we show how to display a List based on an array of items

 var samplelist=JSON.clone(_reportItem);
 samplelist.name='samplelist';
 samplelist.componenttype='list';
 var qsamplelist=CRM.Findrecord("company,vsummarycompany","comp_companyid<"+Request.QueryString("id"));
 samplelist.data=getListSection(qsamplelist, "company", ["comp_name","comp_website"]);
 myreport.reportdetails.push(samplelist);

c. You can also add in raw HTML (since 5.2.2.1)

 var _reportdetails=JSON.clone(_reportItem);
 _reportdetails.name='rawreportdetailshtml';
 _reportdetails.componenttype='html';
 _reportdetails.element="div";
 _reportdetails.data="this is raw html in the details area";
 myreport.reportdetails.push(_reportdetails);

FOOTER

Display some raw html in the footer

 var _footer=JSON.clone(_reportItem);
 _footer.name='rawfooterhtml';
 _footer.componenttype='html';
 _footer.element="div";
 _footer.data="this is raw html in the footer";
 myreport.reportfooter.push(_footer);


Ability to add a "title"

 var sampletitlex=JSON.clone(_reportItem);
 sampletitlex.name='sampletitlex';
 sampletitlex.componenttype='title';
 sampletitlex.data="sampletitlex text";
 myreport.reportdetails.push(sampletitlex);