{"id":21330,"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\/item-index-distribute-a-material-code-to-all-lines\/"},"modified":"2026-05-13T09:36:50","modified_gmt":"2026-05-13T07:36:50","slug":"item-index-distribute-a-material-code-to-all-lines","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\/item-index-distribute-a-material-code-to-all-lines\/","title":{"rendered":"Item Index: Distribute a Material Code to All Lines"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"IndexArticle:repartiruncodearticlesurtoutesleslignes-Principe:\">Principle:<\/h2>\n\n<p>Use this script to retrieve the detected value from a single item line (the 1st in a set) and apply this value to subsequent item lines.<\/p>\n\n<p>This script requires 2 indexes:  <\/p>\n\n<ul class=\"wp-block-list\"><li>index &#8220;value&#8221; which is an index detected on the document for certain item lines.<\/li><li>Index script that takes the value of the &#8220;value&#8221; index if it is detected, otherwise, the 1st non-empty value of &#8220;value&#8221; from the previous article rows<\/li><\/ul>\n\n<h2 class=\"wp-block-heading\" id=\"IndexArticle:repartiruncodearticlesurtoutesleslignes-Script:\">Script:<\/h2>\n\n<pre class=\"wp-block-code\"><code>var getIndexValue = function(pParameters){\n    var articles = getArticleLines(pParameters, \"ARTICLES_INDEX\");\n    var currentArticle = getCurrentArticleLine(pParameters);\n    if(articles == null || currentArticle == null)\n    \treturn \"\";\n    var indexValue = getTextFromIndexInfo(getIndexFromArticleLine(currentArticle, \"VALUE_ARTICLES_INDEX\"));\n    if(indexValue != null &amp;&amp; indexValue != \"\")\n    \treturn indexValue;\n    for(var i=currentArticle.idUnit - 1;i&gt;= 0; i--){\n    \tvar prevIndexValue = getTextFromIndexInfo(getIndexFromArticleLine(articles&#91;i], \"VALUE_ARTICLES_INDEX\"));\n    \tif(prevIndexValue != null &amp;&amp; prevIndexValue != \"\")\n    \t\treturn prevIndexValue;\n    }\n    return \"\";\n};\nreturn getIndexValue(pParameters);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Principle: Use this script to retrieve the detected value from a single item line (the 1st in a set) and apply this value to subsequent item lines. This script requires 2 indexes: index &#8220;value&#8221; which is an index detected on the document for certain item lines. Index script that takes the value of the &#8220;value&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":21276,"menu_order":7,"comment_status":"closed","ping_status":"closed","template":"templates\/ob-help-products.php","meta":{"footnotes":""},"class_list":["post-21330","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21330","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=21330"}],"version-history":[{"count":1,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21330\/revisions"}],"predecessor-version":[{"id":21334,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21330\/revisions\/21334"}],"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=21330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}