<?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: Update a string field on current table based on if value exists in a list field from another tab in Community Central forum</title>
    <link>https://www.servicenow.com/community/community-central-forum/update-a-string-field-on-current-table-based-on-if-value-exists/m-p/3107688#M1653</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/814267"&gt;@JO_JO&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 3 ways. Do this in table B. Query the table A (in below case problem).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Calculated type field (Field will be read-only)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Check the Calculated checkbox in string field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var arr = [];
var gr = new GlideRecord("problem");
gr.addQuery(&amp;lt;list type field name&amp;gt;, "IN", current.sys_id); // Use "CONTAINS" if "IN" doesn't work
gr.query();
while (gr.next()) {
    arr.push(gr.getValue('number').toString())
}

if (arr.length != 0)
    return arr.toString();
else
    return "";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Display BR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var arr = [];
var gr = new GlideRecord("problem");
gr.addQuery(&amp;lt;list type field name&amp;gt;, "IN", current.sys_id); // Use "CONTAINS" if "IN" doesn't work
gr.query();
while (gr.next()) {
    arr.push(gr.getValue('number').toString())
}
if(arr.length != 0)
    current.setValue(&amp;lt;table B field name&amp;gt;, arr.toString());
else
    current.setValue(&amp;lt;table B field name&amp;gt;,"");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) OnLoad CS with GlideAjax&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Use same code written in (2) but with Ajax Call.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;----&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Nov 2024 08:38:56 GMT</pubDate>
    <dc:creator>OmkarR485928563</dc:creator>
    <dc:date>2024-11-19T08:38:56Z</dc:date>
    <item>
      <title>Update a string field on current table based on if value exists in a list field from another table</title>
      <link>https://www.servicenow.com/community/community-central-forum/update-a-string-field-on-current-table-based-on-if-value-exists/m-p/3107352#M1651</link>
      <description>&lt;P&gt;New to ServiceNow platform so not sure if there is a methodology set in place for this. I have a list field in a form of table A, that can have one or more records selected from table B. Now on the form of table B, I want to add a string field that updates when the form loads with the name/number of the record in table A IF the current record in table B included in the list field. Else the default would be blank. Sorry if this is confusing, let me know if I need to elaborate.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 22:27:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/update-a-string-field-on-current-table-based-on-if-value-exists/m-p/3107352#M1651</guid>
      <dc:creator>JO_JO</dc:creator>
      <dc:date>2024-11-18T22:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Update a string field on current table based on if value exists in a list field from another tab</title>
      <link>https://www.servicenow.com/community/community-central-forum/update-a-string-field-on-current-table-based-on-if-value-exists/m-p/3107688#M1653</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/814267"&gt;@JO_JO&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 3 ways. Do this in table B. Query the table A (in below case problem).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Calculated type field (Field will be read-only)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Check the Calculated checkbox in string field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var arr = [];
var gr = new GlideRecord("problem");
gr.addQuery(&amp;lt;list type field name&amp;gt;, "IN", current.sys_id); // Use "CONTAINS" if "IN" doesn't work
gr.query();
while (gr.next()) {
    arr.push(gr.getValue('number').toString())
}

if (arr.length != 0)
    return arr.toString();
else
    return "";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Display BR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var arr = [];
var gr = new GlideRecord("problem");
gr.addQuery(&amp;lt;list type field name&amp;gt;, "IN", current.sys_id); // Use "CONTAINS" if "IN" doesn't work
gr.query();
while (gr.next()) {
    arr.push(gr.getValue('number').toString())
}
if(arr.length != 0)
    current.setValue(&amp;lt;table B field name&amp;gt;, arr.toString());
else
    current.setValue(&amp;lt;table B field name&amp;gt;,"");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) OnLoad CS with GlideAjax&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Use same code written in (2) but with Ajax Call.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;----&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 08:38:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/update-a-string-field-on-current-table-based-on-if-value-exists/m-p/3107688#M1653</guid>
      <dc:creator>OmkarR485928563</dc:creator>
      <dc:date>2024-11-19T08:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Update a string field on current table based on if value exists in a list field from another tab</title>
      <link>https://www.servicenow.com/community/community-central-forum/update-a-string-field-on-current-table-based-on-if-value-exists/m-p/3108295#M1663</link>
      <description>&lt;P&gt;Logic makes sense, but when I tried this the value did not populate to table B field.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 18:11:57 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/update-a-string-field-on-current-table-based-on-if-value-exists/m-p/3108295#M1663</guid>
      <dc:creator>JO_JO</dc:creator>
      <dc:date>2024-11-19T18:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Update a string field on current table based on if value exists in a list field from another tab</title>
      <link>https://www.servicenow.com/community/community-central-forum/update-a-string-field-on-current-table-based-on-if-value-exists/m-p/3109215#M1666</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/550442"&gt;@OmkarR485928563&lt;/a&gt;&amp;nbsp;Please ignore the previous replies, your solution works. I modified the solution to fit my reference field. One question I do have is how to update table B. Since script runs on display, when I do a search in table view on Table B, the field is not updated. Only when the form opens. Is there a way to save the change so that the table view of Table B will be updated with the new value&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 17:35:40 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/update-a-string-field-on-current-table-based-on-if-value-exists/m-p/3109215#M1666</guid>
      <dc:creator>JO_JO</dc:creator>
      <dc:date>2024-12-10T17:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Update a string field on current table based on if value exists in a list field from another tab</title>
      <link>https://www.servicenow.com/community/community-central-forum/update-a-string-field-on-current-table-based-on-if-value-exists/m-p/3125554#M1789</link>
      <description>&lt;P&gt;Modified the string field to be a reference field. This works, but slight issue. Since this business rule on Table B runs on Display, the data is never updated. So now when I am on table view on Table B, the field is still empty until I open the record. Is there a way to have the BR update this table so the changes are saved?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2024 18:18:10 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/update-a-string-field-on-current-table-based-on-if-value-exists/m-p/3125554#M1789</guid>
      <dc:creator>JO_JO</dc:creator>
      <dc:date>2024-12-11T18:18:10Z</dc:date>
    </item>
  </channel>
</rss>

