Report JSON API: Difference between revisions

From Accelerator for SageCRM
(Created page with "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 ...image here... 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. CONTEXT The requests come in the format NAME_js.asp?SID=324333&entity=company&id=46 And...")
 
No edit summary
Line 49: Line 49:
DETAILS
DETAILS


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


   var _companyboxlong=JSON.clone(_reportItem);
   var _companyboxlong=JSON.clone(_reportItem);
   _companyboxlong.name='companyboxlong';
   _companyboxlong.name='companyboxlong';
   _companyboxlong.componenttype='screen';
   _companyboxlong.componenttype='screen';
   var qCompany=CRM.Findrecord("company,vsummarycompany","comp_companyid=123");
   var qCompany=CRM.Findrecord("company,vsummarycompany","comp_companyid="+Request.QueryString("id"));
   var companyboxlong=getScreenSection("company",qCompany,"companyboxlong","Some title");
   var companyboxlong=getScreenSection("company",qCompany,"companyboxlong","Some title");
   _companyboxlong.data=companyboxlong;
   _companyboxlong.data=companyboxlong;
   myreport.reportdetails.push(_companyboxlong);
   myreport.reportdetails.push(_companyboxlong);
a. 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);
FOOTER
Display some raw html in the footer
  var _footer=JSON.clone(_reportItem);
  _footer.name='rawfooterhtml';
  _footer.componenttype='html';
  _footer.element="div";
  _footer.data="<span style=\"background-Color:blue\">this is raw html in the footer</span>";
  myreport.reportfooter.push(_footer);

Revision as of 16:17, 19 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

...image here...

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.

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);

a. 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);

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);