Unable to Create Payment for order using Rest API - acumatica

While trying to Create the Payment at Payments and application screen,facing the below issue
"exceptionMessage": "PX.Data.PXRowPersistingException: Error: 'OrigDocAmt' cannot be empty.\r\n at PX.Data.PXDefaultAttribute.RowPersisting(PXCache sender, PXRowPersistingEventArgs e)\r\n at PX.Data.PXCache.OnRowPersisting(Object item, PXDBOperation operation)\r\n at PX.Data.PXCache1.PersistInserted(Object row, Boolean bypassInterceptor)\r\n at PX.Data.PXCache1.Persist(PXDBOperation operation)\r\n at PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation operation)\r\n at PX.Data.PXGraph.Persist()\r\n at PX.Objects.AR.ARPaymentEntry.Persist() in C:\Bld\AC-FULL2018R24-JOB1\sources\WebSites\Pure\PX.Objects\AR\ARPaymentEntry.cs:line 2458\r\n at PX.Data.PXSave1.<Handler>d__2.MoveNext()\r\n at PX.Data.PXAction1.d__32.MoveNext()\r\n at PX.Data.PXAction`1.d__32.MoveNext()\r\n at PX.Api.SyImportProcessor.SyStep.a(Object A_0, PXFilterRow[] A_1, PXFilterRow[] A_2)\r\n at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()\nPayment.CashAccount: 'Cash Account' cannot be empty.\nPayment.CustomerID: Error: 'Customer' cannot be empty.\nPayment.PaymentMethod: 'Payment Method' cannot be empty.",
{
"Type" : { "Value":"Payment" },
"CustomerID" : { "Value":"10101010"},
"PaymentMethod" : { "Value":"CHECK"},
"PaymentRef" : { "Value": "123456789" },
"PaymentAmount" : { "Value": "250" },
"Branch" : {"Value":"PRODWHOLE"} --->Financial setting tab
}

the thing is REST API is case sensitive, so you need to use lowercase "value" keyword:
{
"Type" : { "value":"Payment" },
"CustomerID" : { "value":"ABARTENDE"},
"PaymentMethod" : { "value":"CHECK"},
"PaymentRef" : { "value": "123456789" },
"PaymentAmount" : { "value": "250" },
"Branch" : {"value":"PRODWHOLE"}
}
By the way, please note that starting from 2019r1 version of Acumatica ERP, you can send Sales Order with Payments in a single call:
Put: {{sitename}}/entity/Default/18.200.001/SalesOrder?$select=OrderNbr,CashAccount
{
"CashAccount": {
"value": "10200"
},
"CustomerID": {
"value": "ABARTENDE"
},
"Details": [
{
"BranchID": {
"value": "HQ"
},"InventoryID": {
"value": "AAMACHINE"
},
"OrderQty": {
"value": 1
},
"UnitPrice": {
"value": 269.85
},
"WharehouseID": {
"value": "WHOLESALE"
},
"ManualPrice": {
"value": true
}
}
],
"OrderType": {
"value": "SO"
},
"PaymentMethod": {
"value": "CHECK"
},
"ExternalRef": {
"value": "9593"
},
"Payments": [
{
"PaymentRef": {
"value": "SOpay123"
},
"AppliedToOrder": {
"value": 269.85
},
"CashAccount": {
"value": "10300"
},
"PaymentMethod": {
"value": "CHECK"
}
}
]
}

Related

Acumatica: How to override Bill-To Address and Ship-To Address in Sales Order using the REST API

