Solved

Make a dropdown field invisible based on a selection.

  • 18 October 2023
  • 11 replies
  • 134 views

Userlevel 2
Badge

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?

Make field “Bill” invisible when selecting AR

 

Make field “Bill” visible when selecting AP (as prevailing)

 

icon

Best answer by rashmikamudalinayake10 24 October 2023, 05:50

View original

11 replies

Badge +16

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

Userlevel 7
Badge +9

Hi @rashmikamudalinayake10 Here is the solution sample to make it conditionally. visible

 

[PXUIVisible(typeof(Where<CABankTran.OrigModule.IsEqual<ARModule>>))]

where ARModule is the constant that you can define for the string “AR”.
 

Userlevel 7
Badge +9

Hi @rashmikamudalinayake10 You can also try with the Workflow to hide the type “Bill” for AR module.

Thanks

Userlevel 7
Badge +17

@rashmikamudalinayake10  The Below article might help with your requirement. Please review.

 

https://riptutorial.com/acumatica/example/29102/modifying-marital-statuses

Userlevel 2
Badge

Hi @rashmikamudalinayake10 Here is the solution sample to make it conditionally. visible

 

[PXUIVisible(typeof(Where<CABankTran.OrigModule.IsEqual<ARModule>>))]

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?

Userlevel 2
Badge

@rashmikamudalinayake10  The Below article might help with your requirement. Please review.

 

https://riptutorial.com/acumatica/example/29102/modifying-marital-statuses

Thanks!

There's an alternative way too

https://www.greytrix.com/blogs/acumatica/2023/09/02/modify-drop-down-values-without-code/

Userlevel 2
Badge

Hi All,

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

protected void CATranExt_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
CABankTran doc = (CABankTran)e.Row;

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.

:-)

Userlevel 7
Badge +5

@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.

 

Userlevel 2
Badge

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?

 protected void CABankTran_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
CABankTran doc = (CABankTran)e.Row;

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.

:-)

Userlevel 7
Badge +5

@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.

Userlevel 2
Badge

Thanks! it worked.

"Here is the attached code."

protected void CABankTran_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
CABankTran doc = (CABankTran)e.Row;

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

 

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