<?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 Rest call occurring twice during single update. in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812091#M469017</link>
    <description>&lt;P&gt;Hi all!&lt;/P&gt;
&lt;P&gt;I am updating single record in a single time but the api is hitting twice.&lt;/P&gt;
&lt;P&gt;Description :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created import set row table u_abc for targeting incident table using "number" and "work_notes" field. The table u_xyz have u_id and u_work_notes. Whenever I update those two field, Before business rule will run and call rest message to insert record in&amp;nbsp;&amp;nbsp;u_abc and finally update the incident record via transform mapping.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Issue :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now the issue is, execution happening twice during every single update. Two times inserting in import table u_abc, at the same time two times updating incident table also&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/47192i99C3D8D4DB9EEE1D/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;This is my BR:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;Table : u_xyz&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;When : Before Update&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;Order : 13,500&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;Script :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;(function executeRule(current, previous /*null when async*/) {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;// Add your code here&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; gs.log("rest details"+current.u_id + current.u_work_notes);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; var request = new sn_ws.RESTMessageV2("ServiceNow sample", "update comments");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; request.setStringParameterNoEscape("number", current.u_id);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; request.setStringParameterNoEscape("notes", current.u_work_notes);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; request.execute();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; var response = request.execute();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; var requestBody = request.getRequestBody();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; var responseBody = response.getBody();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; var httpStatus = response.getStatusCode();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; gs.log("response_incident" + httpStatus + responseBody );&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;})(current, previous);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;This is my Rest message :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Using import API&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;{"u_number":"${number}","u_work_notes":"${notes}"}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Can anyone help?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 09:38:53 GMT</pubDate>
    <dc:creator>Fathima6</dc:creator>
    <dc:date>2020-09-28T09:38:53Z</dc:date>
    <item>
      <title>Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812091#M469017</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;
&lt;P&gt;I am updating single record in a single time but the api is hitting twice.&lt;/P&gt;
&lt;P&gt;Description :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created import set row table u_abc for targeting incident table using "number" and "work_notes" field. The table u_xyz have u_id and u_work_notes. Whenever I update those two field, Before business rule will run and call rest message to insert record in&amp;nbsp;&amp;nbsp;u_abc and finally update the incident record via transform mapping.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Issue :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now the issue is, execution happening twice during every single update. Two times inserting in import table u_abc, at the same time two times updating incident table also&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/47192i99C3D8D4DB9EEE1D/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;This is my BR:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;Table : u_xyz&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;When : Before Update&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;Order : 13,500&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;Script :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;(function executeRule(current, previous /*null when async*/) {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;// Add your code here&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; gs.log("rest details"+current.u_id + current.u_work_notes);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; var request = new sn_ws.RESTMessageV2("ServiceNow sample", "update comments");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; request.setStringParameterNoEscape("number", current.u_id);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; request.setStringParameterNoEscape("notes", current.u_work_notes);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; request.execute();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; var response = request.execute();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; var requestBody = request.getRequestBody();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; var responseBody = response.getBody();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; var httpStatus = response.getStatusCode();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; gs.log("response_incident" + httpStatus + responseBody );&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;})(current, previous);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;This is my Rest message :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Using import API&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;{"u_number":"${number}","u_work_notes":"${notes}"}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Can anyone help?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:38:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812091#M469017</guid>
      <dc:creator>Fathima6</dc:creator>
      <dc:date>2020-09-28T09:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812092#M469018</link>
      <description>&lt;P&gt;Is only update checked in business rule or both? Just have insert/update checked and see if it resolves?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/47194iCA01DAD6BF3CB1B8/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Please Mark as &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; Correct if this solves your issue and also mark ???? Helpful if it helps resolve your problem.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Saji&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:50:13 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812092#M469018</guid>
      <dc:creator>Sajilal</dc:creator>
      <dc:date>2020-09-28T09:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812093#M469019</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;it is recommended to call the Rest Message in &lt;STRONG&gt;After&lt;/STRONG&gt; or &lt;STRONG&gt;Async&lt;/STRONG&gt; business rule and not in the before business rule&lt;/P&gt;
&lt;P&gt;Please make the BR as &lt;STRONG&gt;After &lt;/STRONG&gt;and test once&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:53:21 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812093#M469019</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-09-28T09:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812094#M469020</link>
      <description>&lt;P&gt;No Its not working. If I changed to after or async , then records getting inserted in u_abc import set table but its not updating in incident table.&lt;/P&gt;
&lt;P&gt;fyr this is my endpoint :&amp;nbsp;https://xyz.service-now.com/api/now/import/u_abc&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:27:57 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812094#M469020</guid>
      <dc:creator>Fathima6</dc:creator>
      <dc:date>2020-09-28T11:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812095#M469021</link>
      <description>&lt;P&gt;only update&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:28:25 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812095#M469021</guid>
      <dc:creator>Fathima6</dc:creator>
      <dc:date>2020-09-28T11:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812096#M469022</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;the ideal way to handle this is via After BR.&lt;/P&gt;
&lt;P&gt;Can you explain below questions?&lt;/P&gt;
&lt;P&gt;1) You are using BR on incident table in instance A&lt;/P&gt;
&lt;P&gt;2) Which instance endpoint is being consumed in the Rest Message? is it the same instance or another instance&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:53:20 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812096#M469022</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-09-28T11:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812097#M469023</link>
      <description>&lt;P&gt;I see a comment in your Description "and finally update the incident record via transform mapping. " maybe can you not do this and see if system updates the record by backend only?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Saji&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:56:59 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812097#M469023</guid>
      <dc:creator>Sajilal</dc:creator>
      <dc:date>2020-09-28T11:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812098#M469024</link>
      <description>&lt;P&gt;same instance&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:23:11 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812098#M469024</guid>
      <dc:creator>Fathima6</dc:creator>
      <dc:date>2020-09-28T12:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812099#M469025</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;so possibly the BR is triggering 2 times&lt;/P&gt;
&lt;P&gt;please add this condition in the BR and check once&lt;/P&gt;
&lt;P&gt;gs.getSession().isInteractive()&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:29:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812099#M469025</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-09-28T12:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812100#M469026</link>
      <description>&lt;P&gt;even not using business rule, and trying via widget also calling twice&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:57:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812100#M469026</guid>
      <dc:creator>Fathima6</dc:creator>
      <dc:date>2020-09-28T12:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812101#M469027</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;you have BR configured for triggering the REST Message so please add the condition in the BR&lt;/P&gt;
&lt;P&gt;gs.getSession().isInteractive()&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:01:09 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812101#M469027</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-09-28T13:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812102#M469028</link>
      <description>&lt;P&gt;still getting twice&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:05:10 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812102#M469028</guid>
      <dc:creator>Fathima6</dc:creator>
      <dc:date>2020-09-28T13:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812103#M469029</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;few things to check&lt;/P&gt;
&lt;P&gt;1) why are you consuming same instance endpoint in the same instance&lt;/P&gt;
&lt;P&gt;Regards&lt;BR /&gt;Ankur&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:10:10 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812103#M469029</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2020-09-28T13:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Rest call occurring twice during single update.</title>
      <link>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812104#M469030</link>
      <description>&lt;P&gt;Actually two api calls generating to the third party end user side so I can't able to check in their end so calling my instance instead, therefor found two calls generating.&lt;/P&gt;
&lt;P&gt;now wondering that , I called the same endpoint with the same parameters via postman, its hitting once . Again checking the same via widget by calling rest message its failing. Now I deactivated all BR in the particular table and trying via widget using the below code during button click&lt;/P&gt;
&lt;P&gt;var request = new sn_ws.RESTMessageV2("ServiceNow sample", "update_comments");&lt;BR /&gt; request.setStringParameterNoEscape("number", orde.u_id);&lt;BR /&gt; request.setStringParameterNoEscape("notes", comments);&lt;BR /&gt; request.execute();&lt;BR /&gt; gs.log("rest details"+orde.u_id + comments);&lt;BR /&gt; var response = request.execute();&lt;BR /&gt; var requestBody = request.getRequestBody();&lt;BR /&gt; var responseBody = response.getBody();&lt;BR /&gt; var httpStatus = response.getStatusCode();&lt;BR /&gt; gs.log("response_incident" + httpStatus + responseBody );&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:26:45 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/rest-call-occurring-twice-during-single-update/m-p/1812104#M469030</guid>
      <dc:creator>Fathima6</dc:creator>
      <dc:date>2020-09-28T13:26:45Z</dc:date>
    </item>
  </channel>
</rss>

