Display column label instead of column name as the value

WayneH08
Tera Contributor

I am hoping someone can provide some guidance; I'd like to display the column label instead of the column name as the value.

In the screenshot the field Updated Field is pulling data from another field instead of displaying the column name as in the screenshot (u_preferred_first_name), I'd like to be able to display the column label = Preferred First Name.

 

WayneH08_0-1708704696994.png

Any help would be much appreciated, thank you.

 

4 REPLIES 4

Mio Matsushita
Mega Sage

Hello.

 

Unfortunately I cannot offer a practical solution, but I can offer two methods from a technical aspect.

The first way is to add a Calculate Value Field to the sys_audit table.
Customize the sys_audit table to add a custom field (e.g. Field Label[u_field_label]) that displays the label name.
Specifically, the field label is retrieved from the sy_db_object table based on the table name and field name in the sys_audit table.
This worked as expected.
Set it up as shown in the following image.

image1.png

Calculation

(function calculatedFieldValue(current) {
	var gr = new GlideRecord(current.tablename);
	gr.query();
	return gr[current.fieldname].getLabel();
})(current);

Result

image3.png

 

 

The second way is to create a database view.
Create a database view (e.g., u_sys_audit_sys_dictionary) that combines the sys_audit table and sys_dictionary.
By specifying the audit_fieldname=dict_element && audit_tablename=dict_name Where clause in the view of the sys_dictionary table, the sys_audit table can display Column label together.

The configuration is shown in the following image.

image2.png

Where clause

audit_fieldname=dict_element && audit_tablename=dict_name


However, customization to system tables such as the sys_audit table should be cautious in terms of impact on OOTB functionality and instance performance.
Perhaps these methods are generally not recommended.
If you have other expert opinions, please let me know.

Thank Mio, I am hesitant to customise the sys_audit table, I'll wait to see if any other solutions are provided before going down this road.

Sumanth16
Kilo Patron

Hi @WayneH08 ,

 

Please refer below thread:

 

If you are using business rule add below line

current.getDisplayValue('state');

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

WayneH08
Tera Contributor

Thank you for your reply Sumanth16. I've attached a screenshot of the Business Rule that is monitoring one table for updates and then populating another table to track the updates. I've highlighted the line that sets the value in the target table, this is where I need to display the the column label "Preferred First Name". Where would I add the current.getDisplayValue('state'); line? Also do I replace 'state' with 'u_updated_field' which is the field I need the display name to show?