Question

Attach a specific Report to each line of a Sales Order

  • 14 July 2022
  • 6 replies
  • 225 views

Userlevel 3
Badge

Hello,

for one of our customers we created a very customized docket that can be generated using a run report action in a sales order and gets used to find parts etc. in the warehouse.

We now would like to attach this report to the so line files.
Here:


I know i can add a parameter to the Report to filter for a individual line nbr, but we can’t figure how you would go on and generate all pdfs for all line nbrs where the article has a price > 0 and attach these to the individual corresponding so line.

The Report that would be generated would only contain information from line 2 for example and should be attached to line 2, proceed to line 3 where it only contains information from line 3 etc.

Is there a method we can use?
greetings


6 replies

Userlevel 6
Badge +5

Check this discussion: 

 

The new REST API spec has been published in 2022 R2 Preview. I’ll see if this has been added to that API when I get a chance. Otherwise you may need to use SOAP API as discussed in linked discussion.

 

The other option would be to build a webhook and do it that way (full access to C# Acumatica Framework tools).

Userlevel 3
Badge

Hello @rosenjon, did u check if it got added to the API by chance? 
Otherwise the Solution presented in your linked article seems to be quite alright.
Thank you!

Userlevel 6
Badge +5

Hi @jwestermann17 -

I looked in 2022R2 Preview REST endpoints, and I still don’t see it. I still only see a file attachment endpoint for the parent SalesOrder object.

I’ve never tried this before..but let’s see what happens 🙄

@Debbie Baldwin @hkabiri @mvolshteyn @vkumar ​@Dana Moffat  

Can we please have a SalesOrderDetail file attachment option for the REST API? This has been talked about in various places for a while: Attach Files with Rest API - Acumatica Developers Blog . .

It is frequently the case that customers want files that are related to the items that they ordered, and it makes more sense to build workflows around the items themselves, rather than attaching files in bulk to the sales order header. You could do things like auto-attach files to the order based on the items in the order. So if you add an item, the new file is attached. If you delete an item, the file is removed.

I will also note that it would be helpful to do this at the SalesOrderDetailAllocation level as well, since often serialized or lot tracked inventory has documents tied to that serial number or lot.

 

Thanks,

Jonathan

    "/SalesOrder/{ids}/files/{filename}": {
"put": {
"tags": [
"SalesOrder"
],
"summary": "Attaches a file to a record.",
"operationId": "SalesOrder_PutFile",
"consumes": [],
"produces": [
"application/json",
"text/json"
],
"parameters": [
{
"name": "ids",
"in": "path",
"description": "The values of the key fields of the record.",
"required": true,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "pipes"
},
{
"name": "filename",
"in": "path",
"description": "The name of the file that you are going to attach with the extension.",
"required": true,
"type": "string"
}
],
"responses": {
"204": {
"description": "The file is successfully attached.",
"headers": {
"Location": {
"description": "A URL that can be used to retrieve the file from the system.",
"type": "string",
"format": "uri"
}
}
},
"401": {
"description": "The user is not logged in to the system.",
"schema": {
"$ref": "#/definitions/HttpError"
}
},
"500": {
"description": "Internal server error.",
"schema": {
"$ref": "#/definitions/HttpError"
}
}
}
}
},

 

Userlevel 7
Badge +2

@jwestermann17 could you please send me(Debbie Baldwin)  and Dana Moffat an email so that we can get you the proper help? 

 

Thanks so much!

 

Userlevel 6
Badge +5

@jwestermann17 I was reading the release notes for 2022 R2 Preview 2, and there does appear to be some hope yet for your request. Apparently the API now has a general functionality to attach files to any top level entity via a common type of REST API call. I have pasted the relevant text below. I am going to try this myself, as I am also interested in this functionality. I’ll let you know what I find. It doesn’t seem to be documented yet in the swagger file for the REST api. I believe SalesOrderDetail (Sales Order Line) counts as a top level entity, so in theory tihs should work.

 

New Common Fields in REST Responses Now every REST response body with payload has additional fields as follows:

• For every returned record that corresponds to a top-level entity, there is a _links/top field in the response. The value of this field is part of the URL of a GET request for the retrieval of this top-level entity by its ID. The same URL can be used in a DELETE request for the deletion of this entity.

For every returned record, there is a _links/files:put field in the response. The value of this field is part of the URL template that must be used in a request for attaching a file to this record. Following is an example of the new fields in a response that returns a Bill entity. "_links": { "self": "/SalesDemo/entity/Default/20.200.001/Bill/2b7001ab-7b00- ed11-9e53-9828a61840c3", "files:put": "/SalesDemo/entity/Default/20.200.001/files/PX.Objects.AP.APInvoiceEntry/ Document/2b7001ab-7b00-ed11-9e53-9828a61840c3/{filename}"

Userlevel 6
Badge +5

Weird...I had a whole post written with screenshots and everything, but the forum was throwing an error when I tried to post it. Anyway, I tested this and it works. If you make a get request for the SalesOrderDetail lines of a specific Sales Order, in the response will be a piece of json like below that gives you an endpoint. If you then post using binary encoding with a file (you can do this in Postman by choosing binary option), then the file is attached to the Sales Order Line successfully. Super cool! This isn’t out yet, but will be released with 2022 R2.

"files:put": "/xxx/entity/Default/22.200.001/files/PX.Objects.SO.SOOrderEntry/Transactions/fcc7db25-3d11-ed11-8397-0afb889f9d51/{filename}"

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved