Skip to main content

Is it possible to populate Sales order numbers in reference nbr lookup when selecting SO in Document type without changing any default logics ? If so, how?

 

Hi @rashmikamudalinayake10,

Can you please provide more context of the requirements? Like, screen, your current implementation and expected behavior.


Hi @Vignesh Ponnusamy ,

Screen - Process Bank Transactions (CA306000)
Used 22.207.0013 version

Req- Populate Sales order numbers in reference nbr lookup when selecting SO in the Document type

Note:

SO is a custom value (Sales Orders)


@rashmikamudalinayake10 you could define your referenceNbr field something like:

 

        #region OrderNbr

PXDBString(15, IsKey = true, IsUnicode = true, InputMask = "")]
PXUIField(DisplayName = "Order Nbr")]
PXSelector(typeof(Search<SOOrder.orderNbr, Where<SOOrder.orderType, Equal<Current<documentType>>>>))]
public virtual string OrderNbr { get; set; }

public abstract class orderNbr : PX.Data.BQL.BqlString.Field<orderNbr>
{
}

#endregion

Good luck


The referenceNbr is a mandatory field.

Is it possible to override by keeping the base method? If so, how?


@rashmikamudalinayake10 as @Vignesh Ponnusamy’s mentioned before, please provide additional details on requirements and context for better understanding of the issue.


I posted on @Vignesh Ponnusamy post. But I got this.

Anyway,

Screen Name: Process Bank Transactions (CA306000)

Acumatica Version: 22.207.0013

Requirement:

On the screen "Process Bank Transactions", when the user selects 'SO' from the "Document Type" dropdown (a custom value that has been added), and then clicks on the "Reference Nbr" lookup, the system should display "SO Order Numbers".

 


@rashmikamudalinayake10,

Thanks for the details.! I’m fairly checking the screen for the 1st time, I don’t see the Document Type field in any of the grid.

Do you have any customization to the screen? If, yes share the package and the steps to reproduce the behavior. Also, share the DAC and field name of that Reference Nbr field you are referring to. Thanks, 


@Vignesh Ponnusamy , 

& no customizations are done except custom dropdown value

Thanks.


Hi @rashmikamudalinayake10,

Thanks for the details.!

I see the values are curated in the PXInvoiceSelector attribute of the AdjdRefNbr field.

PXInvoiceSelectorAttribute is in the BankStatementProtoHelpers.cs. You can find the class file in the following folder of your instance <<Instance URL>>\App_Data\CodeRepository\PX.Objects\CA

Now about fetching the Sales Order,

I don’t think there are other options than rewriting the PXInvoiceSelectorAttribute. Then use it in the DAC definition,

    public class CA_CABankTranAdjustment_ExistingColumn : PXCacheExtension<PX.Objects.CA.CABankTranAdjustment>
{
#region AdjdRefNbr
PXDBString(15, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC")]
PXDefault]
PXUIField(DisplayName = "Reference Nbr.", Visibility = PXUIVisibility.Visible)]
PXInvoiceSelectorCustom(typeof(CABankTran.origModule))] //Use customAttribute like this
public string AdjdRefNbr { get; set; }
#endregion
}

In creating the PXInvoiceSelectorCustomAttribute, you need to mimic GetRecordsAR and GetRecordsAP, then use it in the switch case as necessary.

Feel free to post if you have any additional questions. Looks like this might need some extensive customization and testing, Good Luck.!

 


Hi @rashmikamudalinayake10,

Thanks for the details.!

I see the values are curated in the PXInvoiceSelector attribute of the AdjdRefNbr field.

PXInvoiceSelectorAttribute is in the BankStatementProtoHelpers.cs. You can find the class file in the following folder of your instance <<Instance URL>>\App_Data\CodeRepository\PX.Objects\CA

Now about fetching the Sales Order,

I don’t think there are other options than rewriting the PXInvoiceSelectorAttribute. Then use it in the DAC definition,

    public class CA_CABankTranAdjustment_ExistingColumn : PXCacheExtension<PX.Objects.CA.CABankTranAdjustment>
{
#region AdjdRefNbr
PXDBString(15, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC")]
PXDefault]
PXUIField(DisplayName = "Reference Nbr.", Visibility = PXUIVisibility.Visible)]
PXInvoiceSelectorCustom(typeof(CABankTran.origModule))] //Use customAttribute like this
public string AdjdRefNbr { get; set; }
#endregion
}

In creating the PXInvoiceSelectorCustomAttribute, you need to mimic GetRecordsAR and GetRecordsAP, then use it in the switch case as necessary.

Feel free to post if you have any additional questions. Looks like this might need some extensive customization and testing, Good Luck.!

 

Can you elaborate on this more? I tried to achieve it. but, I'm not sure whether I understood correctly. Seems little bit complex.


Hi @rashmikamudalinayake10,

Rewrite the attribute PXInvoiceSelectorAttribute in the BankStatementProtoHelpers.cs like below,

public class PXInvoiceSelectorCustomAttribute : PXCustomSelectorAttribute

{

 //rewrite the PXInvoiceSelectorAttribute and modify the to select sales order when necessary 

}

 

In the attribute, you can find switch (tranModule), which has case GL.BatchModule.AP and case GL.BatchModule.AR, where records are selected using GetRecordsAP and GetRecordsAR methods. You update/modify these queries to select the Sales order when you select the Document Type Sales Orders. 

 

Then in the DAC declaration, you can use PXInvoiceSelectorCustom like below,

    public class CA_CABankTranAdjustment_ExistingColumn : PXCacheExtension<PX.Objects.CA.CABankTranAdjustment>
{
#region AdjdRefNbr APXDBString(15, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC")]
PXDefault]
PXUIField(DisplayName = "Reference Nbr.", Visibility = PXUIVisibility.Visible)]
PXInvoiceSelectorCustom(typeof(CABankTran.origModule))] //Use above create Attribute
public string AdjdRefNbr { get; set; }
#endregion
}

I agree, it is complex and tricky, you could give it a try. Feel free to post if you have any questions. Good Luck.!


Hi all,

I've tried numerous times but have been unable to find a solution. There seems to be an issue, but I can't pinpoint it. I will attach the code snippet I've been working with and the corresponding error. Could you please identify the error for me? I feel like I'm missing something.
 

using PX.Data;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PX.Objects.SO;
using PX.Objects.CA.BankStatementProtoHelpers;
using PX.Objects.CA;

public class PXInvoiceSelectorCustomAttribute : PXInvoiceSelectorAttribute
{

public PXInvoiceSelectorCustomAttribute(Type BatchModule)
: base(BatchModule)
{
}

protected override IEnumerable GetRecords()
{
foreach (var record in base.GetRecords())
{
yield return record;
}

// New logic for 'SO' document type
string tranModule = this._Graph.Cachess_BatchModule].Current?.ToString();
if (tranModule == "SO")
{
foreach (var soOrder in GetSOOrderRecords())
{
yield return soOrder;
}
}
}

private IEnumerable GetSOOrderRecords()
{
PXGraph graph = this._Graph;
CABankTran currentBankTran = graph.Cachesstypeof(CABankTran)].Current as CABankTran;

int? payeeAccountId = currentBankTran?.PayeeBAccountID;

foreach (SOOrder soOrder in PXSelect<SOOrder,
Where<SOOrder.customerID, Equal<Required<SOOrder.customerID>>>>
.Select(graph, payeeAccountId))
{
yield return soOrder;
}

}
}
 #region AdjdRefNbr
PXMergeAttributes(Method = MergeMethod.Append)]
PXInvoiceSelectorCustom(typeof(CABankTran.origModule))]
public string AdjdRefNbr { get; set; }
#endregion

 


Hello again!

I have some good news: I was able to retrieve the SO data and save it, although I encountered an error when I pressed the process button (an image of the error is attached below). However, the Invoice lookup that was in the reference number has disappeared. I'll share the code and the expected output below.

using PX.Data;
using System;
using System.Collections;
using PX.Objects.SO;
using PX.Objects.CA;
using System.Reflection;

public class PXInvoiceSelectorCustomAttribute : PXSelectorAttribute
{
private PXGraph _Graph;

public PXInvoiceSelectorCustomAttribute(Type type) : base(type)
{
this.DescriptionField = typeof(SOOrder.orderDesc);
}

public IEnumerable GetRecords()
{
PXGraph graph = this._Graph;
PXCache cache = graph.Caches[_BqlTable];
object current = cache.Current;

if (current != null)
{
string origModule = (string)cache.GetValue<CABankTran.origModule>(current);

if (origModule == PX.Objects.GL.BatchModule.SO)
{
PXSelectBase<SOOrder> select = new PXSelect<SOOrder>(graph);
foreach (SOOrder order in select.Select())
{
yield return order;
}
}
else
{
var baseMethod = this.GetType().BaseType.GetMethod("GetRecords", BindingFlags.Instance | BindingFlags.NonPublic);
foreach (var record in (IEnumerable)baseMethod.Invoke(this, null))
{
yield return record;
}
}
}
}
}
 #region AdjdRefNbr
[PXMergeAttributes(Method = MergeMethod.Merge)]
//[PXRemoveBaseAttribute(typeof(PXSelectorAttribute))]
[PXInvoiceSelectorCustom(typeof(Search<SOOrder.orderNbr>), Filterable = true)]
public virtual string AdjdRefNbr { get; set; }
#endregion

 

The following is an illustration of the expected output:

When module = AR &
 Document Type = Inv => show invoices 
Document Type = SO => show SalesOrders,

 

 


Hi @rashmikamudalinayake10 were you able to find a solution? Thank you!


Hi @Chris Hackett

Not yet, I'm still working on it.

Thanks.


Reply