-->

将文件添加到Salesorder线项目(Add Files to Salesorder line i

2019-09-30 02:45发布

我想补充文件salesorder使用Web服务在Acumatica线项目。 什么端点应该使用?

我想补充的图像,如上面的截图中,使用Web服务端点。

Answer 1:

REST API需要引用细节线在体内。 由于体用于传递附件REST API的二进制数据不能用于将文件附加到细节线。

下面是创建一个新的主/从文档和附加图像的细节线基于屏幕API代码段。 如果您选择使用基于屏幕的API,你将需要调整销售订单ASMX屏幕的片断,并获取销售订单展开的详情SOLine。 附加文件的模式将是相同的:

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


文章来源: Add Files to Salesorder line item
标签: acumatica