Skip to main content

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

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

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

}


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

 


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


Reply