<?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>topic Re: waitForJobCompletion not executing in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/waitforjobcompletion-not-executing/m-p/1276687#M80806</link>
    <description>&lt;P&gt;Mistake of my own making, changed the lines to&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;          jobInfo.waitForJobCompletion(options).then(() =&amp;gt; {
		  jobInfo.fetchResultData('outfile').then(function(result){
		  outputFileUrl = result.value.url;
		  window.open(outputFileUrl, "_blank");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and it works as planned. Thanks to everyone who took a look!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Apr 2023 19:22:29 GMT</pubDate>
    <dc:creator>JasonJordan00</dc:creator>
    <dc:date>2023-04-07T19:22:29Z</dc:date>
    <item>
      <title>waitForJobCompletion not executing</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/waitforjobcompletion-not-executing/m-p/1276638#M80801</link>
      <description>&lt;P&gt;Hi all, I've been working on a GP tool that will take a record and print out a PDF report on it. I'm trying to use some Javascript within an HTML embed to call the tool when a link is clicked. It will generate the report, check when the job is completed, then open the URL to the PDf in a new tab.&lt;/P&gt;&lt;P&gt;Its 99% working, and I can see the server generate the report in the log and can follow the Job ID and open the PDF on my own, however JobInfo in the code never seems to return a completed status to open it up in a tab. I can see it checking the status every 1.5 seconds in the server log though. Any ideas why lines 30-32 just won't go anywhere?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="utf-8"&amp;gt;
  &amp;lt;title&amp;gt;Print Abstract of Bids&amp;lt;/title&amp;gt;
  &amp;lt;script src="https://js.arcgis.com/4.20/"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;script&amp;gt;
    function executeGeoprocessing() {
      var outputFileUrl;
      var params = {};
      params.contract = "10-100"; //sample record, change to variable on embed
      const url = "https://xxxxxxxx/xxxxxx/rest/services/PrepareAbstractOfBids/GPServer/Prepare%20Abstract%20of%20Bids";

      require([
        "esri/tasks/Geoprocessor",
        "esri/rest/support/JobInfo"
      ], function(Geoprocessor, JobInfo) {
        var gp = new Geoprocessor(url);
        gp.submitJob(params).then((jobInfo) =&amp;gt; {
          const jobid = jobInfo.jobId;
          console.log("ArcGIS Server job ID: ", jobid);

          const options = {
            interval: 1500,
            statusCallback: (j) =&amp;gt; {
              console.log("Job Status: ", j.jobStatus);
            }
          };

          jobInfo.waitForJobCompletion(options).then(() =&amp;gt; {
            outputFileUrl = jobInfo.jobOutputInfo[0].value.url;
            window.open(outputFileUrl, "_blank");
          });
        });
      });
    }

    document.addEventListener("DOMContentLoaded", function(event) {
      var link = document.getElementById("print-abstract-link");
      link.addEventListener("click", function(event) {
        event.preventDefault();
        executeGeoprocessing();
      });
    });
  &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;p&amp;gt;&amp;lt;a href="#" id="print-abstract-link"&amp;gt;Print Abstract&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 17:05:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/waitforjobcompletion-not-executing/m-p/1276638#M80801</guid>
      <dc:creator>JasonJordan00</dc:creator>
      <dc:date>2023-04-07T17:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: waitForJobCompletion not executing</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/waitforjobcompletion-not-executing/m-p/1276687#M80806</link>
      <description>&lt;P&gt;Mistake of my own making, changed the lines to&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;          jobInfo.waitForJobCompletion(options).then(() =&amp;gt; {
		  jobInfo.fetchResultData('outfile').then(function(result){
		  outputFileUrl = result.value.url;
		  window.open(outputFileUrl, "_blank");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and it works as planned. Thanks to everyone who took a look!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 19:22:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/waitforjobcompletion-not-executing/m-p/1276687#M80806</guid>
      <dc:creator>JasonJordan00</dc:creator>
      <dc:date>2023-04-07T19:22:29Z</dc:date>
    </item>
  </channel>
</rss>

