1

Our Business Accounts in Acumatica have 13 custom Attributes for our main Business Account Class. I've been able to save values to the Attributes successfully, based on Acumatica's example "Adding Records to the Business Accounts and Opportunities Forms". But I have not been able to figure out how to retrieve the values with an Export.

First, I tried using a format similar to how the field was specified when saving them.

 Public Function GetCustomerAttributes(ByVal customerID As String) As String()()
    Dim customer As CR303000Content = m_context.CR303000GetSchema()
    m_context.CR303000Clear()

    Dim idFilter As Filter = New Filter()
    idFilter.Field = customer.AccountSummary.BusinessAccount
    idFilter.Condition = FilterCondition.Equals
    idFilter.Value = customerID

    ' SIMILAR TO EXAMPLE FOR SAVING
    Dim awdField As Field = New Field()
    awdField.ObjectName = customer.Attributes.Attribute.ObjectName
    awdField.FieldName = "AWD Number"

    Dim searchfilters() As Filter = {idFilter}
    Dim searchCommands() As Command = {awdField}
    Dim searchResult As String()() = m_context.CR303000Export(searchCommands, searchfilters, 0, False, False)
    Return searchResult
End Function

I thought this would return one result with the value for our attribute named "AWD Number". Instead, it returned 13 results, one for each attribute, and the value of each one was blank. I changed the FieldName to customer.Attributes.Attribute.FieldName and then it started returning the name of each attribute. So I thought if I added another field for the value, then I might get the name and value in separate results, like this:

Public Function GetCustomerAttributes(ByVal customerID As String) As String()()
    Dim customer As CR303000Content = m_context.CR303000GetSchema()
    m_context.CR303000Clear()

    Dim idFilter As Filter = New Filter()
    idFilter.Field = customer.AccountSummary.BusinessAccount
    idFilter.Condition = FilterCondition.Equals
    idFilter.Value = customerID

    Dim awdField As Field = New Field()
    awdField.ObjectName = customer.Attributes.Attribute.ObjectName
    awdField.FieldName = customer.Attributes.Attribute.FieldName

    Dim awdValue As Field = New Field()
    awdValue.ObjectName = customer.Attributes.Attribute.ObjectName
    awdValue.FieldName = customer.Attributes.Attribute.Value

    Dim searchfilters() As Filter = {idFilter}
    Dim searchCommands() As Command = {awdField, awdValue}
    Dim searchResult As String()() = m_context.CR303000Export(searchCommands, searchfilters, 0, False, False)
    Return searchResult
End Function

I did get a 2-item array back for each of the 13 results, but the value in the second field was still blank.

Does anyone know how I can get the values? I don't really care if I have to get them one at a time, but I'd prefer to get them all at once with their names or codes so that I don't have to rely on the indices always staying the same. Below are images of the debugger running on my second example and view in Acumatica. Thanks!

Debugger for 2nd example

Attributes in Acumatica

4

1 回答 1

1

您的第一次尝试是正确的,但是您没有使用正确的对象名称和字段名称。系统将动态添加字段到屏幕的主要对象(视图),在这种情况下,对象名称表示为customer.AccountSummary.BusinessAccount.ObjectName variable(我建议您使用调试器也可以查看该值等于什么 - 很好的学习练习)。

属性字段名称将使用与如何在 Acumatica API 中的 StockItems 中检索属性字段中使用的相同命名约定?. 命名约定是_Attributes。属性 ID不是属性名称;我没有看到您的配置,但我怀疑在您的情况下属性 ID 是“AWD 编号”。总而言之,代码将如下所示:

Dim awdField As Field = New Field()
awdField.ObjectName = customer.AccountSummary.BusinessAccount.ObjectName
awdField.FieldName = "AWDNumber_Attributes"

在您的示例中,通过放置Attributes.Attribute.ObjectName对象,系统将遍历此表中的所有值,然后为每一行返回您想要的字段。我不确定为什么在这种情况下你没有看到所有的属性值,但我认为你应该对上面的例子没问题。

于 2015-04-12T14:31:51.017 回答