Question

Transfer field value from quote screen to project screen

  • 29 October 2023
  • 4 replies
  • 84 views

Userlevel 5
Badge +1

Hi Team,

 

I added two custom fields, one on the project screen and one on the quote screen. I want to transfer values when a project is created from a quote. The fields are using the DACs 'PMSiteAddress' and 'CRAddress'. For the 'PMSiteAddress', I've created an extension class 'CRAddressExt' to add a custom field 'usrCounty'. Similarly, for the 'PMAddress', I've created an extension class 'PMAddressExt' with the same custom field 'usrCounty'

 

public class CRAddressExt : PXCacheExtension<PX.Objects.CR.CRAddress>

{

#region UsrCounty

[PXDBString(155)] [PXUIField(DisplayName = "County")]

public virtual string UsrCounty { get; set; }

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

#endregion

}

for project 

 public class PMAddressExt : PXCacheExtension<PX.Objects.PM.PMAddress>
 {
     #region UsrCounty
     [PXDBString(155)]
     [PXUIField(DisplayName = "County")]

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

I've written this code to transfer the value:

public class ProjectEntry_Extension : PXGraphExtension<PX.Objects.PM.ProjectEntry>

{    protected virtual void _(Events.RowSelected<PMSiteAddress> e) 

  {     
  var row = (PMSiteAddress)e.Row; 
      if (row == null) return;       
CRAddress address = PXSelect<CRAddress,  Where<CRAddress.lastModifiedByScreenID, Equal<Required<PMSiteAddress.lastModifiedByScreenID>>>> .Select(Base, row.LastModifiedByScreenID);   

    if (row != null && row.LastModifiedByScreenID == "PM304500")   
    {         
  var AddressExt = PXCache<CRAddress>.GetExtension<CRAddressExt>(address); 
  e.Cache.SetValue<PMAddressExt.usrCounty>(row, AddressExt?.UsrCounty);   
    }   
}
}
in the ProjectEntry Graph However, the field value is not transferring. Do you have a solution for this, or am I making a mistake? Please advise.

Regards,

Sagar

 


4 replies

Userlevel 7
Badge +8

@sagar07 a couple of suggestions and points to consider:

  1. Please read and watch Acumatica’s customization materials and best practices. We DO NOT change values in the RowSelected event.
  2. I might me wrong but just by looking at the code it looks to me more like a ChatGPT code that unfortunately its not mature enough to do what exactly supposed to happen.
  3. You can not do everything in the event handlers. If you read the “ConvertQuoteToProject” method code in the “PMQuoteMaint” you will see its too late for “ProjectEntry” grapgh to catch the change.
  4. The correct way to achieve what are you doing is to write a “delegate” for the above mentioned method. something like:
public delegate void ConvertQuoteToProjectDelegate(PMQuote row, PMQuoteMaint.ConvertToProjectFilter settings);
[PXOverride]
public virtual void ConvertQuoteToProject(PMQuote row, PMQuoteMaint.ConvertToProjectFilter settings, ConvertQuoteToProjectDelegate baseMethod)
{
// Do your stuff
}

 

Userlevel 5
Badge +1

@aaghaei I'm not using ChatGPT. I've passed the value of many fields through the row selected event. Besides this, I also tried coding on the ConvertQuoteToProjectDelegate action, but my custom field's value is not working only on the address tab.

I'm not finding any link between CRAddress and PMAddress to pass the value of this field. If you have any solution, please provide it to me.

Userlevel 7
Badge +8

@sagar07 its you choice if you want to continue on a wrong and unacceptable practice by altering values in RowSelected event. The RowSelected event primarily purpose is managing UI controls not data manipulation.

Regardless, please provide the delegate code here so people in the community can have a look and advise.

What methods can be used to transfer field values from the quote screen to the project screen?

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