1
votes

The 'Customer' form has a variable called AcctReferenceNbr (Variable that I'm trying to grab shown in yellow) which takes a two-letter abbreviation of the customer name. I am currently editing the Projects form, and I want to use this abbreviation as part of the External Ref. Nbr.

The attached image End Result I'm trying to achieve shows what the end result should look like. The number from the QuoteID is appended to the abbreviation.

I am able to successfully grab the QuoteID as it is part of the Projects table, but I am currently unable to grab the AcctReference Nbr from the Customer table.

I have a RowSelected event on the QuoteID field, which is shown below:


    namespace PX.Objects.PM
    {
      public class ProjectEntry_Extension : PXGraphExtension<ProjectEntry>
      {
        #region Event Handlers
    
        
        protected void PMProject_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
          
          PMProject row = (PMProject)e.Row;
          if (row.ContractCD != null) {
            PMProject item = PXSelectorAttribute.Select<PMProject.contractCD>(cache, row) as PMProject;
            
            // The "UP" string is where the abbreviation is supposed to be, 
            // but I just added two letters to test if the appending works, which it does.
    
            row.ExtRefNbr = "UP" + item.ContractCD;
          }
          
        }
    
        #endregion
      }
    }

What I've tried so far:

  • Accessing the Customer table namespace to grab the value and pass it to the Projects form, which didn't work because it didn't accept the Customer type in the Projects form.

  • Adding a PXDefault attribute to the External Ref. Nbr which would try and grab the variable using SQL.

I'm a bit stuck on what else I can try. Any help would be appreciated :)

UPDATED

Below is how I went about trying to grab the AcctReferenceNbr value from the Customer table.

The reason why I tried using the PXSelectorAttribute method was that I added the AcctReferenceNbr as a column to the Quote ID selector (selector is shown in the link above called 'End Result I'm trying to achieve').

So I figured I could try and grab that value in the Customer namespace, as that is where the variable resides, and pass that up to the Project namespace above.

Then, I would call the public method below in the Project namespace to get the required abbreviation:

// instead of this
row.ExtRefNbr = "UP" + item.ContractCD;

// it would be this
row.ExtRefNbr = PX.Objects.AR.CustomerMaint_Extension.getAcctReferenceNbr(cache, e) + item.ContractCD;
    namespace PX.Objects.AR
    {
      public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
      {
        #region Event Handlers
    
        public static string getAcctReferenceNbr(PXCache cache, PXRowSelectedEventArgs e)
        {
          
            BAccount row = (BAccount)e.Row;
          
            BAccount item = PXSelectorAttribute.Select<BAccount.acctReferenceNbr>(cache, row) as BAccount;
    
            return item.acctReferenceNbr;
          }
          
        }
    
        #endregion
      }
    }

Is there a proper way to target the actual table?

1
can you share your code where you're accessing the Customer table ?Rick
I'm not currently accessing the Customer table as the code I wrote didn't work, so I just removed that part of the code. Did you want me to send through what my attempt to access it looked like?Andrew Aiello
yes. cause that's the way to go. and i'm curious why its not working for you.Rick
I've added an update, let me know if you need me to clarify anything :)Andrew Aiello

1 Answers

1
votes

try this. I haven't tested this but give it a go.

    protected void PMProject_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
    {
      
      PMProject row = (PMProject)e.Row;
      if (row.ContractCD != null && row.CustomerID != null) 
      {

        BAccount ba = (BAccount )PXSelectorAttribute.Select<PMProject.customerID>(cache, row) ;    
        row.ExtRefNbr = ba.AcctReferenceNbr+ row.ContractCD;
      }
      
    }

you certainly don't need to extend the CustomerMaint graph.