KServer Report JSON Syntax: Difference between revisions

From KeystoneIntranet
Jump to navigation Jump to search
 
m (1 revision imported)
 

Latest revision as of 12:58, 14 July 2023

KServer reports are defined by adding a "report" object to an existing KServer endpoint. The report object is specified at the endpoint root level. KServer does not process the "report" object but instead passes it to the caller when the endpoint is called with the "$GETREPORT=1" query parameter.

Report Object Structure

"report": {
  "title": "Sample Report",   // the title for the report (prints at top of report and is used as the screen form caption)
  "activefieldcount": 1,      // the number of fields that represent an "active" item (controls visibility of "Include Active/Include Inactive" checkboxes)
  "export": true              // true to allow the report data to be exported to a file
  "grandtotal": true          // true to print a grand total on the report
  "optionsection": "section", // key to be used to persist the options for this report
  "afterprint": {               
  },
  "afterreport": {
  },
  "beforereport": {
  },
  "selection": [
  ],
  "sequence": [
  ],
  "options": [
  ],
  "groups": [
  ],
  "fields": [
  ],
  "variables": {
  }
}

Report AfterPrint Object Structure

The AfterPrint object is used to execute another endpoint after the report has successfully printed. A confirmation dialog can also be displayed with Yes, No and Cancel options.

"afterprint": {
  "confirm": "Do you want to proceed?",  // message to display in a dialog with Yes, No and Cancel options after the report is completely printed
  "endpoint": "SampleReportUpdate"       // endpoint to execute after the report is completely printed (and if the user selects Yes on the confirm dialog)
}

Report AfterReport Object Structure

The AfterReport object is used to execute another endpoint after the report has previewed/printed. It will execute following the AfterPrint endpoint has executed.

"afterreport": {
  "endpoint": "SampleReportClear"  // endpoint to execute after the report has been previewed/printed (and after the "AfterPrint" endpoint is executed)
}

Report BeforeReport Object Structure

The BeforeReport object is used to execute another endpoint immediately prior to the start of report processing.

"beforereport": {
  "endpoint": "SampleReportPrepare"  // endpoint to execute before the report begins processing
}

Report Selection Array Structure

The Selection array is used to populate the "Selection Criteria" grid on the report screen.

"selection: [
  {
    "title": "Sample Field",          // description of the selection field to be displayed on screen
    "field": "SAMPLE_FIELD",          // selection fieldname
    "type": "string",                 // field type can be one of:
                                      //   string            (a string which is forced uppercase)
                                      //   mixedstring       (a string with is mixed case)
                                      //   integer           (an integer)
                                      //   posinteger        (a positive integer or zero)
                                      //   date              (a date) 
                                      //   lookup            (a dropdown list populated from a database query)
                                      //   lookupchecklist   (a dropdown checklist populated from a database query) 
                                      //   list              (a dropdown list populated from predefined values)
                                      //   checklist         (a dropdown checklist populated from predefined values)
    "condition": "in($SEQUENCE, 1)",  // condition which must evaluate to True for the selection item to be displayed
    "list": {                          
      "type": "SampleList"            // internal identifier (see Report Selection List Types below) which controls the contents of a list/checklist option
    },
    "lookup": {
      "type": "SampleLookup"          // internal identifier (see Report Selection Lookup Types below) which controls the contents of a lookup/lookupchecklist option
    }
  }
]

Report Selection List Types

List Type Description
ARCODFlag A/R Customer COD Flag values
ARLocType A/R Location Type values
ARLocXfrMethod A/R Location Xfr Method values
ARPlantType A/R Plant Type values
ARProdAutoQty A/R Product Auto Qty values
ARProdType A/R Product Type values
ARTaxLocCalcMethod A/R Tax Locality Calc Method values
ARTaxLocLevel A/R Tax Locality Level values
ARTruckType A/R Truck Type values
CCStatusFlag System Session Status values
CCUMSSystem Unit of Measure System values
CCUMSType Unit of Measure Type values
CMAcctType C/M Account Type values
YesNoFlag Yes/No Flag values

Report Selection Lookup Types

Lookup Type Description
AP1099Class A/P 1099 Classes
APExemptClass A/P Use Tax Exempt Classes
APPayTermsClass A/P Payment Terms Classes
APTaxAuthority A/P Use Tax Authorities
APVendor A/P Vendors
APVendorClass A/P Vendor Classes
ARAllowanceClass A/R Allowance Classes
ARCreditTermsClass A/R Credit Terms Classes
ARCustomer A/R Customers
ARCustomerClass A/R Customer Classes
ARDivision A/R Divisions
ARDriver A/R Drivers
ARExemptClass A/R Sales Tax Exempt Classes
ARJobClass A/R Job Classes
ARLocation A/R Locations
AROwner A/R Owners
ARPlant A/R Plants
ARPriceGroup A/R Price Groups
ARProduct A/R Products
ARProductClass A/R Product Classes
ARSalesperson A/R Salespeople
ARTaxAuthority A/R Sales Tax Authorities
ARTruck A/R Trucks
ARTruckClass A/R Truck Classes
ARUnitOfMeasure A/R Units of Measures
ARZone A/R Zones
CCUser System Users
CMBankAcct C/M Bank Accounts
CMBankName C/M Bank Accounts
GLAccount G/L Accounts
GLGroup G/L Groups
GLNRMCAGroup G/L NRMCA Groups
GLSegments G/L Account Segments
GLSourceCode G/L Source Codes
QTProspCustList Quote combined Prospect/Customer List

