send just 1 call with rest api - acumatica

To perform my production, I must to put just one call with the REST API.
I have this error :
"Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 3.
https://XXXXXXXXXXXX/entity/XXX/20.200.001/StockItem?
[ {
"Description": {"value": "DESCRIPTION ITEM1"},
"InventoryID": {"value": "CODE1"},
"ItemStatus": {"value": "Active"},
"ItemType": {"value": "Finished Good"},
"ItemClass": {"value": "NIV2"},
"BaseUOM": {"value": "UNIT"}
},
{
"Description": {"value": "DESCRIPTION ITEM1"},
"InventoryID": {"value": "CODE1"},
"ItemStatus": {"value": "Active"},
"ItemType": {"value": "Finished Good"},
"ItemClass": {"value": "NIV2"},
"BaseUOM": {"value": "UNIT"}
}]

Related

How to findOneAndUpdate MongoDB object inside array from multiple arrays inside object

I am new to mongodD. Although i have wrote correct logic to push object inside cardsData bankCardsArray, but i am not able to make logic to edit a card.
**I have following Data in MongoDB, **
UserData = {
"_id": "63b43ab32fc8d3c100cafecc",
"name": "Praveen Lohar",
"email": "pr********#gmail.com",
"password": "$2b$12$3nwifHakrBu94BwLXAC4Nu16Kw0.xyW8vAIPTMSgY7cYttVklDIZq",
"loginIdsArray": [
{
"title": "Airtel App",
"logoIndex": 3,
"category": "Finance",
"app": "Airtel Thanks",
"username": "p******#gmail.com ",
"password": "xxxxxxx",
"isFavourite": false,
"_id":"63b440ee738a50fc333df3ca"
}
],
"cardsData": {
"bankCardsArray": [
{
"title": "SBI CC",
"logoIndex": 72,
"category": "Bank",
"cardHolder": "Prsscscs",
"cardNumber": "524xxxxxxxx20xx",
"expiry": "23/54",
"cvv": "00",
"isFavourite": false,
"_id": "63b974adb9acaa24a4ebec8b"
},
{
"title": "AXIS CC",
"logoIndex": 85,
"category": "Bank",
"cardHolder": "blsllslss",
"cardNumber": "524xxxxxxxx20xx",
"expiry": "23/54",
"cvv": "00",
"isFavourite": false,
"_id": "63b974adb9acaa24a4ebe5f"
}
],
"identityCardsArray": [
{
"title": "Aadhar Card",
"logoIndex": 98,
"category": "Identity",
"cardHolder": "Name_1",
"cardNumber": "54*******455454",
"issueDate": "2012",
"dob": "23/05",
"isFavourite": false,
"_id":"63b974e6bd0d03c116955f67"
}
],
"licenseCardsArray": [
{
"title": "Two Wheeler License",
"logoIndex": 0,
"category": "License",
"cardHolder": "Klaus Michealson",
"licenseNumber": "RJ/22/ADL-542/474/01",
"expiry": "2036",
"dob": "13/06",
"isFavourite": false,
"_id":"63b97535bd0d03c116955f69"
}
]
}
}
I want to find the user with _id
Then for that user i want to got to cardsData object
Then in cardsData object i want to got to bankCardsArray
Then in bankCardsArray , i want to update fields of a card with particular id
Const res = findOneAndUpdate(
{ 'cardsData.bankCardsArray._id':card_id },
{ $set{ 'cardsData.bankCardsArray.$.title': req.body.title });
Use "." operator to access nested fields.
Refer these mongodb documentation
query-array-of-documents
query-embedded-documents.
Hope this helps.

Nodejs Customized JSON from lucid response

I have the following result set from the database, The result is an array of objects but I want it to look alike a nested objects as shown in the example.
[
{
"id": 4,
"entity": "dashboard",
"key": "message",
"value": "How to watch Netflix with XXX on Android?",
"locale": "en",
"created_at": "2022-10-25T14:41:38.000+05:00",
"updated_at": "2022-10-25T14:41:38.000+05:00"
},
{
"id": 9,
"entity": "in_survey",
"key": "content",
"value": "",
"locale": "en",
"created_at": "2022-10-25T14:41:38.000+05:00",
"updated_at": "2022-10-25T14:41:38.000+05:00"
}
]
Need a response like this from the above JSON
{
"dashboard": {
"message": "How to watch XYZ on Android?",
},
"in_survey": {
"content": ""
}
}

Sales Invoice REST API error The system failed to commit the CurrentDocument row

I am trying to create a Cash Sale in the SalesInvoice rest api endpoint "entity/Default/18.200.001/SalesInvoiceā€¯ and it is giving out the error "The system failed to commit the CurrentDocument row."
I tried removing/adding fields but it doesn't seem to work.
Can anyone help see what is missing?
I basically did a GET call to get an existing record and basically trying to create the same Cash Sale with another RefNumber.
This is the JSON I am sending
{
"rowNumber": 1,
"Amount": {"value": 20.0000},
"Balance": {"value": 0.0000},
"CashDiscount": {"value": 0.0000},
"CreditHold": {"value": false},
"Currency": {"value": "USD"},
"CustomerID": {"value": "ABB001"},
"CustomerOrder": {},
"Date": {"value": "2022-07-14T00:00:00+00:00"},
"Details":
[
{
"rowNumber": 1,
"Amount": {"value": 20.0000},
"BranchID": {"value": "QI"},
"Description": {"value": "Income : Sales"},
"DiscountAmount": {"value": 0.0000},
"DiscountPercent": {"value": 0.000000},
"InventoryID": {"value": "115"},
"LineNbr": {"value": 1},
"Location": {"value": "XX"},
"ManualDiscount": {"value": false},
"Qty": {"value": 1.000000},
"TaxCategory": {"value": "TAXABLE"},
"TransactionDescr": {"value": "BOSC001 test"},
"UnitPrice": {"value": 20.000000},
"UOM": {"value": "EACH"},
"WarehouseID": {"value": "01"}
}
],
"DueDate": {"value": "2022-10-12T00:00:00+00:00"},
"FinancialDetails": {
"rowNumber": 1,
"BatchNbr": {"value": ""},
"Branch": {"value": "QI"},
"CustomerTaxZone": {"value": ""}
},
"Hold": {"value": true},
"Project": {"value": "X"},
"ReferenceNbr": {"value": "POS15841581"},
"Type": {"value": "Cash Sale"},
"VATExemptTotal": {"value": 0.0000},
"VATTaxableTotal": {"value": 0.0000}
}
There is no need for the RowCount element, neither at the document level not the details array. Also I would use the enumerator CSL as the Type, instead of spelling out. Below is a simple example to create a cash sales in the SO invoice screen.
{
"Type": {
"value": "CSL"
},
"ReferenceNbr": {
"value": "AR009548"
},
"Date": {
"value": "12/18/2020 2:21:10 PM"
},
"note": " ",
"CustomerID": {
"value": "AACUSTOMER"
},
"Description": {
"value": "Testing 123"
},
"Details": [
{
"InventoryID": {
"value": "AACOMPUT01"
},
"OrderQty": {
"value": 2
},
"UnitPrice": {
"value": 35.07
}
},
{
"InventoryID": {
"value": "AALEGO500"
},
"OrderQty": {
"value": 2
},
"UnitPrice": {
"value": 436.98
}
},
{
"InventoryID": {
"value": "AAPOWERAID"
},
"OrderQty": {
"value": 8
},
"UnitPrice": {
"value": 5.43
}
}
]
}

How to vertically align Vega-Lite stacked bar chart data labels

How can I align data labels in a stacked bar chart to be centered vertically within each bar segment? In the following example, you can see that the text is positioned at the top of each bar segment. Where a bar segment is thin, the data label overlaps the one below. I realize that having multiple adjacent thin segments would result in overlap even if labels were centered vertically, but that case is unlikely with my data set.
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"data": {
"values": [
{"Value": 0.321, "Date": "09/30/2021", "Measure": "Measure 4"},
{"Value": 0.031, "Date": "09/30/2021", "Measure": "Measure 3"},
{"Value": 0.123, "Date": "09/30/2021", "Measure": "Measure 2"},
{"Value": 0.475, "Date": "09/30/2021", "Measure": "Measure 1"}
]
},
"width": 500,
"height": 250,
"resolve": {"scale": {"color": "independent"}},
"layer": [
{
"mark": "bar",
"encoding": {
"y": {
"field": "Value",
"type": "quantitative",
"axis": {"format": ".1%"}
},
"x": {"field": "Date", "type": "nominal", "axis": {"labelAngle": -45}},
"color": {"field": "Measure", "type": "nominal"}
}
},
{
"mark": {"type": "text"},
"encoding": {
"y": {"field": "Value", "type": "quantitative", "stack": "zero"},
"x": {"field": "Date", "type": "nominal"},
"color": {
"field": "Measure",
"type": "nominal",
"scale": {"range": ["white"]},
"legend": null
},
"text": {
"aggregate": "sum",
"field": "Value",
"type": "quantitative",
"format": ".1%"
}
}
}
]
}
You can do this using a stack and calculate transform. The text layer would look like this:
{
...
"transform": [
{"stack": "Value", "groupby": ["Date"], "as": ["lower", "upper"]},
{"calculate": "(datum.lower + datum.upper) / 2", "as": "midpoint"}
],
"encoding": {
"y": {"field": "midpoint", "type": "quantitative"},
...
}
}
You can see the full spec in the vega editor:

