Skip to main content
Question

Is it possible to add the hover/preview function to UDFs?

  • 11 September 2024
  • 2 replies
  • 64 views

Forum|alt.badge.img

We have several text UDFs and are wanting to preview data, that is longer than the width of the field, by hovering over the field. The functionality exists in out of the box fields, so can this be extended to UDFs? With the character limit on UDFs being a lot longer than the width of the field, it isn’t very user friendly to have to use the cursor/arrows in order to read the data in full. 

2 replies

chameera71
Varsity I
Forum|alt.badge.img+1
  • Varsity I
  • 53 replies
  • September 12, 2024

Yes, you can implement a tooltip-like functionality for User-Defined Fields (UDFs) in Acumatica to preview data when hovering over the field. This functionality, which exists for out-of-the-box fields, can be extended to UDFs with a bit of customization.

Here’s how you can achieve this:

Solution Approach:

  1. Utilize PXFieldAttribute: Acumatica allows you to customize the behavior of fields using the PXFieldAttribute. You can add a tooltip or hover preview to a field by overriding the attribute definition in the code.

  2. Modify the UDF Control in the Customization Project: You will need to modify the UDF definition in the Customization Project Editor to include a hover behavior similar to out-of-the-box fields. You can use the PXFieldAttribute in your DAC extension to define a DisplayName or Description, which will be shown as a tooltip.

Steps:

1. Create a DAC Extension for the UDF:

If you haven’t already, create a DAC extension for the UDFs to add custom attributes. This is where you will extend the tooltip functionality.

 

csharp

 

using PX.Data; namespace CustomizationNamespace { public class MyCustomTableExtension : PXCacheExtension<MyCustomTable> { // Assuming your UDF is a string field [PXDBString(255, IsUnicode = true)] [PXUIField(DisplayName = "My UDF Field", Visibility = PXUIVisibility.SelectorVisible, FieldName = "MyUDFField")] [PXFieldDescription] // This provides the tooltip functionality public virtual string MyUDFField { get; set; } } }

  • PXUIField defines the display name and visibility of the field.
  • PXFieldDescription allows a tooltip to be shown with the field content.

2. Use the PXUIField Attribute for Tooltip:

The PXUIField attribute has a Tooltip property that you can leverage. You can set this property to show the full content of the UDF when hovering over the field. For example:

 

csharp

 

[PXUIField(DisplayName = "My UDF Field", Visibility = PXUIVisibility.SelectorVisible, FieldName = "MyUDFField", Tooltip = "Hover to preview data")]

This will display a tooltip with either the defined text (e.g., "Hover to preview data") or you can dynamically show the actual field value.

3. Use JavaScript for Dynamic Tooltip (Optional):

If you want to make the tooltip dynamic based on the content of the field, you can inject a bit of JavaScript to modify the field’s behavior. Here’s a simple outline of what you can do:

  • Add a JavaScript script to your customization project to listen for the mouse hover event on the UDF field and display the field’s value as a tooltip.

  • In the Customization Project Editor, go to the form where the UDF is located, and add the script to inject dynamic behavior.

Example (conceptual JavaScript):

 

javascript

 

document.querySelectorAll('[id^="MyUDFField"]').forEach(function(el) { el.addEventListener('mouseover', function(event) { el.title = el.value; // Set the tooltip to show the full content of the UDF }); });

4. Customize UI with Customization Project Editor:

Go to the Customization Project Editor in Acumatica, select the UDF fields you want to modify, and apply your extended logic. Ensure that you publish the changes after adding this customization.

Things to Consider:

  • Performance: If your UDFs contain a large amount of data, loading the data in tooltips may have a slight performance impact. Be sure to test for any performance degradation in production.
  • Field Types: This solution assumes that your UDFs are text fields. If your UDFs have different types, you may need to adjust the code accordingly.
  • Tooltips for Grids: If your UDFs are in a grid, the solution will still work but may require more fine-tuning based on the grid behavior.

Conclusion:

By leveraging Acumatica’s PXFieldAttribute and PXUIField attributes, you can extend the out-of-the-box tooltip functionality to UDFs, making the fields much more user-friendly by allowing users to preview longer text values on hover. This can greatly enhance the usability of your screens, especially when dealing with long text entries in UDFs.

 

😀💡


Forum|alt.badge.img
  • Author
  • Varsity I
  • 55 replies
  • November 7, 2024

@chameera71 Thank you for your response. Unfortunately, this is a little more in depth than I was comfortable with, so I sent it over to our VAR to review. After talking with them, and having Acumatica review, we have been advised that the tooltip functionality is not supported for user-defined fields (those created and showing on the user-defined field tab). Have you personally been able to make this work per your suggestions above? Thanks! 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings