How to Configure Request Body JSON of an Action Compatible with Line Item(s)

Status
Not open for further replies.
Line items in terms of accounting are subsets of individual items/products. For example, “quantity, unit price, amount” are line items of "Invoice".

If your app supports Line Item(s) like JSON structure which consists of an array of JSON objects as shown in below example:

JSON:
{
"Invoice": {
  "TxnDate": "2014-09-19",
  "PrintStatus": "NeedToPrint",
  "TotalAmt": 362.07,
  "Line": [
   {
    "Description": "Rock Fountain",
    "DetailType": "SalesItemLineDetail",
    "SalesItemLineDetail": {
     "TaxCodeRef": {
      "value": "TAX"
     },
     "Qty": 1,
     "UnitPrice": 275,
     "ItemRef": {
      "name": "Rock Fountain",
      "value": "5"
     }
    },
    "LineNum": 1,
    "Amount": 275,
    "Id": "1"
   },
   {
    "Description": "Fountain Pump",
    "DetailType": "SalesItemLineDetail",
    "SalesItemLineDetail": {
     "TaxCodeRef": {
      "value": "TAX"
     },
     "Qty": 1,
     "UnitPrice": 12.75,
     "ItemRef": {
      "name": "Pump",
      "value": "11"
     }
    },
    "LineNum": 2,
    "Amount": 12.75,
    "Id": "2"
   },
   {
    "Description": "Concrete for fountain installation",
    "DetailType": "SalesItemLineDetail",
    "SalesItemLineDetail": {
     "TaxCodeRef": {
      "value": "TAX"
     },
     "Qty": 5,
     "UnitPrice": 9.5,
     "ItemRef": {
      "name": "Concrete",
      "value": "3"
     }
    },
    "LineNum": 3,
    "Amount": 47.5,
    "Id": "3"
   },
   {
    "DetailType": "SubTotalLineDetail",
    "Amount": 335.25,
    "SubTotalLineDetail": {}
   }
  ],
  "DueDate": "2014-10-19",
  "DocNumber": "1037",
  "CustomerMemo": {
   "value": "Thank you for your business and have a great day!"
  },
  "Balance": 362.07,
  "BillEmail": {
   "Address": "[email protected]"
  },
  "ShipAddr": {
   "City": "Middlefield",
   "Line1": "5647 Cypress Hill Ave.",
   "PostalCode": "94303",
   "Lat": "37.4238562",
   "Long": "-122.1141681",
   "CountrySubDivisionCode": "CA",
   "Id": "25"
  },
  "BillAddr": {
   "Line4": "Middlefield, CA  94303",
   "Line3": "5647 Cypress Hill Ave.",
   "Line2": "Sonnenschein Family Store",
   "Line1": "Russ Sonnenschein",
   "Long": "-122.1141681",
   "Lat": "37.4238562",
   "Id": "95"
  },
  "Id": "130"
},
"time": "2015-07-24T10:48:27.082-07:00"
}

You can see in the above code, Line is an array of JSON objects. If your action allows this type of JSON structure then, you can set up Line Item compatible action of your app in Pabbly Connect.

All you have to do is, just declare the JSON Key that holds such dynamic data as in the above example "Line[{....}]" is the one.

1635764698578.png

Define one object of "line":[{....}] array in the Body Request (Raw JSON) with variables as shown below:

1635769637321.png

While defining the variables in the request body field on the action step, there is some syntax that helps Pabbly Connect to typecast the dynamic value of JSON as explained below:

For Numeric Value:
Use numeric# prefix in the variable as explained in the following example:

JSON:
{
    "tax": "numeric#{{tax_amount}}",
}

For Repeating Dropdown Values in all objects of Line Item array:
Use repeat# prefix in the variable as explained in the following example:

JSON:
{
   "item_name": "repeat#numeric#{{item_name}}",
   "amount": "repeat#{{amount}}"
}

Once you configure the action with Line Item support, users will be able to enter or map comma-separated values for the line item fields as explained in this tutorial: https://forum.pabbly.com/threads/how-to-use-line-itemizer.1624/
 
Status
Not open for further replies.
Top