我正尝试首先按帐户名称对客户查找进行排序。 在DAC中,我选择了SO.SOrder,通过选择“替换原始”自定义属性,并添加了以下内容:
[PXDefault]
[CustomerActive(typeof(Search<BAccountR.bAccountID,Where<Customer.type, IsNotNull,
Or<Current<SOOrder.aRDocType>, Equal<ARDocType.noUpdate>,
And<BAccountR.type, Equal<BAccountType.companyType>>>>, OrderBy<Asc<BAccountR.acctName>>>),
Visibility = PXUIVisibility.SelectorVisible, DescriptionField = typeof(Customer.acctName), Filterable = true)]
我添加了OrderBy<Asc<BAccountR.acctName>>
。
成功构建并打开SOOrder屏幕后,出现此错误:
Error: The parameter length exceeds the allowed value.
Parameter name: types
at PX.Data.BqlCommand.Compose(Type[] types)
at PX.Objects.AR.CustomerAttribute..ctor(Type search, Type[] fields)
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean.
Search方法确实具有接受OrderBy的重载。我究竟做错了什么?
感谢您的帮助。
-保罗
答案 0 :(得分:1)
这里有两件事要提到:
您要遇到的第一个问题是选择器,仅按键值排序,这样就无法实现最终目标:
Modify Selector Default Sorting
第二个是错误消息。问题似乎是在CustomerAttribute
上的一个Acumatica错误,当它在销售订单上运行时构建BqlCommand
时。在构造器CustomerAttribute(Type search, params Type[] fields)
中,有一条语句检查searchType == typeof(Search<,,>)
,然后在应使用Search2<Field, Join, Where>
并包括OrderBy的情况下尝试使用Search2<Field, Join, Where, OrderBy>
构建查询。我已经确认,该类的客户版本代替了原来的版本,该错误消失了,但是选择器上的顺序不会更改。结果,修复将无助于您的最终目标。
// ...
else if (searchType == typeof(Search<,,>)) //when Search<Field, Where, OrderBy>
{
cmd = BqlCommand.Compose(
typeof(Search2<,,>), //need Search2<Field, Join, Where, OrderBy>
// however using Search2<Field, Join, Where> and results in an error
typeof(BAccountR.bAccountID),
typeof(LeftJoin<,,>),
typeof(Customer),
typeof(On<Customer.bAccountID, Equal<BAccountR.bAccountID>, And<Match<Customer, Current<AccessInfo.userName>>>>),
typeof(LeftJoin<,,>),
typeof(Contact),
typeof(On<Contact.bAccountID, Equal<BAccountR.bAccountID>, And<Contact.contactID, Equal<BAccountR.defContactID>>>),
typeof(LeftJoin<,,>),
typeof(Address),
typeof(On<Address.bAccountID, Equal<BAccountR.bAccountID>, And<Address.addressID, Equal<BAccountR.defAddressID>>>),
typeof(LeftJoin<,>),
typeof(Location),
typeof(On<Location.bAccountID, Equal<BAccountR.bAccountID>, And<Location.locationID, Equal<BAccountR.defLocationID>>>),
searchArgs[1],
searchArgs[2]);
}
// ...