{"id":21303,"date":"2023-02-16T10:43:29","date_gmt":"2023-02-16T09:43:29","guid":{"rendered":"https:\/\/help.openbee.com\/open-bee-scan-capture\/knowledge-base\/how-to-guides\/scripts-in-capture\/case-studies\/tricks\/tip-check-if-the-last-validated-job-from-capture-is-accepted-or-declined\/"},"modified":"2026-05-13T09:36:48","modified_gmt":"2026-05-13T07:36:48","slug":"tip-check-if-the-last-validated-job-from-capture-is-accepted-or-declined","status":"publish","type":"page","link":"https:\/\/help.openbee.com\/en\/open-bee-scan-capture\/knowledge-base\/how-to-guides\/scripts-in-capture\/case-studies\/tricks\/tip-check-if-the-last-validated-job-from-capture-is-accepted-or-declined\/","title":{"rendered":"Tip: Check if the last validated job from Capture is &#8220;Accepted&#8221; or &#8220;Declined&#8221;"},"content":{"rendered":"\n<p>Version 4.4.0<\/p>\n\n<pre class=\"wp-block-code\"><code>\nvar isLastDMSTaskValidatedOrRefused = function(ws)\n{\n\tvar res = ws.send(\"\/ws\/document\/\"+INTERNAL_DOCUMENT_ID, \"GET\", {\"Authorization\" : \"Bearer \"+ CAPTURE_WS_TOKEN});\n\tvar documentRaw = JSON.parse(res.StringResponse);\n\n\tvar lastDMSTaskValidated = null;\n\n\tif(documentRaw != null &amp;&amp; documentRaw.outputs != null)\n\t\t\n\tfor(var i=0;i&lt;documentRaw.outputs.length;i++)\n\t{\n\t\tvar docOutput = documentRaw.outputs&#91;i];\n\t\t\n\t\tif(docOutput.type == \"DocumentOutputDMS\" &amp;&amp; docOutput.taskValidations != null)\n\t\t{\n\t\t\tfor(var j=0;j&lt;docOutput.taskValidations.length;j++){\n\t\t\t\tif(lastDMSTaskValidated == null || lastDMSTaskValidated.date &lt; docOutput.taskValidations&#91;j].date)\n\t\t\t\t\tlastDMSTaskValidated = docOutput.taskValidations&#91;j];\n\t\t\t}\n\t\t}\n\t}\n\n\tif(lastDMSTaskValidated == null)\n\t\treturn \"No task\";\n\treturn lastDMSTaskValidated.validateTask ? \"Validated\" : \"Refused\";\n};\n\nvar ws = new JSE_WebService(\"127.0.0.1\", \"http\", 8090); \/\/ Serveur Capture\n\nreturn isLastDMSTaskValidatedOrRefused(ws);<\/code><\/pre>\n\n<p>Previous Versions<\/p>\n\n<pre class=\"wp-block-code\"><code>\nvar isLastDMSTaskValidatedOrRefused = function(ws)\n{\n\tvar res = ws.send(\"\/ws\/document\/\"+INTERNAL_DOCUMENT_ID, \"GET\", {\"Authorization\" : \"Bearer \"+ CAPTURE_WS_TOKEN});\n\tvar documentRaw = JSON.parse(res.StringResponse);\n\tvar docOutputDMS = documentRaw != null &amp;&amp; documentRaw.outputs != null ? documentRaw.outputs.DMS : null;\n\n\tvar lastDMSTaskValidated = null;\n\n\tif(docOutputDMS != null &amp;&amp; docOutputDMS.taskValidations != null)\n\t\tfor(var i=0;i&lt;docOutputDMS.taskValidations.length;i++){\n\t\t\tif(lastDMSTaskValidated == null || lastDMSTaskValidated.date &lt; docOutputDMS.taskValidations&#91;i].date)\n\t\t\t\tlastDMSTaskValidated = docOutputDMS.taskValidations&#91;i];\n\t\t}\n\n\tif(lastDMSTaskValidated == null)\n\t\treturn \"No task\";\n\treturn lastDMSTaskValidated.validateTask ? \"Validated\" : \"Refused\";\n};\n\nvar ws = new JSE_WebService(\"127.0.0.1\", \"http\", 8090); \/\/ Serveur Capture\n\nreturn isLastDMSTaskValidatedOrRefused(ws);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Version 4.4.0 Previous Versions<\/p>\n","protected":false},"author":96,"featured_media":0,"parent":21272,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"templates\/ob-help-products.php","meta":{"footnotes":""},"class_list":["post-21303","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/users\/96"}],"replies":[{"embeddable":true,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/comments?post=21303"}],"version-history":[{"count":1,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21303\/revisions"}],"predecessor-version":[{"id":21304,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21303\/revisions\/21304"}],"up":[{"embeddable":true,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21272"}],"wp:attachment":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/media?parent=21303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}