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

使用Acumatica API导出业务帐户属性,acumatica,Acumatica,我们在Acumatica中的业务帐户对于我们的主要业务帐户类有13个自定义属性。基于Acumatica的示例“将记录添加到业务帐户和商机表单”,我已经成功地将值保存到属性中。但我还没有弄清楚如何通过导出检索值 首先,我尝试使用类似于保存字段时指定字段的格式 Public Function GetCustomerAttributes(ByVal customerID As String) As String()() Dim customer As CR303000Content = m_

我们在Acumatica中的业务帐户对于我们的主要业务帐户类有13个自定义属性。基于Acumatica的示例“将记录添加到业务帐户和商机表单”,我已经成功地将值保存到属性中。但我还没有弄清楚如何通过导出检索值

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

 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中的第二个示例和视图上运行的调试器的图像。谢谢


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

属性字段名称将使用与中相同的命名约定。命名约定为_属性。属性ID不是属性名称;我看不到您的配置,但我怀疑在您的情况下,属性ID是“AWD编号”。总而言之,代码如下所示:

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

在您的示例中,通过放置
Attributes.Attribute.ObjectName
对象,系统将迭代该表中的所有值,然后为每一行返回所需的字段。我不太清楚为什么在本例中看不到所有的属性值,但我认为您应该对上面的示例没问题。

谢谢!在我的第一个示例中,我实际上已经尝试过FieldName的这种格式,但绝对没有尝试过ObjectName。我确信它应该引用属性