I am doing an integration with Acumatica.
In my SalesOrder request, I am creating a Sales Order with Bill-To Address and Ship-To Address.
After the request was made I have check in acumatica Sales Order that the Sales Order do not have the Bill-To and Ship-To Address as specified in my request.
It seems that it is using the Default Address that was set in the CustomerID
Here is a sample API which shows how to override the Ship-To address. Pay attention to the ShipTo entity declared
{
"OrderNbr": {
"value": "37631"
},
"OrderType": {
"value": "SO"
},
"Date": {
"value": "12/18/20 2:21:10 PM"
},
"note": " ",
"CustomerID": {
"value": "ABC123"
},
"ExternalRef": {
"value": "37631"
},
"Description": {
"value": "Self Import"
},
"CustomerOrder": {
"value": " "
},
"Processed": {
"value": false
},
"ShippingSettings": {
"Priority": {
"value": 2
},
"ShipVia": {
"value": "2ND_DAY"
}
},
"ShipToContactOverride": {
"value": true
},
"ShipToContact": {
"BusinessName": {
"value": "Bob Jones"
},
"Attention": {
"value": ""
},
"Phone1": {
"value": ""
},
"Email": {
"value": ""
}
},
"ShipToAddressOverride": {
"value": true
},
"ShipToAddress": {
"AddressLine1": {
"value": "123 Main Street"
},
"AddressLine2": {
"value": ""
},
"AddressLine3": {
"value": ""
},
"City": {
"value": "Ft. Smith"
},
"State": {
"value": "AR"
},
"PostalCode": {
"value": "72913"
}
},
"Details": [
{
"InventoryID": {
"value": "7239-1"
},
"OrderQty": {
"value": 2
},
"UnitPrice": {
"value": 35.07
}
},
{
"InventoryID": {
"value": "7543"
},
"OrderQty": {
"value": 2
},
"UnitPrice": {
"value": 436.98
}
},
{
"InventoryID": {
"value": "6243-2"
},
"OrderQty": {
"value": 8
},
"UnitPrice": {
"value": 5.43
}
}
]
}

Cannot Add Sales Order with Payment thru REST API

I’m sending a Sales Order with Pre-Authorized Payment thru REST API in Acumatica. This works perfect in my local Acumatica instance. However, I can’t get it worked when switching to Acumatica.com and I’m getting this error “The order cannot be applied, the specified combination of the order type and order number cannot be found in the system.”. It works well when I remove the payment details.
<pre><code>
{
"BillToAddress": {
"AddressLine1": {
"value": "3153 Doctors Drive"
},
"AddressLine2": {
"value": ""
},
"City": {
"value": "Los Angeles"
},
"Country": {
"value": "US"
},
"PostalCode": {
"value": "90017"
},
"State": {
"value": "CA"
},
"custom": {}
},
"BillToAddressOverride": {
"value": false
},
"BillToContact": {
"Attention": {
"value": "Mr."
},
"BusinessName": {
"value": "Gregory Luton"
},
"Email": {
"value": "gluton#hotmeal.com"
},
"Phone1": {
"value": "(310) 341-3975"
},
"custom": {}
},
"CreditHold": {
"value": false
},
"CustomerID": {
"value": "S000000001"
},
"CustomerOrder": {},
"Date": {
"value": "2021-06-02T13:42:02.22Z"
},
"Description": {
"value": ""
},
"Details": [
{
"ManualPrice": {
"value": true
},
"Amount": {
"value": 79.99
},
"DiscountAmount": {
"value": 0
},
"DiscountCode": {},
"DiscountPercent": {
"value": 0
},
"ExtendedPrice": {
"value": 79.99
},
"FreeItem": {
"value": false
},
"InventoryID": {
"value": "ELEHDD1"
},
"LineDescription": {
"value": "Lego 500 piece set"
},
"LineNbr": {
"value": 1
},
"ManualDiscount": {
"value": false
},
"OpenQty": {
"value": 1
},
"OrderQty": {
"value": 1
},
"RequestedOn": {
"value": "2021-06-02T13:42:02.22Z"
},
"Subitem": {
"value": ""
},
"UnbilledAmount": {
"value": 79.99
},
"UnitPrice": {
"value": 79.99
},
"UOM": {
"value": "EA"
},
"WarehouseID": {
"value": "WHOLESALE"
},
"rowNumber": 1,
"custom": {}
}
],
"Hold": {
"value": false
},
"OrderedQty": {
"value": 1
},
"OrderTotal": {
"value": 79.99
},
"OrderType": {
"value": "SO"
},
"Payments": [
{
"CardAccountNbr": {
"value": "CUSTOMPAYMC:S000000001"
},
"CashAccount": {
"value": "10600"
},
"CreditCardTransactionInfo": [
{
"AuthNbr": {
"value": "23456"
},
"NeedValidation": {
"value": false
},
"TranDate": {
"value": "2021-06-02T16:13:01.22Z"
},
"TranNbr": {
"value": "12345"
},
"TranType": {
"value": "Authorize Only"
},
"custom": {}
}
],
"Description": {
"value": "Payment for 006024"
},
"PaymentAmount": {
"value": 79.99
},
"PaymentMethod": {
"value": "CUSTOMPAYMC"
},
"ProcessingCenterID": {
"value": "CUSTOMPAY"
},
"Status": {
"value": "Pre-Authorized"
},
"custom": {}
}
],
"RequestedOn": {
"value": "2021-06-02T13:42:02.22Z"
},
"ShipToAddress": {
"AddressLine1": {},
"AddressLine2": {},
"City": {},
"Country": {},
"PostalCode": {},
"State": {},
"custom": {}
},
"ShipToAddressOverride": {
"value": false
},
"ShipToContact": {
"Attention": {},
"BusinessName": {},
"Email": {},
"Phone1": {},
"custom": {}
},
"ShipVia": {
"value": ""
},
"Status": {},
"TaxTotal": {
"value": 0
},
"Totals": {
"FreightCost": {
"value": 0
},
"DiscountTotal": {
"value": 0
},
"LineTotalAmount": {
"value": 79.99
},
"custom": {}
},
"custom": {
"Document": {
"AttributeAMT": {
"value": "79.99",
"type": "CustomStringField"
},
"AttributeAUTHID": {
"value": "23456",
"type": "CustomStringField"
},
"AttributeCUR": {
"value": "USD",
"type": "CustomStringField"
},
"AttributeDT": {
"value": "6/2/2021 4:13:01 PM",
"type": "CustomStringField"
},
"AttributeEXPDATE": {
"value": "2025-05",
"type": "CustomStringField"
},
"AttributeRC": {
"value": "0",
"type": "CustomStringField"
},
"AttributeTOKEN": {
"value": "Gmg9niiBqh8B8FXH",
"type": "CustomStringField"
},
"AttributeTRANID": {
"value": "12345",
"type": "CustomStringField"
},
"AttributeCID": {
"value": "B",
"type": "CustomStringField"
},
"AttributeSTATUS": {
"value": "Pending",
"type": "CustomStringField"
}
}
}
}
</code></pre>
public async Task Upsert(BusinessModel.Order
order)
{
// Map BusinessModel to DTO
var request = _mapper.Map(order);
//Add Payment record
DataModel.SalesOrderPayment payment = new
DataModel.SalesOrderPayment();
payment.Description = new StringValue { Value =
string.Format("Payment for {0}", order.OrderNumber)};
payment.PaymentMethod = new StringValue { Value =
"CUSTOMPAYMC" };
payment.CardAccountNbr = new StringValue { Value =
string.Concat(order.PaymentDetails.CardID) };
payment.CashAccount = new StringValue { Value = "10600" };
payment.ProcessingCenterID = new StringValue { Value =
"CUSTOMPAY"};
payment.Hold = new BooleanValue { Value = false };
payment.PaymentAmount = new DecimalValue { Value =
order.Header.TotalAmount };
payment.AppliedToOrder = new DecimalValue { Value =
order.Header.TotalAmount };
payment.Custom = new Dictionary>();
payment.Status = new StringValue { Value = "Pre-Authorized"
};
DataModel.SalesOrderCreditCardTransactionDetail detail = new
DataModel.SalesOrderCreditCardTransactionDetail();
detail.AuthNbr = new StringValue { Value =
order.PaymentDetails.AuthorizationNumber };
detail.NeedValidation = new BooleanValue { Value = false };
detail.TranDate = new DateTimeValue { Value =
order.PaymentDetails.AuthorizationDateTime };
detail.TranNbr = new StringValue { Value =
order.PaymentDetails.TransactionID };
detail.TranType = new StringValue { Value = "Authorize Only"
};
detail.Custom = new Dictionary>();
payment.CreditCardTransactionInfo = new
List();
//payment.CreditCardTransactionInfo.Add(detail);
request.Payments = new List();
request.Payments.Add(payment);
// Invoke API
SalesOrder salesOrderResponse = await
api.PutEntityAsync(request, null, null, null, null));
// Map response DTO to BusinessModel
var response = _mapper.Map
(salesOrderResponse);
return Ok(response);
}

