Question

It is not possible to change the value field again after performing the FieldSelecting Event

  • 28 November 2023
  • 3 replies
  • 94 views

Userlevel 3
Badge

Dear Team,

I have created a Custom field (UsrContactPhone) on the Cases screen to display the Contact's phone number.

I used FieldSelecting Event to do this. The result displayed the value of Custom field (UsrContactPhone) on the Cases screen, but I can't re-enter another value for this field (UsrContactPhone). After entering another value again, the system updates the default value of FieldSelecting Event.

How can I change the value of the field after performing FieldSelecting Event or FieldUpdated Event ?


Please help me with the solution !

Best Regards,

NNT

==============

protected void CRCase_UsrContactPhone_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e, PXFieldSelecting InvokeBaseHandler)
    {
      if(InvokeBaseHandler != null)
      InvokeBaseHandler(cache, e);
      var row = (CRCase)e.Row;
            if (row == null)
            {
                return;
            }

            Contact contact = PXSelect<Contact,
                Where<Contact.contactID, Equal<Required<Contact.contactID>>>>.Select(Base, row.ContactID); 
            if (contact == null) { return; }
            e.ReturnValue = contact.Phone1 ;
            Base.Case.View.RequestRefresh();
      
    }

==============


3 replies

Userlevel 7
Badge +17

@nhatnghetinh Try like below.

 

Write a FieldUpdated event for the CONTACTID field, and update the PHONE NUMBER field (Custom Field). Then after if you modify also, it will the update field.

 

protected void CRCase_ContactID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
    {
      if(InvokeBaseHandler != null)
      InvokeBaseHandler(cache, e);
      CRCase row = (CRCase)e.Row;
            if (row == null)
            {
                return;
            } 

            Contact contact = PXSelect<Contact,   Where<Contact.contactID, Equal<Required<Contact.contactID>>>>.Select(Base, row.ContactID); 
            if (contact != null) 

CRCaseExt rowExt = row.GetExtension<CRCaseExt>(); 

            rowExt.UsrContactPhone = contact.Phone1 ;
          //  Base.Case.View.RequestRefresh();
      
    }

}

Userlevel 3
Badge

Hi @Naveen Boga,

Please let me ask. 

 

// Your code lines

...

 Contact contact = PXSelect<Contact,   Where<Contact.contactID, Equal<Required<Contact.contactID>>>>.Select(Base, row.ContactID); 

 if (contact != null) 

{

       CRCaseExt rowExt = row.GetExtension<CRCaseExt>(); 

       rowExt.UsrContactPhone = contact.Phone1 ;

}

 

// and these code lines => are they the same? (with the same situation: CRCase_ContactID_FieldUpdated event )

... 

CRCaseExt rowExt = PXCache<CRCase>.GetExtension<CRCaseExt>(row)

 Contact contact = PXSelect<Contact,   Where<Contact.contactID, Equal<Required<Contact.contactID>>>>.Select(Base, row.ContactID); 

 if (contact != null) 

 {

     cache.SetValueExt<CRCaseExt.UsrContactPhone>(row, contact.Phone1);

}

 

Best Regards,

NNT

 

Userlevel 7
Badge

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

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