Add Files to Salesorder line item

倾然丶 夕夏残阳落幕 提交于 2019-12-11 10:24:41

问题


I want to add files to salesorder line items in Acumatica using web services. What endpoint should be used?

I want to add an image as shown in the screenshot above, using web service endpoint.


回答1:


REST API needs to reference the detail line in the body. Since the body is used to pass the binary data of the attachment REST API can't be used to attach files to detail line.

Below is a screen based API snippet that creates a new master/detail document and attach images to the detail line. If you choose to use the screen based API you will need to adapt the snippet for sales order ASMX screen and fetch sales order with expanded details SOLine. The pattern to attach file will be the same:

string[] detailDescription = "Test";
List<string> filenames = "image.jpg";
List<byte[]> images = new byte[] { put_image_binary_data_here } ;

ServiceReference1.Screen context = new ServiceReference1.Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://localhost/Demo/Soap/XYZ.asmx";
context.Login("admin@CompanyLoginName", "admin");

ServiceReference1.XY999999Content content = PX.Soap.Helper.GetSchema<ServiceReference1.XY999999Content>(context);

List<ServiceReference1.Command> cmds = new List<ServiceReference1.Command>
{
    // Insert Master
    new ServiceReference1.Value { Value="<NEW>", LinkedCommand = content.Document.KeyField},
    new ServiceReference1.Value { Value="Description", LinkedCommand = content.Document.Description},

    // Insert Detail
    content.DataView.ServiceCommands.NewRow,
        new ServiceReference1.Value { Value = noteDetail[0], LinkedCommand = content.DataView.Description },

    // Attaching a file to detail
    new ServiceReference1.Value
    {
        Value = Convert.ToBase64String(images[0]),
        FieldName = filenames[0],
        LinkedCommand = content.DataView.ServiceCommands.Attachment
    },
    content.Actions.Save,
    content.Document.KeyField
};

var returnValue = context.PP301001Submit(cmds.ToArray());
context.Logout();


来源:https://stackoverflow.com/questions/55137176/add-files-to-salesorder-line-item

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!