将文件添加到Salesorder订单项 [英] Add Files to Salesorder line item

查看:56
本文介绍了将文件添加到Salesorder订单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Web服务将文件添加到Acumatica中的salesorder订单项中。
应该使用哪个端点?

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

我想使用Web服务端点添加如上图所示的图像。

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

推荐答案

REST API需要引用主体中的详细信息行。由于主体用于传递附件的二进制数据,因此REST API不能用于将文件附加到明细行。

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.

下面是基于屏幕的API片段,可创建新的主文档/详细文档并将图像附加到详细信息行。如果您选择使用基于屏幕的API,则需要调整销售订单ASMX屏幕的代码段,并使用扩展的详细信息SOLine获取销售订单。附加文件的模式是相同的:

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();

这篇关于将文件添加到Salesorder订单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