Error submitting Sales Order to Acumatica

I'm testing an order submission via Postman, just passing this JSON structure to /SalesOrders.
{
"Details": [
{
"InventoryID": {
"value": "TEST-SKU"
},
"WarehouseID": {
"value": "BUF"
},
"LineNbr": {
"value": 1
},
"OrderQty": {
"value": 2
},
"UnitPrice": {
"value": 285
}
}
],
"CustomerID": {
"value": "0000003759"
},
"Hold": {
"value": false
},
"Description": {
"value": "WEBTEST-1000123456"
},
"ExternalRef": {
"value": "1000123456"
},
"BillToAddressOverride": {
"value": true
},
"ShipToAddressOverride": {
"value": true
},
"Totals": {
"FreightCostIsuptodate": {
"value": true
},
"OverrideFreightPrice": {
"value": true
},
"FreightCost": {
"value": 41.89
},
"Freight": {
"value": 41.89
}
},
"PaymentMethod": {
"value": "APSCRCARD"
},
"NewCard": {
"value": true
},
"PaymentCardIdentifier": {
"value": "APSCRCARD:****-****-****-1234"
},
"PaymentRef": {
"value": "12345678910"
},
"ShipToContact": {
"Attention": {
"value": "Test User"
},
"BusinessName": {
"value": "Testing Company"
}
},
"BillToAddress": {
"AddressLine1": {
"value": "123 Test Lane"
},
"AddressLine2": {
"value": ""
},
"AddressLine3": {
"value": ""
},
"AddressLine4": {
"value": ""
},
"City": {
"value": "Buffalo"
},
"Country": {
"value": "US"
},
"PostalCode": {
"value": "14216"
},
"State": {
"value": "NY"
},
"rowNumber": {
"value": 1
}
},
"ShipToAddress": {
"AddressLine1": {
"value": "123 Test Lane"
},
"AddressLine2": {
"value": ""
},
"AddressLine3": {
"value": ""
},
"AddressLine4": {
"value": ""
},
"City": {
"value": "Buffalo"
},
"Country": {
"value": "US"
},
"PostalCode": {
"value": "14216"
},
"State": {
"value": "NY"
},
"rowNumber": {
"value": 1
}
},
"ShippingSettings": {
"shipVia": {
"value": "BUFFEDEX2DAY"
}
}
}
It's getting hung up when I'm trying to pass over cc information and I'm not exactly sure what to do. It says the Payment Card Identifier field is empty but as you can see I'm passing a value to it.
"SalesOrder.PaymentCardIdentifier: 'Identifier' cannot be empty.\nInserting 'CustomerPaymentMethodC' record raised at least one error. Please review the errors."
I'm not sure if I need to be using a different value but I'm repurposing one that I received on a call to get Sales Orders from Acumatica.
I was curious if I potentially have to add the CustomerPaymentMethod before adding the order? Any help around this would be greatly appreciated.
The Validation message mentions SalesOrder.PaymentCardIdentifier being empty not PaymentCardIdentifier so are you sure you have the correct request format?
Please check the Endpoint to see how this field is being defined in the SalesOrder Entity. That field is not part of the default endpoint - so I can't check it, but perhaps the name is spelled differently.
So it turned out, regarding this, that I was referencing an incorrect endpoint in our system (a custom one as opposed to Default).
I also had to add payment to the Payment sub-object as opposed to the Sales Order object directly.
Thank you everyone for the assistance!

Elasticsearch query including documents it should exclude and vice versa

IMPORTANT EDIT: The logic described below appears to be all correct. The root of my issue was actually being caused by the utility we used to push new data to the ES database, not with the query itself. I have accepted the answer that says that the query works as intended.
I have an Elasticsearch server whose mapping looks like this (as output by curl 'elastic:9200/resourcelibrary/_mapping):
{
"resourcelibrary": {
"mappings": {
"resource": {
"properties": {
"created_at": {
"type": "date"
},
"created_by": {
"type": "text"
},
"custom_key": {
"type": "keyword"
},
"defaultAction": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"default_action": {
"type": "keyword"
},
"description": {
"type": "text"
},
"id": {
"type": "text"
},
"indexed": {
"type": "keyword"
},
"is_searchable": {
"type": "keyword"
},
"key": {
"type": "text"
},
"licenses": {
"type": "keyword"
},
"raw": {
"type": "text"
},
"require_priv": {
"type": "keyword"
},
"source": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"fielddata": true
},
"stat": {
"type": "text"
},
"style_def": {
"type": "keyword"
},
"tags": {
"type": "text"
},
"thumbnail": {
"type": "text"
},
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"type": {
"type": "keyword"
},
"uid": {
"type": "text"
},
"updated_at": {
"type": "date"
},
"updated_by": {
"type": "text"
}
}
}
}
}
}
With the resourcelibrary collection completely empty, I add the following documents to it:
[
{
'type' : 'video',
'uid' : '2c444278-e0d3-497b-9b5b-b70756b0fdc0',
'key' : 'test-test',
'custom_key' : 'test-test',
'description' : 'Random text just to fill up the description. Also, math',
'privileged' : [],
'require_priv' : true,
'title' : 'Title!!!',
'defaultAction': '9dfcdb39-6644-4023-82c3-8227ba184c02',
'source' : 'frontline'
},
{
'type' : 'course',
'uid' : '8afb5c95-c7b5-498a-abec-ae829d164964',
'key' : 'test-scorm',
'custom_key' : 'test-scorm',
'description' : 'SCORM!!!',
'privileged' : [],
'require_priv' : true,
'title' : 'SCORM!!!',
'defaultAction': '1302dead-9941-4b90-b35c-30eff4993365',
'source' : 'scormcloud'
},
{
'type' : 'mc',
'uid' : '8e66c2fa-6090-49da-91dd-d939124fef90',
'key' : 'test-mc',
'custom_key' : 'test-mc',
'description' : 'MC!!!',
'require_priv' : false,
'title' : 'MC!!!',
'defaultAction': '7957b8f5-c934-4296-b7bb-70f2cc4b2ad0',
'source' : 'edivate'
},
{
'type' : 'group',
'uid' : '80a908c3-dd6c-4902-9f05-647a8af689ac',
'key' : 'test-group',
'custom_key' : 'test-group',
'description' : 'GROUP!!!',
'require_priv' : false,
'title' : 'GROUP!!!',
'defaultAction': '25b700a5-7563-4d6e-9eab-18465d08a683',
'source' : 'two words'
},
{
'type' : 'video',
'uid' : '3d555389-e0d3-497b-9b5b-c81867c10ed1',
'key' : 'test-video',
'custom_key' : 'test-video',
'description' : 'Random text just to fill up the description. Also, science',
'require_priv' : false,
'title' : 'NO-PRIVS-REQUIRED RESOURCE!!!',
'defaultAction': '9dfcdb39-6644-4023-82c3-8227ba184c02',
'source' : 'ets'
},
{
'type' : 'video',
'uid' : 'fbc0f853-9020-4ed7-8d4d-e18ebe75d815',
'key' : 'test-test-test',
'custom_key' : 'test-test-test',
'description' : 'integration testing description',
'require_priv' : false,
'title' : 'Search All Resources Integration Title',
'defaultAction': '9dfcdb39-6644-4023-82c3-8227ba184c02'
},
{
'type' : 'file',
'uid' : 'cf84e252-1082-4a94-9fe5-45fa73364e2f',
'key' : 'test-test-test two',
'custom_key' : 'test-test-test two',
'description' : 'integration testing description two',
'require_priv' : false,
'title' : 'Search All Resources Integration Title two',
'defaultAction': '0b7abf9e-c88a-4d19-891d-52fe0b220506'
},
{
'id' : 'ba462b70-de73-4173-88bf-66bc9d1385b9',
'type' : 'course',
'uid' : 'scormcloud-course-cf84e252-1082-4a94-9fe5-45fa73364e2f',
'key' : 'test-test-test two',
'custom_key' : 'test-test-test two',
'description' : 'integration testing description two',
'require_priv' : false,
'title' : 'Search All Resources Integration Title two',
'defaultAction': '0b7abf9e-c88a-4d19-891d-52fe0b220506'
},
{
'id' : '7f0cbbc6-a1dd-43ca-9108-b31f90904dce',
'type' : 'course',
'uid' : 'scormcloud-course-7f0cbbc6-a1dd-43ca-9108-b31f90904dce',
'key' : 'LD_7f0cbbc6-a1dd-43ca-9108-b31f90904dce',
'custom_key' : 'LD_7f0cbbc6-a1dd-43ca-9108-b31f90904dce',
'description' : 'This is a LearningDesigner course',
'require_priv' : false, // Still requires LCR Tooling
'title' : 'LearningDesigner Course 1',
'defaultAction': '1302dead-9941-4b90-b35c-30eff4993365'
},
{
'id' : '9e195a62-1a53-42c0-8648-4aa35c309d48',
'type' : 'course',
'uid' : 'scormcloud-course-9e195a62-1a53-42c0-8648-4aa35c309d48',
'key' : 'user-SCORM_9e195a62-1a53-42c0-8648-4aa35c309d48',
'custom_key' : 'user-SCORM_9e195a62-1a53-42c0-8648-4aa35c309d48',
'description' : 'This is a user-uploaded SCORM course',
'require_priv' : false, // Still requires LCR Tooling
'title' : 'User-Uploaded Course 1',
'defaultAction': '1302dead-9941-4b90-b35c-30eff4993365'
},
{
'id' : '2b1b2197-48ae-4669-8bfa-7edd440cb027',
'type' : 'course',
'uid' : 'course-2b1b2197-48ae-4669-8bfa-7edd440cb027',
'source' : 'canvas',
'key' : '9e195a62-1a53-42c0-8648-4aa35c309d48',
'custom_key' : '9e195a62-1a53-42c0-8648-4aa35c309d48',
'description' : 'This is a Canvas course',
'require_priv' : false,
'title' : 'Canvas Course 1',
'defaultAction': '7aef5ef2-e0c1-4188-9e74-3e24057e7e6e'
},
{
'id' : '5e113295-f905-4a3d-97e0-f5d49926c979',
'type' : 'collaborative',
'uid' : 'frontline-collaborative-5e113295-f905-4a3d-97e0-f5d49926c979',
'key' : '5e113295-f905-4a3d-97e0-f5d49926c979',
'custom_key' : '5e113295-f905-4a3d-97e0-f5d49926c979',
'description' : 'This is a Collaborative resource',
'require_priv' : false,
'title' : 'Collab Resource 1',
'defaultAction': 'e153409d-3330-4202-baf2-d602b4cb7d66'
},
]
I am working with BodyBuilder.JS to produce a query that returns everything EXCEPT for documents that meets any of the following criteria:
type is equal to "collaborative"
source is equal to "canvas"
type is equal to "course" AND custom_key starts with "LD_"
type is equal to "course" AND custom_key starts with "user-SCORM_"
In my application, I implemented these exclusive conditions like so (note: body is an object created with the bodybuilder() function from BodyBuilder.JS):
body.notFilter('term', 'type', 'collaborative');
body.notFilter('term', 'source', 'canvas');
body.notFilter('bool', subFilter => {
subFilter.filter('term', 'type', 'course');
subFilter.filter('regexp', 'custom_key', 'LD_.*');
return subFilter;
});
body.notFilter('bool', subFilter => {
subFilter.filter('term', 'type', 'course');
subFilter.filter('regexp', 'custom_key', 'user-SCORM_.*');
return subFilter;
});
... And when body.build() is called, it produces the following Elasticsearch DSL string:
{
"from": "0",
"size": 100,
"query": {
"bool": {
"filter": {
"bool": {
"must": {
"bool": {}
},
"must_not": [
{
"term": {
"type": "collaborative"
}
},
{
"term": {
"source": "canvas"
}
},
{
"bool": {
"must": [
{
"term": {
"type": "course"
}
},
{
"regexp": {
"custom_key": "LD_.*"
}
}
]
}
},
{
"bool": {
"must": [
{
"term": {
"type": "course"
}
},
{
"regexp": {
"custom_key": "user-SCORM_.*"
}
}
]
}
}
]
}
}
}
}
}
When I send this query to my Elasticsearch server, it correctly omits the documents with type of "collaborative" and source of "canvas". However, it is doing the following incorrect things:
search results are missing the second document (uid value "8afb5c95-c7b5-498a-abec-ae829d164964")
search results are improperly including documents whose type is "course" and whose custom_key starts with "LD_"
search results are improperly including documents whose type is "course" and whose custom_key starts with "user-SCORM_"
I'm genuinely not sure what I'm doing wrong here. I have also tried replacing the regexp subclauses with match subclauses (e.g. subFilter.filter('match', 'custom_key', 'LD_*'),
but I get the exact same results.
I've been staring at this thing for a literal week now, trying hundreds of slightly-different things similar to what is described in this post but this is the closest I've gotten to getting the results I need. What am I doing wrong?
This might help to solve & analyze your problem locally.
I have created the index:
PUT /resourcelibrary
{
"mappings": {
"properties": {
"created_at": {
"type": "date"
},
"created_by": {
"type": "text"
},
"custom_key": {
"type": "keyword"
},
"defaultAction": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"default_action": {
"type": "keyword"
},
"description": {
"type": "text"
},
"id": {
"type": "text"
},
"indexed": {
"type": "keyword"
},
"is_searchable": {
"type": "keyword"
},
"key": {
"type": "text"
},
"licenses": {
"type": "keyword"
},
"raw": {
"type": "text"
},
"require_priv": {
"type": "keyword"
},
"source": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"fielddata": true
},
"stat": {
"type": "text"
},
"style_def": {
"type": "keyword"
},
"tags": {
"type": "text"
},
"thumbnail": {
"type": "text"
},
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"type": {
"type": "keyword"
},
"uid": {
"type": "text"
},
"updated_at": {
"type": "date"
},
"updated_by": {
"type": "text"
}
}
}
}
Data Ingestion:
POST /resourcelibrary/_doc
{
"custom_key": "5e113295-f905-4a3d-97e0-f5d49926c979",
"defaultAction": "e153409d-3330-4202-baf2-d602b4cb7d66",
"description": "This is a Collaborative resource",
"id": "5e113295-f905-4a3d-97e0-f5d49926c979",
"key": "5e113295-f905-4a3d-97e0-f5d49926c979",
"require_priv": false,
"title": "Collab Resource 1",
"type": "collaborative",
"uid": "frontline-collaborative-5e113295-f905-4a3d-97e0-f5d49926c979"
}
Search Query (working fine)
GET /resourcelibrary/_search
{
"query": {
"bool": {
"filter": {
"bool": {
"must": {
"bool": {}
},
"must_not": [
{
"term": {
"type": "collaborative"
}
},
{
"term": {
"source": "canvas"
}
},
{
"bool": {
"must": [
{
"term": {
"type": "course"
}
},
{
"regexp": {
"custom_key": "LD_.*"
}
}
]
}
},
{
"bool": {
"must": [
{
"term": {
"type": "course"
}
},
{
"regexp": {
"custom_key": "user-SCORM_.*"
}
}
]
}
}
]
}
}
}
}
}
Try to create an index with different name & try to execute these queries. This way you can debug into actual issue.
But the Query is being generated properly.

