使用Acumatica API导出业务帐户属性

时间:2015-04-11 22:33:53

标签: acumatica

我们在Acumatica的商业帐户为我们的主要商业帐户类别提供了13个自定义属性。我已经能够成功地将值保存到属性,基于Acumatica的示例“将记录添加到业务帐户和机会表单”。但是我无法弄清楚如何使用Export来检索值。

首先,我尝试使用类似于保存时指定字段的格式。

 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

我认为这会返回一个带有名为“AWD Number”的属性值的结果。相反,它返回了13个结果,每个属性一个,每个属性的值为空。我将FieldName更改为customer.Attributes.Attribute.FieldName,然后它开始返回每个属性的名称。所以我想如果我为该值添加了另一个字段,那么我可能会在单独的结果中得到名称和值,如下所示:

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

我确实为13个结果中的每个结果返回了一个2项目数组,但第二个字段中的值仍为空白。

有谁知道我如何获得价值观?如果我不得不一次拿到一个,我真的不在乎,但我更愿意用他们的名字或代码一次性地获取它们,这样我就不必依赖指数始终保持不变。下面是在我的第二个示例上运行的调试器的图像以及Acumatica中的视图。谢谢!

Debugger for 2nd example

Attributes in Acumatica

1 个答案:

答案 0 :(得分:1)

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

属性字段名称将使用与How To Retrieve An Attribute Field In StockItems In Acumatica API?中使用的相同的命名约定。命名约定是_Attributes。属性ID是属性名称;我没有看到您的配置,但我怀疑您的属性ID是" AWD Number"。总而言之,代码如下:

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

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