Report Sequence Array Structure

The Sequence array is used to populate the "Report Sequence" dropdown on the report screen.

"sequence": [
  {
    "title": "Sample Sequence",               // description of the sequence to be displayed on screen
    "field": "SAMPLE_FIELD_1;SAMPLE_FIELD_2"  // sequence fieldname(s)
  }
]

Report Options Array Structure

The Options array is used to populate the user-selectable options when setting up the report.

"options": [
  {
    "title": "Sample Option",  // on-screen title for the option
    "type": "checkbox",        // option type (checkbox, checklist, edit, list)
    "param": "SEL_INCLUDE",    // query parameter name to be set by this option
    "condition": "",           // condition which must evaluate to True for the option to be displayed
    "optionname": "option",    // key to be used to persist this option for this report 

    "checkbox": {              // *** this object present only for checkbox type  
      "valuechecked": "Y",     // value returned if a checkbox option is checked (value can be string, bool or number)
      "valueunchecked": "N"    // value returned if a checkbox option is unchecked (value can be string, bool or number)
    },

    "checklist": {             // *** this object present only for checklist type
      "items": [               // list of items for the checklist box
        {
          "title": "Job Totals",   // on-screen title for the first list item
          "value": "1"             // value returned if this list item is checked
        },
        {
          "title": "Plant Totals", // on-screen title for the second list item
          "value": "2"             // value returned if this list item is checked
        },
      ] 
    },

    "edit": {                  // *** this object present only for edit type
      "type": "string"         // edit type (string, mixedstring, integer, posinteger, date)
    },

    "list": {                  // *** this object present only for list type
      "items": [               // list of items for the radio group box
        {
          "title": "Summary",  // on-screen title for the first list item
          "value": "1"         // value returned if this list item is selected
        },
        {
          "title": "Detail",   // on-screen title for the second list item
          "value": "2"         // value returned if this list item is selected
        },
      ] 
    }
  }
]

Report Groups Array Structure

The Groups array is used to define grouping/subtotal levels for the report.

"groups": [
  {
    "level": 1,            // group level
    "label": "Group",      // label for subtotal line for this group
    "subtotal": true,      // print subtotals for this group (default=False)
    "inline": true,        // group indicate on the same line as the report detail (default=False)
    "autosequence": true,  // automatically sort by this group's fields if selected (default=True)
    "condition": ""        // condition which must evaluate to True for this group to be processed
  }
]

Report Fields Array Structure

The Fields array is used to define detail fields for the report. This section is optional. If it is not specified all query fields will be printed as detail fields.

"fields": [
  {
    "label": "Sample Label",  // heading label to print for this field
    "field": "SAMPLE_FIELD",  // field name
    "format": "#.00",         // print format
    "align": "right",         // field alignment (left, center, right)
    "width": 15,              // field width (if omitted the largest width for the field is automatically calculated)
    "group": 1,               // group level
    "calc": "",               // value printed is the result of the expression
    "printdetail": true,      // controls whether the field is printed on the detail line (default=true)
    "detail": {
      "col": 1,               // if present specifies the absolute column position for this field  
      "row": 1,               // if present specifies the absolute row position for this field within this record
      "newrow": true,         // if present indicates this field should print on the next row
      "condition": ""         // condition which must evaluate to True for this field to be printed
    },
    "printtotal": true,       // controls whether the field is totaled (default=False)
    "total": {
      "col": 1,                 // if present specifies the absolute column position for this field  
      "row": 1,                 // if present specifies the absolute row position for this field within this record
      "newrow": true,           // if present indicates this field should print on the next row
      "grouplevel": 1,          // always use this group level for the total value of this field (default=group for this field)
      "printlevel": [1, 2, 3],  // field total will be printed for the specified group levels (default=all)
      "condition": ""           // condition which must evaluate to True for this field to be totaled
    }
  }
]

Report Variables Object Structure

The Variables object is used to define variables for the report. This section is optional. When processing field expressions variables are referenced by their name prepended with a "$" character.

"variables": {
  "report": [
    "name": "repvar", // name of the report variable
    "calc": "",       // variable value is the result of the expression 
    "condition": ""   // condition which must evaluate to True for this variable to be evaluated
  ],
  "detail": [
    "name": "detvar", // name of the detail variable
    "calc": "",       // variable value is the result of the expression 
    "condition": ""   // condition which must evaluate to True for this variable to be evaluated
  ]
}