Solved

How to get a custom field to only show dependant on an earlier field choice


How do you get a custom field to only show dependant on an earlier field choice?

 

The scenario:

On the Activity page CR306010, you can currently choose different activity types, such as phone call or note. 

We would like to add a custom field so that the custom field shows up when Phone Call is chosen. This Custom Field would be called Call Type, and have drop-down options such as Cold Call, Pricing Call, Customer Sevice Call etc.

Then we are planning with that data to be able to see what type of phone calls are being made. 

 

So the question is, if we add a custom field, how can we get it to show only when the Type Field is filled with the Phone Call option?

 

Trust this makes sense.

icon

Best answer by Naveen B 6 May 2021, 10:19

Hi @dan_00 

Sorry for that. I just corrected it. Please publish the attached package and verify.

View original

4 replies

Userlevel 6
Badge +3

Hi @dan_00 

It requires small customization to display the custom field based on the selection. I have attached the package here. Please publish and verify.

 

Also attached code here.

[Serializable]
public class CRActivityCExt : PXCacheExtension<CRActivity>
{
#region UsrCMSRP
[PXDBString(30, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Test Field")]
// [PXUIVisible(typeof(Where<CRActivity.type, Equal<Testconstants.PhoneCall>>))]
public virtual string UsrTestField { get; set; }
public abstract class usrTestField : PX.Data.BQL.BqlString.Field<usrTestField> { }
#endregion
}


public class CRActivityMaintExt : PXGraphExtension<CRActivityMaint>
{
protected virtual void CRActivity_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
InvokeBaseHandler?.Invoke(cache, e);
CRActivity row = e.Row as CRActivity;
if (row != null )
{
PXUIFieldAttribute.SetVisible<CRActivityCExt.usrTestField>(cache, row, row.Type.Trim() == "P");

}
}
}

 

 

Userlevel 6
Badge +3

Forgot to attach the screenshots…
 

 

 

 

Thanks heaps for that @Naveen B 

I am actually getting a validation issue:

\App_Code\Caches\CRActivityMaint.cs(29): error CS0246: The type or namespace name 'CRActivityCExt' could not be found (are you missing a using directive or an assembly reference?)

Do you know why that would be?

Userlevel 6
Badge +3

Hi @dan_00 

Sorry for that. I just corrected it. Please publish the attached package and verify.

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 — 2020  Acumatica, Inc. All rights reserved