我使用基于Acumatica的合约API从ASP.net应用程序创建销售订单。我需要更新"运输条款" "运输设置下的字段"在我创建销售订单时选项卡(见下文),但我找不到要在通过基于合同的API提供的ASP.net对象上使用的属性。我该如何做到这一点?
以下是我目前创建销售订单的代码:
using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
{
//Sales order data
string customerID = "CUST1234;
string orderDescription = "Automated Order";
string customerOrder = "TEST";
var orderDetails = new List<SalesOrderDetail>();
foreach(var lineItem in order.line_items)
{
orderDetails.Add(new SalesOrderDetail {
InventoryID = new StringValue { Value = lineItem.sku },
Quantity = new DecimalValue { Value = lineItem.quantity },
UnitPrice = new DecimalValue { Value = Decimal.Parse(lineItem.price) }, //TODO this should only be done for MHR owned sites
UOM = new StringValue { Value = "EACH" },
});
}
//Specify the values of a new sales order
SalesOrder orderToBeCreated = new SalesOrder
{
OrderType = new StringValue { Value = "SO" },
CustomerID = new StringValue { Value = customerID },
Description = new StringValue { Value = orderDescription },
CustomerOrder = new StringValue { Value = customerOrder },
ExternalReference = new StringValue { Value = order.order_number.ToString() },
Details = orderDetails.ToArray<SalesOrderDetail>(),
ShippingAddressOverride = new BooleanValue { Value = true },
ShippingContactOverride = new BooleanValue { Value = true },
ShippingContact = new Contact()
{
DisplayName = new StringValue { Value = order.shipping_address.first_name + " " + order.shipping_address.last_name },
FirstName = new StringValue { Value = order.shipping_address.first_name },
LastName = new StringValue { Value = order.shipping_address.last_name },
Address = new Address()
{
AddressLine1 = new StringValue { Value = order.shipping_address.address_1 },
AddressLine2 = new StringValue { Value = order.shipping_address.address_2 },
City = new StringValue { Value = order.shipping_address.city },
State = new StringValue { Value = order.shipping_address.state },
Country = new StringValue { Value = order.shipping_address.country },
PostalCode = new StringValue { Value = order.shipping_address.postcode }
}
},
};
client.Login(_acumaticaUid, _acumaticaPwd, _acumaticaCompany, null, null);
//Create a sales order with the specified values
try
{
SalesOrder newOrder = (SalesOrder)await client.PutAsync(orderToBeCreated);
client.Logout();
return newOrder;
}
catch (Exception e)
{
//order addition to Acumatica failed, update the order status in Woo Commerce
client.Logout();
Console.WriteLine("Acumatica could not add specified entity: " + e);
return null;
}
}
更新 根据PatrickChen的评论,我在Acumatica&#34; SalesOrderCustom&#34;中创建了一个新的Web服务端点,在那里我使用了所有默认字段,然后添加了&#34; ShippingTerms&#34;列表也是如此。然后我将该Web服务导入到我的.net项目中(由于this问题引起了一些麻烦),并且能够使用该服务获取我想要添加运输条款的销售订单,并尝试更新它。代码执行正常,但在PUT操作完成后,对象不会在Acumatica中更新,而ShippingTerms属性将返回为NULL。我究竟做错了什么?代码如下:
public async Task<SalesOrderCustom> UpdateShippingTerms(string customerOrder, string originStore, string shippingSpeed)
{
var binding = CreateNewBinding(true, 655360000, 655360000);
var address = new EndpointAddress(ConfigurationManager.AppSettings["AcumaticaCustomUrl"]);
var soToBeFound = new SalesOrderCustom()
{
OrderType = new StringSearch { Value = "SO" },
CustomerOrder = new StringSearch { Value = customerOrder }
};
using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
{
client.Login(_acumaticaUid, _acumaticaPwd, _acumaticaCompany, null, null);
try
{
var soToBeUpdated = (SalesOrderCustom) await client.GetAsync(soToBeFound);
soToBeUpdated.ShippingTerms = new StringValue { Value = "USPS 1 CLS" };
var updatedOrder = (SalesOrderCustom)await client.PutAsync(soToBeUpdated);
//ShippingTerms is still NULL on returned object even after updating the object!!! WHY???
client.Logout();
return updatedOrder;
}
catch (Exception e)
{
client.Logout();
Console.WriteLine("Acumatica could not find specified entity: " + e);
return null;
}
}
}
答案 0 :(得分:2)
启动Acumatica 6,可以更新 默认 端点中未包含的任何字段。此功能仅适用于实现第二版系统合同的端点:
以下示例显示如何使用 默认 基于合同的端点更改销售订单的送货条款,方法是使用{ {1}}收集:
CustomFields
在全新的Acumatica上使用扩展的 默认 基于合同的终端更新销售订单送货条款时,我的注意事项也没有发现ERP 6.1实例:
using (var client = new DefaultSoapClient())
{
client.Login("admin", "123", null, null, null);
try
{
var order = new SalesOrder()
{
OrderType = new StringSearch { Value = "SO" },
OrderNbr = new StringSearch { Value = "SO003729" }
};
order = client.Get(order) as SalesOrder;
order.CustomFields = new CustomField[]
{
new CustomStringField
{
fieldName = "ShipTermsID",
viewName = "CurrentDocument",
Value = new StringValue { Value = "FLATRATE2" }
}
};
client.Put(order);
}
finally
{
client.Logout();
}
}
供参考,添加用于更新 SalesOrder 实体中送货条款的扩展 默认 端点的屏幕截图:
答案 1 :(得分:-1)
我在创建新的6.0端点时能够添加送货条款。 Acumatica附带的默认端点不可扩展。