Solved

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


Badge

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 Boga 6 May 2021, 10:19

View original

11 replies

Userlevel 7
Badge +17

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 7
Badge +17

Forgot to attach the screenshots…
 

 

 

 

Badge

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 7
Badge +17

Hi @dan_00 

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

Badge

Hello @Naveen B 

Thank you for the customisation file, its good.

After working on this, we actually wondered whether the best approach to this was to extend the Attributes setup CS205000to the Activities screen?

Is this possible?  Would it be another way to answer the issue?

Or should this be put on a new thread...

Userlevel 7
Badge +17

Hi, @dan_00 It would be better if you open a new thread, so that everyone can share their ideas.

 

Badge

Ok will do.

Badge

Hello @Naveen B 

With this customisation package, is there a way to have it so that it shows for all activity types, and then dependant on the activity type chosen, have different values in the dropdown?

Or is thisnot a possibility?

I note this article describes how to add a dropdown field, but not regarding having the selection field dependent on an earlier field. https://www.crestwood.com/2018/03/13/how-to-add-a-dropdown-list-field-to-an-acumatica-screen/ Would there be an extra step or two in this process shown here that would make it possible?

Userlevel 7
Badge +17

Hi @dan_00,

Below is my understanding, please confirm.

-- A new customization “DropDown” field will be created and this will be visible to all the types.

-- Based on the “Type” selected, the DropDown values will be modified.

   For Eg: When we select the “Chat” type, the dropdown values will show A, B, C...but when we select Phone Call Type, then the dropdown will show X, Y, Z.

 

I’m hoping you're expecting this behavior, if yes, then the above customization package will NOT work, we need to come up with new customization. 

Userlevel 2
Badge

Hi @Naveen Boga ,

 

I have a similar scenario but I want the drop list to be the list of all inventory items, so basically, I add a new data field, add control but then what? I am not that good with programming language and would appreciate if can be done by clicking buttons please! [the inventory does not show up in the data view drop down box if the screen that I am want to change is the Case Support screen] Thank you!

 

Kind regards,

mrivera67

Userlevel 4
Badge

Naveen,

How would you write the PXFieldAttribute command if you wanted to “display the usrTestField except when Phone is selected”?

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