<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Adding a button next to field on form in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016865#M673791</link>
    <description>&lt;P&gt;I know this is older but I was trying to do this and found a pretty good solution. What I ended up doing is creating a UI Macro, then referencing that UI Macro in the field attributes. In the UI macro I had that reference a UI page and was able to write my code there using html, client scripts... etc..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is my UI macro code&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;
&amp;lt;j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"&amp;gt;
&amp;lt;g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" /&amp;gt;
&amp;lt;j:set var="jvar_n" value="show_incidents_${jvar_guid}:${ref}"/&amp;gt;
&amp;lt;g:reference_decoration id="${jvar_n}" field="${ref}" 
  onclick="cancelITRecord('${ref}'); "
  title="${gs.getMessage('Cancel IT Record')}" image="images/icons/tasks.gifx" icon="icon-workflow-rejected" /&amp;gt;

&amp;lt;script&amp;gt;

function cancelITRecord(reference) {
	
  	var w = new GlideDialogWindow('cancel_it_offboarding_record'); //This is the name of the UI page I created.
  	w.setTitle("");
  	w.render();
}

&amp;lt;/script&amp;gt;
&amp;lt;/j:jelly&amp;gt; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;this is what I put next to the field to reference the UI macro. right click on field and go to dictionary&amp;nbsp;click on advanced view under related links and put this in Attributes&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;ref_contributions=cancel_it_record&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cancel_it_record is the name of the UI Macro above, replace it with the name of your UI Macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;create your UI page add HTML and client scripts and processing scripts and your done!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Jan 2019 18:01:43 GMT</pubDate>
    <dc:creator>kazidon</dc:creator>
    <dc:date>2019-01-03T18:01:43Z</dc:date>
    <item>
      <title>Adding a button next to field on form</title>
      <link>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016861#M673787</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I want to add this button &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="button.PNG"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/59536i08F0BB0EBC107CEF/image-size/large?v=v2&amp;amp;px=999" srcset="/community/image/serverpage/image-id/59536i08F0BB0EBC107CEF/image-size/large?v=v2&amp;amp;px=999 1.0x" role="button" title="button.PNG" alt="button.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Next to this field on the form, not in the banner like it currently is&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="field.PNG"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/59530iCAF05DFA5C75546B/image-size/large?v=v2&amp;amp;px=999" srcset="/community/image/serverpage/image-id/59530iCAF05DFA5C75546B/image-size/large?v=v2&amp;amp;px=999 1.0x" role="button" title="field.PNG" alt="field.PNG" /&gt;&lt;/span&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 17:25:38 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016861#M673787</guid>
      <dc:creator>codedude</dc:creator>
      <dc:date>2016-07-19T17:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a button next to field on form</title>
      <link>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016862#M673788</link>
      <description>&lt;P&gt;Sounds like you need a UI Macro.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Wiki documentation: &lt;A href="http://wiki.servicenow.com/index.php?title=UI_Macros#gsc.tab=0" title="http://wiki.servicenow.com/index.php?title=UI_Macros#gsc.tab=0"&gt;UI Macros - ServiceNow Wiki&lt;/A&gt; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Examples of UI Macros: &lt;A href="http://www.servicenowguru.com/tag/ui-macros/" title="http://www.servicenowguru.com/tag/ui-macros/"&gt;UI macros Archives - ServiceNow Guru&lt;/A&gt; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;You should be able to use the examples on the second link to build exactly what you're trying to do. &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Jul 2016 17:34:20 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016862#M673788</guid>
      <dc:creator>Tim Deniston</dc:creator>
      <dc:date>2016-07-19T17:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a button next to field on form</title>
      <link>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016863#M673789</link>
      <description>&lt;P&gt;Hi Josh,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;You may find below blog helpful.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;A href="http://www.servicenowguru.com/topics/system-ui/ui-macros/" title="http://www.servicenowguru.com/topics/system-ui/ui-macros/"&gt;UI macros Archives - ServiceNow Guru&lt;/A&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;A href="http://www.servicenowguru.com/system-ui/ui-macros/add-me-ui-macro-user-group-fields/" title="http://www.servicenowguru.com/system-ui/ui-macros/add-me-ui-macro-user-group-fields/"&gt;'Add Me' UI macro for User and Group Fields - ServiceNow Guru&lt;/A&gt; &amp;nbsp; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;A href="http://www.servicenowguru.com/system-ui/ui-macros/add-macro-non-reference-field/" title="http://www.servicenowguru.com/system-ui/ui-macros/add-macro-non-reference-field/"&gt;Adding a UI Macro to a Non-reference Field - ServiceNow Guru&lt;/A&gt; &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Jul 2016 18:05:00 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016863#M673789</guid>
      <dc:creator>Pradeep Sharma</dc:creator>
      <dc:date>2016-07-19T18:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a button next to field on form</title>
      <link>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016864#M673790</link>
      <description>&lt;P&gt;Please help on this Pradeep: &lt;A title="How to set the image icon beside priority field?" __default_attr="1337832" __jive_macro_name="message" class="jive_macro jive_macro_message" data-orig-content="How to set the image icon beside priority field?" data-renderedposition="10_190.890625_308_16" href="https://www.servicenow.com/community?id=community_question&amp;amp;sys_id=846ff2a9db58dbc01dcaf3231f961993"&gt;How to set the image icon beside priority field?&lt;/A&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Feb 2018 11:31:20 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016864#M673790</guid>
      <dc:creator>prasannakumard</dc:creator>
      <dc:date>2018-02-02T11:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a button next to field on form</title>
      <link>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016865#M673791</link>
      <description>&lt;P&gt;I know this is older but I was trying to do this and found a pretty good solution. What I ended up doing is creating a UI Macro, then referencing that UI Macro in the field attributes. In the UI macro I had that reference a UI page and was able to write my code there using html, client scripts... etc..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is my UI macro code&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;
