UI Action pulls the wrong field?

JP-ODU
Tera Guru

I've been trying to use this script for a UI Action button that will pre-fill additional comments with a salutation and sign-off. The trouble is, what seems to very clearly say caller ID to me in the script keeps pasting incident Number into that space of additional comments, instead?

 

What am I missing?

 

 

function writeComment(){
	var message = "Dear " + g_form.getDisplayValue("caller_id") + ", <insert comments here>\n\n\n" + " Best regards, " + g_user.getUserName();
	g_form.setValue("comments", message);
	g_form.getControl("comments").focus();
}

 

 

Yields:

additional comments.png

1 ACCEPTED SOLUTION

Voona Rohila
Kilo Patron
Kilo Patron

Hi @JP-ODU 

Use g_form.getDisplayBox('caller_id').value; Instead of g_form.getDisplayValue("caller_id");

 

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_referenc...

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

1 REPLY 1

Voona Rohila
Kilo Patron
Kilo Patron

Hi @JP-ODU 

Use g_form.getDisplayBox('caller_id').value; Instead of g_form.getDisplayValue("caller_id");

 

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_referenc...

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP