<?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: UI action condition with script include in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/ui-action-condition-with-script-include/m-p/2812321#M1079367</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/329477"&gt;@asd22&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Your script include contains only initialize function&amp;nbsp;&lt;SPAN&gt;and no other methods, it won't be very useful for conditions in a UI Action.&amp;nbsp;You need to add a method to your Script Include that contains the logic for your condition and returns a boolean value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's how you can modify your Script Include to include a method for your condition:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var conditions_hidestudbutton = Class.create();
conditions_hidestudbutton.prototype = {
    initialize: function() {
    // Initialization code, if necessary
    },

    shouldDisplayButton: function() {
        // Your conditions logic here
        // Return true to display the button, false to hide it
        return true; // or false based on your conditions
    },

    type: 'conditions_hidestudbutton'
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the example above, I've added a&amp;nbsp;&lt;STRONG&gt;shouldDisplayButton&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;method that contains the logic for determining whether the UI Action should be displayed.&lt;BR /&gt;&lt;BR /&gt;Once you have your Script Include set up with the new method, you can call it in the condition field of your UI Action like this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;new conditions_hidestudbutton().shouldDisplayButton();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This line will instantiate your&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;conditions_hidestudbutton&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;class&lt;/STRONG&gt; and call the&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;shouldDisplayButton&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;method. The UI Action will then use the boolean value returned by this method to determine whether to display the UI Action.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Remember to make sure that your Script Include is marked as&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;Client Callable&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if you are using it in a client-side context. If your condition logic needs to run on the server side, you should not use a Script Include in the condition field of a UI Action; instead, you would handle the logic within the server-side script portion of the UI Action.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;I&gt;Please mark this response as correct or helpful if it assisted you with your question.&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Feb 2024 18:15:02 GMT</pubDate>
    <dc:creator>Iraj Shaikh</dc:creator>
    <dc:date>2024-02-01T18:15:02Z</dc:date>
    <item>
      <title>UI action condition with script include</title>
      <link>https://www.servicenow.com/community/developer-forum/ui-action-condition-with-script-include/m-p/2812026#M1079296</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a UI action where the condition is a script include, and its not working.&lt;/P&gt;&lt;P&gt;Here is how i did the ui action condition:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="asd22_0-1706799467297.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/326090i2E7FB5B6F0062BCF/image-size/medium?v=v2&amp;amp;px=400" srcset="/community/image/serverpage/image-id/326090i2E7FB5B6F0062BCF/image-size/medium?v=v2&amp;amp;px=400 1.0x" role="button" title="asd22_0-1706799467297.png" alt="asd22_0-1706799467297.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and here is the script include:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="asd22_2-1706799515157.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/326093i3FB3F8474EB7EB0B/image-size/medium?v=v2&amp;amp;px=400" srcset="/community/image/serverpage/image-id/326093i3FB3F8474EB7EB0B/image-size/medium?v=v2&amp;amp;px=400 1.0x, /community/image/serverpage/image-id/326093i3FB3F8474EB7EB0B/image-dimensions/800x441?v=v2 2.0x" role="button" title="asd22_2-1706799515157.png" alt="asd22_2-1706799515157.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 14:58:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/ui-action-condition-with-script-include/m-p/2812026#M1079296</guid>
      <dc:creator>asd22</dc:creator>
      <dc:date>2024-02-01T14:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: UI action condition with script include</title>
      <link>https://www.servicenow.com/community/developer-forum/ui-action-condition-with-script-include/m-p/2812321#M1079367</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/329477"&gt;@asd22&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Your script include contains only initialize function&amp;nbsp;&lt;SPAN&gt;and no other methods, it won't be very useful for conditions in a UI Action.&amp;nbsp;You need to add a method to your Script Include that contains the logic for your condition and returns a boolean value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's how you can modify your Script Include to include a method for your condition:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var conditions_hidestudbutton = Class.create();
conditions_hidestudbutton.prototype = {
    initialize: function() {
    // Initialization code, if necessary
    },

    shouldDisplayButton: function() {
        // Your conditions logic here
        // Return true to display the button, false to hide it
        return true; // or false based on your conditions
    },

    type: 'conditions_hidestudbutton'
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the example above, I've added a&amp;nbsp;&lt;STRONG&gt;shouldDisplayButton&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;method that contains the logic for determining whether the UI Action should be displayed.&lt;BR /&gt;&lt;BR /&gt;Once you have your Script Include set up with the new method, you can call it in the condition field of your UI Action like this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;new conditions_hidestudbutton().shouldDisplayButton();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This line will instantiate your&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;conditions_hidestudbutton&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;class&lt;/STRONG&gt; and call the&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;shouldDisplayButton&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;method. The UI Action will then use the boolean value returned by this method to determine whether to display the UI Action.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Remember to make sure that your Script Include is marked as&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;Client Callable&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if you are using it in a client-side context. If your condition logic needs to run on the server side, you should not use a Script Include in the condition field of a UI Action; instead, you would handle the logic within the server-side script portion of the UI Action.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;&lt;I&gt;Please mark this response as correct or helpful if it assisted you with your question.&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 18:15:02 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/ui-action-condition-with-script-include/m-p/2812321#M1079367</guid>
      <dc:creator>Iraj Shaikh</dc:creator>
      <dc:date>2024-02-01T18:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: UI action condition with script include</title>
      <link>https://www.servicenow.com/community/developer-forum/ui-action-condition-with-script-include/m-p/2813203#M1079582</link>
      <description>&lt;P&gt;Hello sorry for the late respond, i tried this but i have some issues with the button not showing up at all now&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 11:00:30 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/ui-action-condition-with-script-include/m-p/2813203#M1079582</guid>
      <dc:creator>asd22</dc:creator>
      <dc:date>2024-02-02T11:00:30Z</dc:date>
    </item>
  </channel>
</rss>

