【问题标题】:How to create attributes on a Service Order through Web Services如何通过 Web 服务在服务订单上创建属性
【发布时间】:2019-11-24 11:15:22
【问题描述】:

我必须为服务订单创建自己的 Web 服务端点。这是 WSDL:https://imagineersllc.acumatica.com/(W(7))/entity/PileraAPI/19.100.0122?wsdl&company=Imagineers%20LLC%20-%20Prototype 我按照我在默认端点的 Stock Items 下找到的示例添加了属性。

我向服务订单类型添加了属性,当我尝试在我的 API 中填充属性时,它们保持空白。服务订单创建得很好,只是没有填充属性。

我尝试重命名属性并使用代码与代码中的描述。

string sServiceOrderType = "MRO";           // Only type supported
string sCustomer = "1003";
string sBranchLocation = "PROPMGMT";        // Only location available
string sWorkflowStage = "ACKNOWLEDGED";
DateTime dDate = DateTime.Parse("7/1/2019");
string sExternalReference = "WO-2345";   
string sDescription = "Service Order from Pilera API";
bool bOverride = true;      // Used to make Contact and Address editable
string sCompanyName = "DSD Business Systems";
string sAttention = "John Wiles";
string sPhone = "(858) 550-5900";
string sEmail = "johnw@dsdinc.com";
string sAddressLine1 = "1225 Rosemarie Way";
string sAddressLine2 = "";
string sCity = "Chesapeake";
string sState = "VA";
string sPostalCode = "23322";
DateTime dPromisedDate = DateTime.Parse("7/21/2019");
string sSeverity = "Low";
string sPriority = "High";
string sComment = "Comment created by API";
bool bHold = true;
string sCategory = "GENERALREPAIR";       
string sCommunity = "Deerfield Condominium Assoc.";
string sContact = "Annamma George";
string sContactPhone = "860-656-6603";
string sContactLocation = "268 Richard Street #1 Newington, CT 06111";

ServiceOrders ServiceOrdersToBeCreated = new ServiceOrders
{
    ServiceOrderType = new StringValue { Value = sServiceOrderType },
    Customer = new StringValue { Value = sCustomer },
    BranchLocation = new StringValue { Value = sBranchLocation },
    WorkflowStage = new StringValue { Value = sWorkflowStage },
    Date = new DateTimeValue { Value = dDate },
    ExternalReference = new StringValue { Value = sExternalReference },
    Description = new StringValue { Value = sDescription },
    Hold = new BooleanValue { Value = bHold },
    PromisedDate = new DateTimeValue { Value = dPromisedDate },
    Severity = new StringValue { Value = sSeverity },
    Priority = new StringValue { Value = sPriority },
    Category = new StringValue { Value = sCategory },
    Override = new BooleanValue { Value = bOverride },
    CompanyName = new StringValue { Value = sCompanyName },
    Attention = new StringValue { Value = sAttention },
    Phone = new StringValue { Value = sPhone },
    Email = new StringValue { Value = sEmail },
    AddressLine1 = new StringValue { Value = sAddressLine1 },
    AddressLine2 = new StringValue { Value = sAddressLine2 },
    City = new StringValue { Value = sCity },
    State = new StringValue { Value = sState },
    PostalCode = new StringValue { Value = sPostalCode },
    Comment = new StringValue { Value = sComment },
    Attributes = new[]
    {
        new AttributeValue
        {
            AttributeID = new StringValue { Value = "Community" },
            Value = new StringValue { Value = sCommunity }
        },
        new AttributeValue
        {
            AttributeID = new StringValue { Value = "Contact" },
            Value = new StringValue { Value = sContact }
        },
        new AttributeValue
        {
            AttributeID = new StringValue { Value = "Phone" },
            Value = new StringValue { Value = sContactPhone }
        },
        new AttributeValue
        {
            AttributeID = new StringValue { Value = "Location" },
            Value = new StringValue { Value = sContactLocation }
        }
    }
};
ServiceOrders newServiceOrder = (ServiceOrders)soapClient.Put(ServiceOrdersToBeCreated);

服务订单是在没有属性的情况下创建的。没有收到错误消息。

【问题讨论】:

    标签: attributes acumatica endpoint


    【解决方案1】:

    这是支持提供的内容:

    try
    {
        ServiceOrders newServiceOrder = (ServiceOrders)client.Put(ServiceOrdersToBeCreated);
    
        List<AttributeValue> attrList = new List<AttributeValue>();
        foreach (AttributeValue attrVal in newServiceOrder.Attributes)
        {
            AttributeValue attr = new AttributeValue();
            attr.ID = attrVal.ID;
            switch(attrVal.AttributeID.Value)
            {
                case "Community":
                    attr.Value = new StringValue { Value = sCommunity };
                    break;
                case "Contact":
                    attr.Value = new StringValue { Value = sContact };
                    break;
                case "Phone":
                    attr.Value = new StringValue { Value = sContactPhone };
                    break;
                case "Location":
                    attr.Value = new StringValue { Value = sContactLocation };
                    break;
    
                default:
                    Console.WriteLine("Attribute Not Found!");
                    break;
            }
            attrList.Add(attr);
        }
        newServiceOrder.Attributes = attrList.ToArray();
    
        newServiceOrder = (ServiceOrders)client.Put(newServiceOrder);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-09
      相关资源
      最近更新 更多