{"id":21342,"date":"2022-09-14T17:51:00","date_gmt":"2022-09-14T15:51:00","guid":{"rendered":"https:\/\/help.openbee.com\/open-bee-scan-capture\/knowledge-base\/how-to-guides\/scripts-in-capture\/case-studies\/index\/index-get-an-item-line-value-from-a-vertical-position\/"},"modified":"2026-05-13T09:36:50","modified_gmt":"2026-05-13T07:36:50","slug":"index-get-an-item-line-value-from-a-vertical-position","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-get-an-item-line-value-from-a-vertical-position\/","title":{"rendered":"Index: Get an Item Line Value from a Vertical Position"},"content":{"rendered":"\n<p>The purpose of this script is to populate an index of the current row by comparing the vertical position of the current row to the vertical position of an index of another item row<\/p>\n\n<p><\/p>\n\n<p>REFERENCES_INDEX = Item Line ID on which we want to base the values in vertical position<\/p>\n\n<p>NUMERO_REFERENCES_INDEX = Item line index ID for vertical positions<\/p>\n\n<p>TOTAL_ARTICLE_LIGNES_ARTICLES_INDEX = ID of the current line that gives an idea of the current position of our item line<\/p>\n\n<pre class=\"wp-block-code\"><code>var calculScore = function(pInfo){\r\n\tif(pInfo == null || pInfo.value == null || pInfo.value.rectangle == null)\r\n\t\treturn -1;\r\n\treturn (pInfo.numPage*10000)+pInfo.value.rectangle.y1;\r\n};\r\n\r\nvar articles = getArticleLines(pParameters, \"REFERENCES_INDEX\");\r\nvar ref = &#91;];\r\n\r\nfor(var i=0;i&lt;articles.length;i++){\r\n\tvar r = getIndexFromArticleLine(articles&#91;i], \"NUMERO_REFERENCES_INDEX\");\r\n\tref.push({\"info\" : getTextFromIndexInfo(r), \"score\": calculScore(r)});\r\n}\r\n\r\nref.sort(function(a, b){return b.score - a.score});\r\n\r\nvar currentArticle = getCurrentArticleLine(pParameters);\r\nvar calculCurrent = calculScore(getIndexFromArticleLine(currentArticle, \"TOTAL_ARTICLE_LIGNES_ARTICLES_INDEX\"));\r\n\r\nvar currentRef = \"\";\r\nvar j = 0;\r\nwhile(j &lt; ref.length &amp;&amp; currentRef == \"\"){\r\n\tif(calculCurrent >= ref&#91;j].score)\r\n\t\tcurrentRef = ref&#91;j].info;\r\n\tj = j + 1;\r\n}\r\n\r\nreturn currentRef;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The purpose of this script is to populate an index of the current row by comparing the vertical position of the current row to the vertical position of an index of another item row REFERENCES_INDEX = Item Line ID on which we want to base the values in vertical position NUMERO_REFERENCES_INDEX = Item line index [&hellip;]<\/p>\n","protected":false},"author":97,"featured_media":0,"parent":21276,"menu_order":9,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-21342","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21342","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\/97"}],"replies":[{"embeddable":true,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/comments?post=21342"}],"version-history":[{"count":1,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21342\/revisions"}],"predecessor-version":[{"id":21345,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21342\/revisions\/21345"}],"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=21342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}