Issues with Acumatica REST Contract-Based API SalesInvoice Entity 18.200.001

Automating creation of Sales Invoice via Rest API
Unable to get CustomerLocation to populate
In the WebService EndPoint the Mapped Object and Mapped Fields are blank for this item
Has any one successfully used this API to modify Location?
Does any one know if I have a formatting error in my JSON for Linked Entities, it matches the documentation but may not be up to date?
Tried several formats of JSON based on the guide and experience including Linked, Summary, Custom and Detail
Tried both BillToSettings and BillingSetting Entities
Searched Known issues, Newton JSon
"Type": { "value": "Invoice" },
"CustomerID": { "value": "C0004055" },
/// bit does not create in Acumatica
"BillToSettings": { "CustomerLocation": { "value": "67217" } },
/// "BillingSettings" : {"CustomerLocation" : {"value" : "67217"}
/// also LocationID, CustomerLocationID and many combinations there of
"CustomerOrder": { "value": 1942 },
"Date": { "value": "2/14/2019" },
"Description": { "value": "SO S048773" },
"Details": [
{
"InventoryID": { "value": "POLLING-HOSTING" },
"TransactionDescr": { "value": "GPRS Monitoring" },
"UOM": { "value": "PNTS" },
"Qty": { "value": "3" },
"UnitPrice": { "value": "68.25" }
},
{
"InventoryID": { "value": "AIRTIME" },
"TransactionDescr": { "value": "GPRS Airtime" },
"UOM": { "value": "EACH" },
"Qty": { "value": "3" },
"UnitPrice": { "value": "20" }
}
]
I expect the Default MAIN location to be overridden with 67217 instead every record shows main
If I add the address Override fields (as below) then I get data for them on the successful creation of the invoice but no CustomerLocation data is returned.
Nor does the LocationID update correctly
BillingSettings = new
{
BillToAddressOverride = new {value = true},
BillToContactOverride = new { value = true },
CustomerLocation = new { value = "67217"}
},
I tried to use your JSON example on a clean SalesDemo install of 2019R1 and could replicate the same issue that you're experiencing.
I think it has to do with the CustomerLocation field not being mapped in the Default 18.200.001 endpoint. It actually makes sense if we look at the response object - there is no CustomerLocation field in the response either.
First Attempt, without extending the API endpoint:
{
"Type": {
"value": "Invoice"
},
"CustomerID": {
"value": "ABARTENDE"
},
"Date": {
"value": "5/10/2019"
},
"Description": {
"value": "Test SalesInvoice Creation"
},
"BillingSettings" : {
"CustomerLocation" : {
"value" : "VEGAS"
}
}
}
Response from the first attempt:
"BillingSettings": {
"BillToAddress": {
"AddressLine1": {
"value": "201 Lower Notch Rd"
},
"AddressLine2": {},
"City": {
"value": "Little Falls"
},
"Country": {
"value": "US"
},
"PostalCode": {
"value": "07424"
},
"State": {
"value": "NJ"
}
},
"BillToAddressOverride": {
"value": false
},
"BillToContact": {
"Attention": {
"value": "Accounts Receivable"
},
"BusinessName": {
"value": "USA Bartending School"
},
"Email": {
"value": "barkeep#usabartend.con"
},
"Phone1": {
"value": "+1 (908) 532-9522"
}
},
"BillToContactOverride": {
"value": false
}
}
If you extend the endpoint and implement the Location field which can be found under the Invoice Summary selection when populating the field, you should be able to achieve your intended outcome. PS. I added the Location on the SalesInvoice object itself, and not on the BillingSettings object:
Second Request, the extended endpoint includes the Location field that was added:
{
"Type": {
"value": "Invoice"
},
"CustomerID": {
"value": "ABARTENDE"
},
"Date": {
"value": "5/10/2019"
},
"Description": {
"value": "Test SalesInvoice Creation"
},
"Location" : {
"value" : "VEGAS"
}
}
Second Response:
{
"Amount": {
"value": 0
},
"Balance": {
"value": 0
},
"BillingSettings": {
"BillToAddressOverride": {
"value": false
},
"BillToContactOverride": {
"value": false
}
},
"Currency": {
"value": "USD"
},
"CustomerID": {
"value": "ABARTENDE"
},
"Date": {
"value": "2019-05-10T00:00:00+00:00"
},
"Description": {
"value": "Test SalesInvoice Creation"
},
"DueDate": {
"value": "2019-06-09T00:00:00+02:00"
},
"Hold": {
"value": false
},
"Location": {
"value": "VEGAS"
},
"ReferenceNbr": {
"value": "AR006994"
},
"Status": {
"value": "Balanced"
},
"Type": {
"value": "Invoice"
}
}
As to whether the CustomerLocation holds any meaningful value/purpose, I'm not sure, so I left it in the BillingSettings as is.

Resources