How to flatten JSON with nested structure before passing to #csv filter

I am trying to parse some JSON that is the output of an AWS CLI command to display Snapshots. I want to load this data up into a spreadsheet to be able to filter, group, and audit it.
I've been stumped on how to get the nested Tags array flattened into the parent objects such that the intermediate can then be passed to the #csv filter.
Here is the example:
Initial input JSON:
{
"Snapshots": [
{
"SnapshotId": "snap-fff",
"StartTime": "2014-04-01T06:00:13.000Z",
"VolumeId": "vol-fff",
"VolumeSize": 50,
"Description": "desc1",
"Tags": [
{
"Value": "/dev/sdf",
"Key": "device"
},
{
"Value": "a name",
"Key": "Name"
},
{
"Value": "Internal",
"Key": "Customer"
},
{
"Value": "Demo",
"Key": "Environment"
},
{
"Value": "Brand 1",
"Key": "Branding"
},
{
"Value": "i-fff",
"Key": "instance_id"
}
]
},
{
"SnapshotId": "snap-ccc",
"StartTime": "2014-07-01T05:59:14.000Z",
"VolumeId": "vol-ccc",
"VolumeSize": 8,
"Description": "B Desc",
"Tags": [
{
"Value": "/dev/sda1",
"Key": "device"
},
{
"Value": "External",
"Key": "Customer"
},
{
"Value": "Production",
"Key": "Environment"
},
{
"Value": "i-ccc",
"Key": "instance_id"
},
{
"Value": "B Brand",
"Key": "Branding"
},
{
"Value": "B Name",
"Key": "Name"
},
{
"Value": "AnotherValue",
"Key": "AnotherKey"
}
]
}
]
}
Desired Intermediate:
[
{
"SnapshotId": "snap-fff",
"StartTime": "2014-04-01T06:00:13.000Z",
"VolumeId": "vol-fff",
"VolumeSize": 50,
"Description": "desc1",
"device": "/dev/sdf",
"Name": "a name",
"Customer": "Internal",
"Environment": "Demo",
"Branding": "Brand 1",
"instance_id": "i-fff",
}
{
"SnapshotId": "snap-ccc",
"StartTime": "2014-07-01T05:59:14.000Z",
"VolumeId": "vol-ccc",
"VolumeSize": 8,
"Description": "B Desc",
"device": "/dev/sda1",
"Customer": "External",
"Environment": "Production",
"instance_id": "i-ccc",
"Branding": "B Brand",
"Name": "B Name",
"AnotherKey": "AnotherValue",
}
]
Final Output:
"SnapshotId","StartTime","VolumeId","VolumeSize","Description","device","Name","Customer","Environment","Branding","instance_id","AnotherKey"
"snap-fff","2014-04-01T06:00:13.000Z","vol-fff",50,"desc1","/dev/sdf","a name","Internal","Demo","Brand 1","i-fff",""
"snap-ccc","2014-07-01T05:59:14.000Z","vol-ccc",8,"B Desc","/dev/sda1","External","Production","i-ccc","B Brand","B Name","AnotherValue"
The following jq filter produces the requested intermediate output:
.Snapshots[] | (. + (.Tags|from_entries)) | del(.Tags)
Explanation: from_entries converts the array of key-value objects to an object with the given key-value pairs. This is added to the target object, and finally the "Tags" key is removed.
If the "target" object has a key that also appears in the "Tags" array, then the above filter will favor the value in the "Tags" array. You may accordingly wish to change the order of the operands of "+", or resolve the conflict in some other way.

Resources