As of the last update, directly controlling the fields displayed in a hover preview (reference field pop-up) using the ref_contributions attribute in ServiceNow is not straightforward. The ref_contributions attribute is typically used for adding UI actions, related lists, or enabling certain JavaScript controls on the reference field's hover window or reference selector, rather than directly specifying fields to be displayed.
However, to achieve the display of specific fields (e.g., Name and Country) in the hover preview for a reference field such as the caller in an incident, you have a couple of alternative strategies:
1. Customizing the Form Layout for the Reference Table
The hover preview generally shows the form view designed for the referenced record. To control which fields are visible, you can either modify an existing form view or create a new one and then instruct the reference field to use this view for its preview.
-
Navigate to Form Design:
- Go to the referenced table (e.g., User [sys_user] for Caller) and access the form configuration by right-clicking on the header of a record and selecting "Configure" -> "Form Layout."
-
Customize/Create a Form View:
- Either modify the existing "Default" view (not recommended if it's used elsewhere in your application) or create a new form view by simply arranging only the fields you want to be visible (Name and Country in this case).
-
Assign the Custom Form View to Hover Preview:
- This step depends on whether your version/setup of ServiceNow supports directly setting a specific form view for hover previews via UI. If not, this might involve a more in-depth customization such as scripting or potentially updating the reference field's dictionary attributes to implicitly use the newly created view. Typically, this kind of customization might be limited by out-of-the-box capabilities and could require creative solutions like client scripts that manipulate the DOM (not recommended due to potential performance and upgradeability issues).
2. System Properties
Sometimes, the behavior of reference field hover previews can be influenced by system properties. You may explore sys_properties for any properties related to reference field displays or hover behavior, although there's no direct property to specify fields as of the last update. To check or modify system properties:
- Navigate to "System Properties" via the filter navigator and search for properties related to references or hovers. Note that any changes here affect the system globally, so proceed with caution.
Consider Scripting Only as a Last Resort
It's worth noting that directly injecting JavaScript to alter the DOM for displaying specific fields in hover previews is highly discouraged unless absolutely necessary, as it can introduce performance issues, impact upgradability, and lead to unexpected behavior during system updates.
Conclusion
Without direct attribute manipulation options for specifying fields in the hover preview, the recommended approach involves adjusting form views or potentially seeking custom development solutions. Given the potential complexity and unintended consequences of custom solutions, consider reaching out to ServiceNow community forums, your ServiceNow representative, or consulting services for guidance tailored to your specific version and business needs. Always test any changes in a development or sub-production instance before applying them to your live environment.