Skip to main content
Solved

Make a Combo box visible depending on the value of another field


How do I go about making another field visible depending on the value of another field. I would like to do this with Acumatica Tools as I’m not familiar with Visual Studio.

15 replies

Badge +12

Can you give some more details, such as the field names and what value would change the visibility?

Userlevel 5
Badge +2

hi @lewisad 

 

As @darylbowman said could you please elaborate?

But as a first point of call, this would be a customisation, probably an override of the RowSelected handler, and would look something like this:

protected virtual void _(Events.RowSelected<YourDac> e, PXRowSelectedArgs b)
{
YourDac row = e.Row;
b?.Invoke(e.Cache, e.Args)

if(row.YourField == "SomeValue")
{
PXUIFieldAttribute.SetEnabled<row.YourDropDown>(e.Cache, e.Row, true)
}

}

The solution should be something along these lines.

Badge +12

Some people consider adding fields into Data Access to be low code. Since you can also change / add DAC attributes there, it would probably be possible using [PXUIEnabled], but under the hood, it's still a customization.

Userlevel 2
Badge

Hi. I added a new field using this method.

Custom Field combo box list creation | Community (acumatica.com)

I would like this combo box to be only activated when the status of a customer account is changed to “OnHold”. The user would then be able to select the reason the account is “OnHold”. This field would be made visible on service orders as a quick glance to why the customer account is on hold and the service order cannot be created.

The T210 training does go through this but from a VB perspective.

Userlevel 5
Badge +2

The best thing you could do is add a dialog box to the workflow transition, that’s no code just through the workflow engine.

Badge +12

I would like this combo box to be only activated when the status of a customer account is changed to “OnHold”. The user would then be able to select the reason the account is “OnHold”.

I’m assuming you’re wanting to set the combo box value from the Customer screen.

 

This field would be made visible on service orders as a quick glance to why the customer account is on hold and the service order cannot be created.

This may be tricky using low-code / no-code, but I haven’t looked at the screen.

 

Since you already used DAC attributes in creating the field, simply add this attribute in the same place:

[PXUIEnabled(typeof(Where<Customer.status.IsEqual<CustomerStatus.hold>>))]

 

If you additionally wish to require the field when the Custom is ‘On Hold’, add these as well:

[PXUIRequired(typeof(Where<Customer.status.IsEqual<CustomerStatus.hold>>))]

[PXDefault]

 

Finally,

...but from a VB perspective.

Acumatica is written in C#.

Userlevel 6
Badge +2

You can do this by adding the new even handler. You can do that in your browser without opening Visual Studio.
1. Click Customization at the top right corner
2. Click Inspect element 
3. Click on any control at the screen 
4. In new popup, click Customize 
5. New window will open. It will show you the page where you can edit layout of the screen
6. Click three dots right to the Preview Changes button
7. Click Customize Business Logic
8. New page will be opened, with a template like this:

using System;
using PX.Objects;
using PX.Data;

namespace Sprinterra.CommunityRnd.InquiryTotals
{
  public class MSInquiry_Extension : PXGraphExtension<Sprinterra.CommunityRnd.InquiryTotals.MSInquiry>
  {
    #region Event Handlers

    #endregion
  }
}

9. Between #region and #endregion lines, insert this code:

public virtual void _(Events.RowSelected<Customer> e, PXRowSelected baseMethod)
{
    baseMethod?.Invoke(e.Cache, e.Args);

    if (!(e.Row is Customer row))
        return;

    PXUIFieldAttribute.SetEnabled<Customer.collectionAction>(e.Cache, row, row.Status == "OnHold");
}

10. Replace Customer with the DAC you're trying to track, and "OnHold" with the value associated with the OnHold status.
11. Click Save
12. Click Publish at the top menu
13. Click Publish Current Project

You'll see a new section at the bottom of the page that will show you the progress. Once it's finished - it's done.  
If you need help with identifying the right DAC and Status value, tell me the screen you're trying to customize and which Status field you need to check for.  
Let me know if there's any issue with this approach.

I'd also want to point out that as @aiwan mentioned, you can also do that via workflow. As I'm a developer, for me it's easier and faster to create this event handler I've shown above. But you might find that workflow solution is more maintainable for you as it can be configured all in the browser using built-in commands, not touching the code at all.

Userlevel 2
Badge
  • @andriitkachenko thanks for your reply. I will also try this method.

Userlevel 2
Badge

How do I clear this field once the status is changed back to “Active” or one of the other status?

Badge +12

Ideally, you’d use code to do so, but this is getting well beyond low-code / no-code.

Userlevel 6
Badge +2

You need to add another command to the event:

public virtual void _(Events.RowSelected<Customer> e, PXRowSelected baseMethod)
{
baseMethod?.Invoke(e.Cache, e.Args);

if (!(e.Row is Customer row))
return;

PXUIFieldAttribute.SetEnabled<Customer.collectionAction>(e.Cache, row, row.Status == "OnHold");

if(row.Status=="Active")
row.CollectionAction = null;
}

​But, as @darylbowman  rightfully said - your logic grows beyond a low-code solution that can be maintained in the browser, as we can already see new clauses and edge cases appearing.  

Userlevel 7
Badge +4

@lewisad since you mentioned/posted low-no code, here’s a helpful article from @Naveen Boga on the subject.

Tips & Tricks Using Acumatica's Low-Code/No-Code

You basically create the condition and use it on the Hidden parameter for the field.

Userlevel 2
Badge

You can do this by adding the new even handler. You can do that in your browser without opening Visual Studio.
1. Click Customization at the top right corner
2. Click Inspect element 
3. Click on any control at the screen 
4. In new popup, click Customize 
5. New window will open. It will show you the page where you can edit layout of the screen
6. Click three dots right to the Preview Changes button
7. Click Customize Business Logic
8. New page will be opened, with a template like this:

using System;
using PX.Objects;
using PX.Data;

namespace Sprinterra.CommunityRnd.InquiryTotals
{
  public class MSInquiry_Extension : PXGraphExtension<Sprinterra.CommunityRnd.InquiryTotals.MSInquiry>
  {
    #region Event Handlers

    #endregion
  }
}

9. Between #region and #endregion lines, insert this code:

public virtual void _(Events.RowSelected<Customer> e, PXRowSelected baseMethod)
{
    baseMethod?.Invoke(e.Cache, e.Args);

    if (!(e.Row is Customer row))
        return;

    PXUIFieldAttribute.SetEnabled<Customer.collectionAction>(e.Cache, row, row.Status == "OnHold");
}

10. Replace Customer with the DAC you're trying to track, and "OnHold" with the value associated with the OnHold status.
11. Click Save
12. Click Publish at the top menu
13. Click Publish Current Project

You'll see a new section at the bottom of the page that will show you the progress. Once it's finished - it's done.  
If you need help with identifying the right DAC and Status value, tell me the screen you're trying to customize and which Status field you need to check for.  
Let me know if there's any issue with this approach.

I'd also want to point out that as @aiwan mentioned, you can also do that via workflow. As I'm a developer, for me it's easier and faster to create this event handler I've shown above. But you might find that workflow solution is more maintainable for you as it can be configured all in the browser using built-in commands, not touching the code at all.

Thanks. I will look into trying it this way also. Would you recommend perusing an understanding of C# and web development as a next step?

Userlevel 2
Badge

The best thing you could do is add a dialog box to the workflow transition, that’s no code just through the workflow engine.

Will take a look. Thanks

Userlevel 6
Badge +2

Thanks. I will look into trying it this way also. Would you recommend perusing an understanding of C# and web development as a next step?

Depends on your goals and availability.

If you want to go further with the custom logic and cover other cases - then yes, it will start requiring more and more knowledge about the software development.  

Whether it’s worth it to learn more or outsource it - is up to you. If you have time and patience to learn how to write a code and develop new things - go for it, you can start with learning only chunks required to your right now.

Otherwise - you can reach out to an ISV to help you make the customization you need.

Reply