1 line
5.1 KiB
Plaintext
1 line
5.1 KiB
Plaintext
{"Name":"z_ayGetFromAPI display additional data from linked customer object","Active":true,"Notes":"Example of using the ayGetFromAPI to display data from the Customer record when reporting on the Unit record","Roles":124927,"AType":31,"IncludeWoItemDescendants":false,"Template":"<html>\n <body>\n\t<div>\t\n\t\t<div class=\"reporttitle\">\n\t\t\t<p>Using API method to obtain additional data from the {{ayT 'Customer'}} record</p>\n\t\t</div>\n <table>\n <thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan=\"10\">Data from the Unit record</th>\n\t\t\t\t\t<th colspan=\"2\"></th>\n\t\t\t\t\t<th colspan=\"12\">Data from the Unit's Customer record obtained using API method</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan=\"6\">{{ayT 'Customer'}} {{ayT 'Unit'}}</th>\n\t\t\t\t\t<th colspan=\"5\">{{ayT 'Customer'}}</th>\n\t\t\t\t\t<th colspan=\"1\"></th>\t\t\t\t\t\n\t\t\t\t\t<th colspan=\"4\">{{ayT 'Customer'}} {{ayT 'CustomerEmail'}}</th>\n\t\t\t\t\t<th colspan=\"4\">{{ayT 'Customer'}} {{ayT 'CustomerPhone1'}}</th>\n\t\t\t\t\t<th colspan=\"4\">{{ayT 'Customer'}} {{ayT 'HeadOffice'}}</th>\n\t\t\t\t </tr>\n \t\t</thead>\n\t\t\t <tbody>\n\t\t\t\t {{#each ayReportData}} \n\t\t\t\t <tr>\n\t\t\t\t\t<td colspan=\"6\">{{Serial}} {{UnitModelNameViz}}</td>\n\t\t\t\t\t<td colspan=\"5\">{{CustomerViz}}</td>\n\t\t\t\t\t<td colspan=\"1\"></td>\t\t\t\t\t\n\t\t\t\t\t<td colspan=\"4\">{{myCustomerInfo.emailAddress}}</td>\n\t\t\t\t\t<td colspan=\"4\">{{myCustomerInfo.phone1}}</td>\n\t\t\t\t\t<td colspan=\"4\">{{myCustomerInfo.headOfficeViz}}</td>\n\t\t\t\t </tr>\n\t\t\t\t {{/each}}\n\t\t\t </tbody>\n </table>\n\n<!-- uncomment this to see printout of data returned from the custom Prepare\n <table>\n {{#each ayReportData}}\n <tbody>\n <tr>\n <td colspan=\"24\">This is a printout of the data returned from the custom Prepare that this report now uses for each unit in the datalist. To display any of the Customer data ported over, just identify in mustaches myCustomerInfo.xxxx where xxx is the key as in CustomerInfo.phone1</td>\n </tr>\n <tr>\n\t\t\t <td colspan=\"24\" class=\"leftlean\">{{ayJSON this}}</td>\n </tr>\n </tbody>\n {{/each}}\n </table>\n-->\n\n </div>\n</body>\n</html>","Style":".singlePage\r\n{\r\npage-break-after: always;\r\n\r\n}\r\nbody {\r\n font-family: 'Helvetica', 'Helvetica Neue', Arial, sans-serif; \r\n}\r\n\r\n.reporttitle { \r\n margin-bottom: 20pt; \r\n font-weight: bold; \r\n font-size: 13pt; \r\n color: #9e9e9e;\r\n text-align: center;\r\n} \r\n\r\ntable { \r\n border-collapse: collapse;\r\n white-space: pre-wrap;\r\n width: 100%;\r\n table-layout: fixed; \r\n }\r\n\r\nth {\r\n /* border-bottom: solid 1pt #9e9e9e; */\r\n height: 30px;\r\n font-size: 11pt; \r\n color: #9e9e9e;\r\n}\r\n\r\ntbody td {\r\n padding: 10px;\r\n word-wrap: break-word;\r\n font-size: 9pt;\r\n}\r\n\r\n\r\ntbody tr:nth-child(even) {\r\n background-color: #f8f8f8; /* MUST checkmark Print background in PDF Options for this to show */\r\n}\r\n\r\n\r\n.rightlean {\r\n text-align: right;\r\n}\r\n.leftlean {\r\n text-align: left;\r\n}\r\n.centerlean {\r\n text-align: center;\r\n}\r\n\r\n\r\n.fontgreen {\r\n color: green;\r\n font-size: 16pt;\r\n}\r\n.fontblue {\r\n color: blue;\r\n}\r\n.fontred {\r\n color:red;\r\n}\r\n\r\n","JsPrerender":"async function ayPrepareData(ayData) {\n\n await ayGetTranslations([\"Unit\", \"Customer\", \"CustomerEmail\", \"CustomerPhone1\", \"HeadOffice\" ]);\n \n //Loop through all the records in the raw report data\n for (let i = 0; i < ayData.ayReportData.length; i++) {\n //set a temporary variable to each record to save typing it all out\n let item = ayData.ayReportData[i];\n\n //call into the AyaNova API and get the customer record for this report data's customer id\n const apiResult = await ayGetFromAPI(`customer/${item.CustomerId}`);\n\n //if a result comes back, insert it into the report data so it's available to the template\n if (apiResult) {\n //put the return data customer record on a key in each record called 'myCustomerInfo' (you can call it anything as long as it doesn't conflict with an existing key)\n item.myCustomerInfo = apiResult.data\n }\n }\n return ayData;\n}","JsHelpers":"","RenderType":0,"HeaderTemplate":"<span style=\"font-size:6pt; width: 96%;text-align:left; \"> Printed date: PDFDate</span>\n\n<span style=\"font-size:6pt;width: 96%; text-align: right; \">Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span> </span>","FooterTemplate":"<span> </span>","DisplayHeaderFooter":true,"PaperFormat":10,"Landscape":true,"MarginOptionsBottom":"15mm","MarginOptionsLeft":"15mm","MarginOptionsRight":"20mm","MarginOptionsTop":"20mm","PageRanges":null,"PreferCSSPageSize":false,"PrintBackground":true,"Scale":1.00000} |