Question

Not able to add the PXSelector correctly

  • 4 October 2023
  • 3 replies
  • 62 views

Userlevel 2
Badge

I am trying to populate the dynamic material no based on this above report condition.

 

#region TransactionDate
[PXDate()]
[PXUIField(DisplayName = "Transaction Date")]
[PXUnboundDefault(typeof(Today))]
public virtual DateTime? TransactionDate { get; set; }
public abstract class transactionDate :
PX.Data.BQL.BqlDateTime.Field<transactionDate>
{ }
#endregion

#region Status
[PXString(1, IsFixed = true)]
[PXUIField(DisplayName = "Status")]
[PXDefault("H")]
[PXStringList(
new string[]
{
DocStatus.Hold,
DocStatus.Balanced
},
new string[]
{
"On Hold",
"Balanced"
})]
public virtual string Status { get; set; }
public abstract class status :
PX.Data.BQL.BqlString.Field<status>
{ }
#endregion

#region MaterialNo
[PXString]
[PXUIField(DisplayName = "Material Number")]
[PXSelector(typeof(Search<AMBatch.batNbr,
Where<AMBatch.docType, Equal<materialType>,
And<Where<AMBatch.status, Equal<Current<status>>,
Or<Current<status>, IsNull, And<Where<AMBatch.tranDate, Equal<Current<transactionDate>>, Or<Current<transactionDate>, IsNull>>>>>>>>),
typeof(AMBatch.batNbr))]

public virtual string MaterialNo { get; set; }
public abstract class materialNo :
PX.Data.BQL.BqlString.Field<materialNo>
{ }
#endregion

public const string MaterialType = "M";
public class materialType : PX.Data.BQL.BqlString.Constant<materialType>
{
public materialType() : base(MaterialType) { }
}

I have created the DAC but it seems when the values are empty all materials are not listed in the selector. Can anyone see what I am doing wrong over here.

Thanks


3 replies

Userlevel 6
Badge +3

Hi @param2022,

Can you try this selector?

[PXSelector(typeof(SelectFrom<AMBatch>
.Where<AMBatch.docType.IsEqual<materialType>
.And<Brackets<AMBatch.status.IsEqual<status.FromCurrent>.Or<status.FromCurrent.IsNull>>> .And<Brackets<AMBatch.tranDate.IsEqual<transactionDate.FromCurrent>.Or<transactionDate.FromCurrent.IsNull>>>>
.SearchFor<AMBatch.batNbr>))]

 

Userlevel 2
Badge

@Zoltan Febert Thanks for reply but this is also not working.
In this case I set the OnHold status. It should list all the OnHold materials but it shows me empty list
 


I don’t understand why this thing works in GI and Report and not in actual code. Strange !!!

Let me know if you see any way here to solve this.

Thanks​​​​​​​

Userlevel 7
Badge +5

I’d try a couple of things. The first would be a SQL trace to see what is being sent to SQL.

The other would be to remove the conditions on the PXSelector to make sure it can see the batch number. Then add the conditions, one by one, to see what’s breaking it.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved