我想在Acumatica中为客户导出所有即将到来的约会。我为Export命令创建了两个过滤器:一个用于客户ID,另一个用于日期范围。适当地应用日期范围过滤器,但忽略客户ID过滤器。即将推出所有客户的所有约会。目前,我正在将自己的客户ID过滤器应用于返回的结果,但我认为,当所有客户都有大量即将到来的约会时,这将非常缓慢。这是我的代码:
Public Function GetUpcomingAppointmentList(ByVal customerID As String) As String()()
Dim appt As SD300200Content = m_context.SD300200GetSchema()
m_context.SD300200Clear()
' THIS FILTER IS IGNORED
Dim customerFilter As Filter = New Filter()
customerFilter.Field = appt.ServiceOrderHeader.CustomerID
customerFilter.Condition = FilterCondition.Equals
customerFilter.Value = customerID
Dim dateFilter As Filter = New Filter()
dateFilter.Field = appt.ScheduledDateAndTime.Date
dateFilter.Condition = FilterCondition.GreaterOrEqual
dateFilter.Value = Date.Today
Dim searchfilters() As Filter = {customerFilter, dateFilter}
Dim searchCommands() As Command = {appt.AppointmentRecords.ServiceCommands.EveryAppointmentNbr, appt.ServiceOrderHeader.CustomerID, appt.AppointmentRecords.Status, appt.AppointmentRecords.AppointmentNbr, appt.AppointmentRecords.ServiceOrderNbr, appt.ScheduledDateAndTime.Date, appt.ScheduledDateAndTime.StartTime, appt.Employees.EmployeeName}
Dim searchResult As String()() = m_context.SD300200Export(searchCommands, searchfilters, 0, False, False)
' SINCE ABOVE CUSTOMER FILTER DOESN'T WORK, HAVE TO FILTER OUT OTHER CUSTOMERS
Dim filteredResults As List(Of String()) = New List(Of String())
Dim i As Integer, apptCustomer As String
For i = 0 To searchResult.Length - 1
apptCustomer = searchResult(i)(0)
If apptCustomer = customerID Then
filteredResults.Add(searchResult(i))
End If
Next
Return filteredResults.ToArray()
End Function
我还认为我可能会应用与Using filter with Customer screen in Acumatica API中提供的解决方案类似的内容。但似乎需要这样一条线:
appt.AppointmentRecords.ServiceOrderNbr.FieldName = appt.AppointmentRecords.ServiceOrderNbr.FieldName + "!" + appt.ServiceOrderHeader.ServiceCommands.FilterCustomerID.FieldName
但appt.ServiceOrderHeader.ServiceCommands根本没有任何“过滤器”属性。有没有其他方法可以按照约会的客户ID进行过滤,或者上面的代码是否有问题?
另一件有趣的事情是,即使Export返回的大量结果与我尝试应用的CustomerID过滤器不匹配,它返回的额外结果也不会提供实际的CustomerID号。而是将与过滤器不匹配的记录的appt.ServiceOrderHeader.CustomerID作为空字符串返回。
答案 0 :(得分:0)
这可能不是完整的答案,但这是我所学到的:
正如你所链接的答案中暗示的那样,过滤器更喜欢屏幕上的基础对象。组合过滤器时,请密切注意您引用的字段的ObjectName。 "和"条件似乎只在ObjectName相同时才起作用!
这是一个与我为CR.30.20.00提供便利的代码特别相关的示例,该代码尝试按联系人类型(员工,联系人等)和上次修改日期进行过滤。这两个字段都可以在" Contact" ObjectName,但是如果对其中一个对象名使用ContactCurrent,则忽略AND,并根据一个过滤器获取所有记录。
filters.Add(new AcumaticaWS.Filter
{
Field = CR302000Schema.ContactSummary.Type,
Condition = FilterCondition.Equals,
Value = "Employee"
});
filters.Add(new AcumaticaWS.Filter
{
//Field = WSTools.NewA4Field(CR302000Schema.DetailsSummary.CompanyName.ObjectName, "LastModifiedDateTime"), // different object name
Field = WSTools.NewA4Field(CR302000Schema.ContactSummary.Type.ObjectName, "LastModifiedDateTime"), // works!
Condition = FilterCondition.GreaterOrEqual,
Value = "2015-04-01"
});
我没有使用您的屏幕,但如果appt.ScheduledDateAndTime.ObjectName
上也有CustomerID字段,那么您可能正在营业。另请注意,即使字段不在强类型模式中,有时也可以使用该字段 - 就像我的LastModifiedDateTime示例一样。
祝你好运!