Print

Function GetJSON() – how it works

Introduction

GetJSON() rule function allows to convert the content of the given AMODIT case form into a JSON formatted string. Depending on arguments provided this function may return the following content:

  • a few technical case data/fields;
  • the given case data/fields that are on the main case form (without tables);
  • a set of chosen case fields.

See the function specification or examples below.

How does GetJSON() function work?

The idea of how the GetJSON() function works is presented on the picture below.

The resulting JSON string may be then written into some file (by using SaveStringAsFile() function), sent via email (i.e. with SendMessage() function), or stored in AMODIT system log for debugging purposes.

Examples

For showing how the GetJSON() function works in practice we prepared a simple process with its case form that looks like this …

… and a sample manual rule with the following code:

WriteToSystemLog("no param", 2, GetJSON()); // [A]
WriteToSystemLog("'standard' param", 2, GetJSON("standard")); // [B]
WriteToSystemLog("'all' param", 2, GetJSON("all")); // [C]
WriteToSystemLog("a list of fields", 2, GetJSON("Some datetime field;Some number field")); // [D]

After running the manual rule the results (registered in the system log) are:

  • for calls [A] and [B]:
{
  "caseId": 100876,
  "fields": [
    {
      "name": "CaseTitle",
      "type": "Varchar",
      "value": "Free flow process (100876)"
    },
    {
      "name": "CaseProcedure",
      "type": "Procedure",
      "value": 2140,
      "displayValue": "Proces z obiegiem swobodnym"
    },
    {
      "name": "CaseStatus",
      "type": "Status",
      "value": 909,
      "displayValue": "Etap 1"
    },
    {
      "name": "CaseCreated",
      "type": "DateTimeWithTime",
      "value": "2022-12-30 12:26:10"
    },
    {
      "name": "CaseOwner",
      "type": "User",
      "value": 1064,
      "displayValue": "Zsakul Ttob (lbott)"
    },
    {
      "name": "CaseIsClosed",
      "type": "YesNo",
      "value": 0
    }
  ]
}

  • for call [C]
{
  "caseId": 100876,
  "fields": [
    {
      "name": "Some text field",
      "type": "Varchar",
      "value": "See you on the dark side of the moon"
    },
    {
      "name": "Some number field",
      "type": "Number",
      "value": 9087.54
    },
    {
      "name": "Some datetime field",
      "type": "DateTimeWithTime",
      "value": "2023-03-22 09:15:00"
    }
  ]
}
  • for call [D]
{
  "caseId": 100876,
  "fields": [
    {
      "name": "Some datetime field",
      "type": "DateTimeWithTime",
      "value": "2023-03-22 09:15:00"
    },
    {
      "name": "Some number field",
      "type": "Number",
      "value": 9087.54
    }
  ]
}
Czy artykuł był pomocny?
0 na 5 gwiazdek
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
How Can We Improve This Article?