The CreatorCon Call for Content is officially open! Get started here.

How to Change the Display Value Based on the View in a ServiceNow Portal Form?

E555
Tera Guru

In a ServiceNow portal form, I am displaying a form with a specific view. I would like to change the Display Value dynamically based on the view.

 

I tried using an onLoad Client Script I was able to get the view from the URL, but I couldn't set the Display Value.

 

function onLoad() {  
	var url = top.location.href;
    var value = new URLSearchParams (url) .get ("view");

    if (value === "a_userportallist") {
		var username= g_form.getValue('u_username');
        g_form.setValue('display_value_field', username);
    }
}

 

Is it possible to change the Display Value depending on the view? If so, what would be the best approach?

Thank you!

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@E555 

are you referring to setting display value of reference field/variable?

if yes then it's not possible as it comes from Dictionary and is shown for the field which is marked as Display=true on that table

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you for the reply.
It is a String Value, not a Reference. In the current Default View, A (String Type) is the Display Value, but I would like to set the other B (String Type) to Display Value in the newly created Custom View.

@E555  @tanuk 

Didn't get this sentence -> In the current Default View, A (String Type) is the Display Value, but I would like to set the other B (String Type) to Display Value in the newly created Custom View

Please explain with screenshots.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader