Skip to main content
Question

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


nhatnghetinh
Captain II
Forum|alt.badge.img+10

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

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • November 28, 2023

@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();
      
    }

}


nhatnghetinh
Captain II
Forum|alt.badge.img+10
  • Author
  • Captain II
  • 387 replies
  • November 29, 2023

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

 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2640 replies
  • December 18, 2023

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings