Make a dropdown field invisible based on a selection.
Need to invisible the field “Bill” in ‘Document Type dropdown’ when selecting ‘AR’ as Module. and also It shouldn’t affect the visibility when selecting ‘AP’ as the module. (logic applicable only for ‘AR’)
How can I achieve this. Any Code snippets/ ideas?
Page 1 / 1
Hello @rashmikamudalinayake10 ,
For faster help with Development and Customization, please post question in Development or Customization discussion areas of this forum (not in Financials).
Many members subscribe only to certain Discussion Forums where their skills match the questions.
You may post your question again in a different forum and close this one by choosing best answer, or you may ask an Acumatica Moderator to move this post. More Hints & Tips for new members can be found here:
I hope this helps you find a faster answer. Good luck!
Laura
Hi @rashmikamudalinayake10 Here is the solution sample to make it conditionally. visible
Hi @rashmikamudalinayake10 Here is the solution sample to make it conditionally. visible
where ARModule is the constant that you can define for the string “AR”.
Hi there,
Just Need to hide the field “Bill” in ‘Document Type dropdown’ when selecting ‘AR’ as the Module. (besides, "Bill" should be there when selecting ‘AP’ as the module) Any idea?
@rashmikamudalinayake10 The Below article might help with your requirement. Please review.
I just tried the code below, but I didn't get either an error or a visible change in UI. Can anyone please point out what's wrong here?
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using PX.Common; using PX.Data; using PX.Objects.AP; using PX.Objects.AR; using PX.Objects.CA.BankStatementHelpers; using PX.Objects.CA.BankStatementProtoHelpers; using PX.Objects.CM.Extensions; using PX.Objects.CS; using PX.Objects.GL; using PX.Objects.IN; using PX.Objects.AP.MigrationMode; using PX.Objects.AR.MigrationMode; using PX.Objects.Common; using PX.Objects.CR; using PX.Objects.EP; using static PX.Objects.Common.UIState; using PX.Objects.TX; using PX.Data.BQL.Fluent; using PX.Data.BQL; using PX.Objects.CA.Repositories; using PX.Objects; using PX.Objects.CA;
namespace PX.Objects.CA { public class CABankTransactionsMaint_Extension : PXGraphExtension<PX.Objects.CA.CABankTransactionsMaint> { #region Event Handlers
if (doc.OrigModule == "AR") { // Hide the 'Bill' field by setting its visibility to false PXUIFieldAttribute.SetVisible<CABankTranAdjustment.adjdDocType>(cache, doc, false); } else { // Make the 'Bill' field visible for other modules PXUIFieldAttribute.SetVisible<CABankTranAdjustment.adjdDocType>(cache, doc, true); } } } }
Thanks.
:-)
@rashmikamudalinayake10 first of all, I’m not sure why you use CATranExt_RowSelected.
Since you want the value to be dependent on a field on CABankTran, it makes sense to use CABankTran instead.
Second, in the PXUIFieldAttribute.SetVisible<CABankTranAdjustment.adjdDocType>(cache, doc, true); you should use cache object of the CABankTranAdjustment. Currently you have cache object of CATranExt (or CABankTran if you change it).
Fixing those two things should help.
Thanks!
Could able to hide the 'Document Type' column when selecting the 'AR' module. But I need to hide the dropdown value 'Bill' in the 'Document Type' dropdown when the 'AR' module is selected. Any ideas on how to reference the value field in the dropdown?
if (doc != null) { if (doc.OrigModule == "AR") { // Hide the 'adjdDocType' field by setting its visibility to false PXUIFieldAttribute.SetVisible<CABankTranAdjustment.adjdDocType>(Base.Adjustments.Cache, null, false); } else { // Make the 'adjdDocType' field visible for other modules PXUIFieldAttribute.SetVisible<CABankTranAdjustment.adjdDocType>(Base.Adjustments.Cache, null, true); } } }
Thanks.
:-)
@rashmikamudalinayake10 you should use PXListAttribute.SetList() method to set list of value to the dropdown.
Also make sure you set MatrixMode=true in aspx for the field.
if (doc != null) { if (doc.OrigModule == "AR") { // Modify the list of values for the 'adjdDocType' dropdown PXStringListAttribute.SetList<CABankTranAdjustment.adjdDocType>( Base.Adjustments.Cache, null, new string[] { "Invoice", "Payment" }, // List of values to display new string[] { "INV", "PMT" } // List of corresponding keys ); }
else { // Restore the original list of values for the 'adjdDocType' dropdown PXStringListAttribute.SetList<CABankTranAdjustment.adjdDocType>( Base.Adjustments.Cache, null, new string[] { "Invoice", "Bill", "Payment" }, // Original list of values new string[] { "INV", "BILL", "PMT"} // Original list of corresponding keys ); } } }