Adding a button next to field on form

codedude
Mega Expert

I am trying to add a button next to a field on a form in ServiceNow. I know you can add a button in the banner, list, etc, but I am wanting to add it to the form next to the field. I will show image below.

I want to add this button

button.PNG

Next to this field on the form, not in the banner like it currently is

field.PNG

6 REPLIES 6

Shane J
Tera Guru

I know this was 3 years ago now, but did you ever get this working?

Nevermind, I figured out after reviewing some existing UI Macros and kazidon's post.

 

Here my example for a MINUS button I've placed next to a custom Quantity field.

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="show_incidents_${jvar_guid}:${ref}"/>
	   <button id="${jvar_n}"
		   type="button"
		   aria-haspopup="true"
		   aria-label="${gs.getMessage('Remove 1 from Quantity')}"
		   onclick="consume_1('${ref}')"
		   name="${jvar_n}"
		   class="btn btn-ref btn-default icon-remove"
		   tabindex="$[jvar_ua_optional_tabindex]"
		   title="${gs.getMessage('Remove 1 from Quantity')}">
   </button>
	
<script>
function consume_1(reference) {
var qty = parseInt(g_form.getValue('u_quantity'));
var new_qty = qty - 1;
g_form.setValue('u_quantity', new_qty);
	}
</script>
</j:jelly>