Adding a button next to field on form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2016 10:25 AM
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
Next to this field on the form, not in the banner like it currently is
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2019 05:36 AM
I know this was 3 years ago now, but did you ever get this working?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2019 06:48 AM
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>