Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Change Values when Exporting to PDF

LouisG
Giga Guru

Hello Everyone, 

 

I was wondering if it's at all possible to change which values are displayed when exporting a record to PDF?

 

For problem tickets only, for all sys_user reference fields on the ticket, when exporting to PDF I don't want user names to display, I want their titles to display.  

 

I've implemented a client script that will change all sys_user reference fields to display titles onLoad in the native view, now I need this to apply to PDF exports as well. 

 

Any help pointing me in the right direction would be much appreciated.  

1 ACCEPTED SOLUTION

LouisG
Giga Guru

Alrighty so I figured this out. 

 

I edited the List Layout for the related Lists on the form, and dot.walked to Assigned to.Title field for all sys_user reference fields. 

 

For form fields, I access the context menu and went to Configure > Form Layout and dot.walked to sys_user.Title as well. Once all the adjustments were made, I exported to portrait PDF and all the Titles were exported on the doc instead of the employees names. 

View solution in original post

3 REPLIES 3

Sandeep Rajput
Tera Patron
Tera Patron

@LouisG Could you please share the script which changes all sys_user reference fields to display titles onLoad in the native view?

Hi Sandeep,

Below is the code that changes the displayValue onLoad

 

function onLoad() {
	var aUser = g_form.getValue("assigned_to");
	
	var userGR = new GlideRecord("sys_user");
	userGR.get(aUser);

	g_form.setValue("assigned_to", userGR, userGR.title);
}

 

I'm not saving this change after it's set, because I only want to change the display value for the user currently viewing the ticket. I also would like to prevent changing the Display property on the sys_user table, because I don't need this change reflected on any other sys_user reference field on other tables.

LouisG
Giga Guru

Alrighty so I figured this out. 

 

I edited the List Layout for the related Lists on the form, and dot.walked to Assigned to.Title field for all sys_user reference fields. 

 

For form fields, I access the context menu and went to Configure > Form Layout and dot.walked to sys_user.Title as well. Once all the adjustments were made, I exported to portrait PDF and all the Titles were exported on the doc instead of the employees names.