<?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 How do you run the client side AND the server side in UI Action page in Community Central forum</title>
    <link>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3123592#M1775</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi all,&lt;BR /&gt;I’m currently working on a UI Action where I need to execute both server-side &lt;EM&gt;&lt;STRONG&gt;and&lt;/STRONG&gt; &lt;/EM&gt;client-side logic when the user submits a record. Specifically on the Client side, I want to make the record "read-only" once it has been selected and submitted from the table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;However, I’m encountering an issue with the 'Client = true' configuration. It’s throwing errors, and I’m unsure if there’s something I need to adjust in the &lt;STRONG&gt;OnClick&lt;/STRONG&gt; field or the &lt;STRONG&gt;Workspace Client Script&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;I tried renaming the field to match the client script and the &lt;STRONG&gt;OnClick&lt;/STRONG&gt; field, but that led to additional issues. Could anyone please advise on the best approach to resolve this and ensure both server-side and client-side code run correctly?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for your help!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Dec 2024 00:58:23 GMT</pubDate>
    <dc:creator>schoi</dc:creator>
    <dc:date>2024-12-10T00:58:23Z</dc:date>
    <item>
      <title>How do you run the client side AND the server side in UI Action page</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3123592#M1775</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi all,&lt;BR /&gt;I’m currently working on a UI Action where I need to execute both server-side &lt;EM&gt;&lt;STRONG&gt;and&lt;/STRONG&gt; &lt;/EM&gt;client-side logic when the user submits a record. Specifically on the Client side, I want to make the record "read-only" once it has been selected and submitted from the table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;However, I’m encountering an issue with the 'Client = true' configuration. It’s throwing errors, and I’m unsure if there’s something I need to adjust in the &lt;STRONG&gt;OnClick&lt;/STRONG&gt; field or the &lt;STRONG&gt;Workspace Client Script&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;I tried renaming the field to match the client script and the &lt;STRONG&gt;OnClick&lt;/STRONG&gt; field, but that led to additional issues. Could anyone please advise on the best approach to resolve this and ensure both server-side and client-side code run correctly?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for your help!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 00:58:23 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3123592#M1775</guid>
      <dc:creator>schoi</dc:creator>
      <dc:date>2024-12-10T00:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do you run the client side AND the server side in UI Action page</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3123629#M1777</link>
      <description>&lt;P&gt;Perhaps understanding the parts a little better will help.&lt;/P&gt;&lt;P&gt;Action name is the name of your action. It is not what action will happen. It is specific to &lt;STRONG&gt;your action&lt;/STRONG&gt;. If you want to use&amp;nbsp;gsftSubmit(null, g_form.getFormElement(), 'your_action_name_here'); you have to use whatever you put in as your action name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Onclick is the function that is called when you click on the UI Action. I would avoid using overly common function names such as onClick or onSubmit but instead use something more relevant to what your action is doing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the function that will be called in the Script when you click the UI Action on the Client Side.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you will need another function for Server Side. This is called by&amp;nbsp;&lt;/P&gt;&lt;P&gt;if (typeof window == 'undefined') nameYourServerSideFunctionHere();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally, make sure that both your functions are in your script!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I like to see how things are connected, so I'm including a screenshot of an OotB UI Action that perfectly demonstrates this and I've color coded which parts are connected.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AJM_0-1733799509013.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/406791i161798479788D58A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AJM_0-1733799509013.png" alt="AJM_0-1733799509013.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Official Documentation here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.servicenow.com/docs/bundle/xanadu-api-reference/page/script/useful-scripts/reference/using-client-server-code-ui-action.html" target="_blank"&gt;Using client and server code in a UI action&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 02:59:34 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3123629#M1777</guid>
      <dc:creator>AJ M</dc:creator>
      <dc:date>2024-12-10T02:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do you run the client side AND the server side in UI Action page</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3124305#M1780</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks for your reply and for color coordinating everything! I tried adding `setRowReadOnly()` under the `onclick` function, but I’m getting a “g_form is not defined” error. When I try to pass 'g_form' as a parameter, I get an error saying that 'g_form' is undefined. How did you get the code above to work?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 16:04:57 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3124305#M1780</guid>
      <dc:creator>schoi</dc:creator>
      <dc:date>2024-12-10T16:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do you run the client side AND the server side in UI Action page</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3124586#M1782</link>
      <description>&lt;P&gt;Did you check the "Client" checkbox? Is the g_form being used in the function that you listed in the onClick field?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 21:35:06 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3124586#M1782</guid>
      <dc:creator>AJ M</dc:creator>
      <dc:date>2024-12-10T21:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do you run the client side AND the server side in UI Action page</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3124625#M1783</link>
      <description>&lt;P&gt;Yes, below attachment is what I have. I have also tried passing in g_form and it was erroring out saying- g_form is undefined&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 22:38:27 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3124625#M1783</guid>
      <dc:creator>schoi</dc:creator>
      <dc:date>2024-12-10T22:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do you run the client side AND the server side in UI Action page</title>
      <link>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3124638#M1784</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot replicate this on my PDI. The form behaves as expected with the UI Action.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;Something just clicked into place. You have List banner button and List bottom button selected and the name of your function is setRowReadOnly. Are you trying to use g_form in List view?&amp;nbsp;&lt;/P&gt;&lt;P&gt;If so, this is not something that can be done. When you manipulate a record in List View, there's very little UI to look at. UI Policies and Client Scripts also do not work in List View.&lt;/P&gt;&lt;P&gt;The workaround would be to create Data Policies or Security Rules to make the record Read Only.&lt;/P&gt;&lt;P&gt;Is this what you are trying to do?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 23:13:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/how-do-you-run-the-client-side-and-the-server-side-in-ui-action/m-p/3124638#M1784</guid>
      <dc:creator>AJ M</dc:creator>
      <dc:date>2024-12-10T23:13:12Z</dc:date>
    </item>
  </channel>
</rss>

