{"id":21344,"date":"2022-04-11T13:56:08","date_gmt":"2022-04-11T11:56:08","guid":{"rendered":"https:\/\/help.openbee.com\/open-bee-scan-capture\/knowledge-base\/how-to-guides\/scripts-in-capture\/case-studies\/index\/index-retrieve-a-value-from-the-file-name\/"},"modified":"2026-05-13T09:36:49","modified_gmt":"2026-05-13T07:36:49","slug":"index-retrieve-a-value-from-the-file-name","status":"publish","type":"page","link":"https:\/\/help.openbee.com\/en\/open-bee-scan-capture\/knowledge-base\/how-to-guides\/scripts-in-capture\/case-studies\/index\/index-retrieve-a-value-from-the-file-name\/","title":{"rendered":"Index: Retrieve a value from the file name"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\" id=\"Index:R&#xE9;cup&#xE9;rerunevaleurdepuislenomdufichier-G&#xE9;n&#xE9;ral\">General<\/h1>\n\n<p>Our file is named TEST_005.pdf, our goal is to retrieve the value 005 which corresponds to our invoice number<\/p>\n\n<h1 class=\"wp-block-heading\" id=\"Index:R&#xE9;cup&#xE9;rerunevaleurdepuislenomdufichier-Script\">Script<\/h1>\n\n<pre class=\"wp-block-code\"><code>var ws = new JSE_WebService(\"127.0.0.1\", \"http\", 8090);\nvar res = ws.send(\"\/ws\/document\/\"+INTERNAL_DOCUMENT_ID, \"GET\", {\"Authorization\" : \"Bearer \"+ CAPTURE_WS_TOKEN});\nvar docName = JSON.parse(res.StringResponse).filename;\nif(docName != null){\n    var nameWithoutExt = docName.split(\".\");\n     \n    if(nameWithoutExt.length > 0){\n        var values = nameWithoutExt&#91;0].split(\"_\");\n     \n        if(values.length > 1)\n            return values&#91;1];\n    }\n}\n \nreturn \"\";<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>General Our file is named TEST_005.pdf, our goal is to retrieve the value 005 which corresponds to our invoice number Script<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":21276,"menu_order":4,"comment_status":"closed","ping_status":"closed","template":"templates\/ob-help-products.php","meta":{"footnotes":""},"class_list":["post-21344","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21344","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/comments?post=21344"}],"version-history":[{"count":1,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21344\/revisions"}],"predecessor-version":[{"id":21346,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21344\/revisions\/21346"}],"up":[{"embeddable":true,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21276"}],"wp:attachment":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/media?parent=21344"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}