&amp;lt;j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"&amp;gt;
&amp;lt;g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" /&amp;gt;
&amp;lt;j:set var="jvar_n" value="show_incidents_${jvar_guid}:${ref}"/&amp;gt;
&amp;lt;g:reference_decoration id="${jvar_n}" field="${ref}" 
  onclick="cancelITRecord('${ref}'); "
  title="${gs.getMessage('Cancel IT Record')}" image="images/icons/tasks.gifx" icon="icon-workflow-rejected" /&amp;gt;

&amp;lt;script&amp;gt;

function cancelITRecord(reference) {
	
  	var w = new GlideDialogWindow('cancel_it_offboarding_record'); //This is the name of the UI page I created.
  	w.setTitle("");
  	w.render();
}

&amp;lt;/script&amp;gt;
&amp;lt;/j:jelly&amp;gt; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;this is what I put next to the field to reference the UI macro. right click on field and go to dictionary&amp;nbsp;click on advanced view under related links and put this in Attributes&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;ref_contributions=cancel_it_record&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cancel_it_record is the name of the UI Macro above, replace it with the name of your UI Macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;create your UI page add HTML and client scripts and processing scripts and your done!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jan 2019 18:01:43 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016865#M673791</guid>
      <dc:creator>kazidon</dc:creator>
      <dc:date>2019-01-03T18:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a button next to field on form</title>
      <link>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016866#M673792</link>
      <description>&lt;P&gt;I know this was 3 years ago now, but did you ever get this working?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2019 12:36:50 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016866#M673792</guid>
      <dc:creator>Shane J</dc:creator>
      <dc:date>2019-09-09T12:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a button next to field on form</title>
      <link>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016867#M673793</link>
      <description>&lt;P&gt;Nevermind, I figured out after reviewing some existing UI Macros and kazidon's post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here my example for a MINUS button I've placed next to a custom Quantity field.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;
&amp;lt;j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"&amp;gt;
&amp;lt;g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" /&amp;gt;
&amp;lt;j:set var="jvar_n" value="show_incidents_${jvar_guid}:${ref}"/&amp;gt;
	   &amp;lt;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')}"&amp;gt;
   &amp;lt;/button&amp;gt;
	
&amp;lt;script&amp;gt;
function consume_1(reference) {
var qty = parseInt(g_form.getValue('u_quantity'));
var new_qty = qty - 1;
g_form.setValue('u_quantity', new_qty);
	}
&amp;lt;/script&amp;gt;
&amp;lt;/j:jelly&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Sep 2019 13:48:07 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/adding-a-button-next-to-field-on-form/m-p/2016867#M673793</guid>
      <dc:creator>Shane J</dc:creator>
      <dc:date>2019-09-09T13:48:07Z</dc:date>
    </item>
  </channel>
</rss>

