How to update a field in another DAC


Userlevel 2
Badge

I have added a new Probability field over here marked as yellow. It is a dropdown containing integer values. I need to reflect the value selected over there in the probability field marked as green. Currently that probability field is taking value from the stage dropdown marked as blue. Need to change that. Any leads would be welcomed.  

 

The field I have added i.e Yellow colored one is in CROpportunityExt class that i have created. And the field I need to update (green colored) based on change is present in CROpportunityProbability DAC.

 


8 replies

Userlevel 7
Badge +17

Hi @param2022  You can write a FieldUpdated event for the Yellow colored filed, and when you try to update the yellow update field, then this field updated event will be invoke and this event set the value to the Green color field.  

Userlevel 2
Badge

@Naveen Boga i know i need to add that thing in the field updated event and I created one. But i don’t know how can I access the CROpportunityProbability over here and remove the current dependency the green field has on the blue dropdown.

 

In this code I only get the CROpportunity DAC.

 

public class OpportunityMaint_Extension : PXGraphExtension<OpportunityMaint>
{
#region Event Handlers

protected void CROpportunity_UsrProbability_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
CROpportunity row = (CROpportunity)e.Row;
}
#endregion
}

 

Userlevel 7
Badge +17

Hi, @param2022  It is very simple to access the field from the current VIEW like below.

Base.LeadCurrent.Current.UsrCustomField = Yellow Color Field value.

 

I hope you have completed the “Application Developer” certification, if NOT, I would highly recommend you to complete the Application Developer certification as early as possible.

 

Userlevel 2
Badge

@Naveen Boga by “Application Developer” are you referring to T200,T210 …... series course ?? I am working on that as of now.

Userlevel 7
Badge +17

Yes @param2022  Please complete that certification before jumping into customizations. 

By the time finishing your certification, you will get a good knowledge customizations.

 

Userlevel 3
Badge

@Naveen Boga 

I was wondering if you could look at this for me.  I tried to go back and review the training you suggested but wasn’t able to fix the below logic which is now split between 2 DACs but on the same entry screen (Appointments FS300200). 

 

I am trying to update a customization from 2020R1 to 2021R2.  The fields CustomerID and ProjectID have moved from FSServiceOrder to FSAppointment and I’m not sure how to fix the below logic.  Thanks in advance for any tips…

 

 

 

     protected void _(Events.FieldUpdated<FSServiceOrder, FSServiceOrder.customerID> eventHandler)
{
FSServiceOrder row = eventHandler.Row;
if (row == null || row.CustomerID == null) return;

Location serviceOrderLocation = SelectFrom<Location>
.Where<Location.bAccountID.IsEqual<@P.AsInt>
.And<Location.locationID.IsEqual<@P.AsInt>>>
.View.Select(Base, row.CustomerID, row.LocationID);

if (serviceOrderLocation != null && serviceOrderLocation.CDefProjectID != null)
eventHandler.Cache.SetValueExt<FSServiceOrder.projectID>(row, serviceOrderLocation.CDefProjectID);

 

Userlevel 7
Badge +17

Hi @greglang  Thanks for reaching out the above query.

Please find the code below to update the Project from Customer Location to Appoinments screen.

I have verified it and working as expected. Please let me know if you any other queries on this.

public class AppointmentEntryExt : PXGraphExtension<AppointmentEntry>
{
protected void _(Events.FieldUpdated<FSAppointment, FSAppointment.customerID> eventHandler)
{
FSAppointment row = eventHandler.Row;
if (row != null && Base.ServiceOrderRelated.Current != null)
{
Location serviceOrderLocation = SelectFrom<Location>
.Where<Location.bAccountID.IsEqual<@P.AsInt>
.And<Location.locationID.IsEqual<@P.AsInt>>>
.View.Select(Base, row.CustomerID, Base.ServiceOrderRelated.Current?.LocationID);

if (serviceOrderLocation != null && serviceOrderLocation.CDefProjectID != null)
{
row.ProjectID = serviceOrderLocation.CDefProjectID;
//eventHandler.Cache.SetValueExt<FSServiceOrder.projectID>(row, serviceOrderLocation.CDefProjectID);
}
}
}
}

 

Userlevel 3
Badge

@Naveen Boga Thanks for the quick help.  It seems to be working mostly but for some reason has broken the current PXDefault for DfltProjectTaskID.  The field is not populating as before but based on the Attributes it should so I can only assume something is messed up in the event order Correct?

 

[PXDBInt]
        [PXFormula(typeof(Default<projectID>))]
        [PXUIField(DisplayName = "Default Project Task", Visibility = PXUIVisibility.Visible, FieldClass = ProjectAttribute.DimensionName)]
        [PXDefault(typeof(Search<PMTask.taskID,
                            Where<PMTask.projectID, Equal<Current<projectID>>,
                            And<PMTask.isDefault, Equal<True>,
                            And<PMTask.isCompleted, Equal<False>,
                            And<PMTask.isCancelled, Equal<False>>>>>>),
                            PersistingCheck = PXPersistingCheck.Nothing)]
        [FSSelectorActive_AR_SO_ProjectTask(typeof(Where<PMTask.projectID, Equal<Current<projectID>>>))]
        [PXForeignReference(typeof(FK.DefaultTask))]

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