Functions

Introduction

It is possible to use most of the functions available in pure Javascript. Please note that the features of web-based Javascript are not available.

Pre-integrated functions

In order to facilitate your experience with Open Bee™ Scan Capture , a few functions have been pre-built and can be used regardless of the context of the script.

When a function uses an index ID as a parameter, you can find the one corresponding to the desired index in the configuration interface of this index by clicking on the information button

All of the examples below have been created for an index script on the following document:

getIndexesFromID(info, pid)

This method is used to get the Info objects contained within the info list with id p id

var listHT = getIndexesFromID(pParameters, "AMOUNT_EX_VAT_INDEX");
return JSON.stringify(listHT);

Result

[
	{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"total","text":"total","rectangle":{"x1":1318,"y1":1495,"x2":1399,"y2":1524}},"value":{"textPropositionByCapture":"322.28","sourceValue":"322.28","text":"322,28","rectangle":{"x1":2302,"y1":1341,"x2":2418,"y2":1373}},"lockValue":false,"idUnit":1,"id":"AMOUNT_EX_VAT_INDEX","name":"Total HT","numPage":1,"docIndexType":2,"type":"DecimalIndexInfo"},
	{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"total","text":"total","rectangle":{"x1":1318,"y1":1495,"x2":1399,"y2":1524}},"value":{"textPropositionByCapture":"425.29","sourceValue":"425,29","text":"425,29","rectangle":{"x1":2301,"y1":1297,"x2":2420,"y2":1330}},"lockValue":false,"idUnit":2,"id":"AMOUNT_EX_VAT_INDEX","name":"Total HT","numPage":1,"docIndexType":2,"type":"DecimalIndexInfo"},
	{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"total","text":"total","rectangle":{"x1":1318,"y1":1495,"x2":1399,"y2":1524}},"value":{"textPropositionByCapture":"103.01","sourceValue":"103,01","text":"103,01","rectangle":{"x1":2303,"y1":1497,"x2":2413,"y2":1530}},"lockValue":false,"idUnit":3,"id":"AMOUNT_EX_VAT_INDEX","name":"Total HT","numPage":1,"docIndexType":2,"type":"DecimalIndexInfo"}
]

getFirstIndexFromID(info, pid)

This method gets the first Info object in the Info list with id p id

var mtHT = getFirstIndexFromID(pParameters, "AMOUNT_EX_VAT_INDEX");
return JSON.stringify(mtHT );

Result

{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"total","text":"total","rectangle":{"x1":1318,"y1":1495,"x2":1399,"y2":1524}},"value":{"textPropositionByCapture":"322.28","sourceValue":"322.28","text":"322,28","rectangle":{"x1":2302,"y1":1341,"x2":2418,"y2":1373}},"lockValue":false,"idUnit":1,"id":"AMOUNT_EX_VAT_INDEX","name":"Total HT","numPage":1,"docIndexType":2,"type":"DecimalIndexInfo"}

getTextFromIndexInfo(info)

This method is used to obtain the text value of the Info object passed as a parameter

var mtHTInfo = getFirstIndexFromID(pParameters, "AMOUNT_EX_VAT_INDEX");
var mtHTText = getTextFromIndexInfo(mtHTInfo);
return mtHTText;

Result

322,28

getArticleLines(info, lineid)

This method allows you to obtain the different item lines corresponding to a lineid id

var lignesInfos = getArticleLines(pParameters, "ARTICLES_INDEX");
return JSON.stringify(lignesInfos);

Result

[
	{
		"indexInfos":[
			{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"Régularisation","sourceValue":"Régularisation","text":"Régularisation","rectangle":{"x1":1160,"y1":1295,"x2":1399,"y2":1332}},"lockValue":false,"idUnit":1,"id":"DESCRIPTION_ARTICLES_INDEX","name":"Description","numPage":1,"docIndexType":1,"type":"VarcharIndexInfo"},
			{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"425.29","sourceValue":"425,29","text":"425,29","rectangle":{"x1":2301,"y1":1297,"x2":2420,"y2":1330}},"lockValue":false,"idUnit":1,"id":"MONTANT_ARTICLES_INDEX","name":"Montant","numPage":1,"docIndexType":2,"type":"DecimalIndexInfo"}
		],
		"lockValue":false,
		"idUnit":1,
		"id":"ARTICLES_INDEX",
		"name":"Articles",
		"numPage":1,
		"docIndexType":5,
		"type":"ArticleLineInfo"
	},
	{
		"indexInfos":[
			{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"Remise","sourceValue":"Remise","text":"Remise","rectangle":{"x1":1160,"y1":1340,"x2":1284,"y2":1369}},"lockValue":false,"idUnit":2,"id":"DESCRIPTION_ARTICLES_INDEX","name":"Description","numPage":1,"docIndexType":1,"type":"VarcharIndexInfo"},
			{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"322.28","sourceValue":"322.28","text":"322,28","rectangle":{"x1":2302,"y1":1341,"x2":2418,"y2":1373}},"lockValue":false,"idUnit":2,"id":"MONTANT_ARTICLES_INDEX","name":"Montant","numPage":1,"docIndexType":2,"type":"DecimalIndexInfo"}
		],
		"lockValue":false,
		"idUnit":2,
		"id":"ARTICLES_INDEX",
		"name":"Articles",
		"numPage":1,
		"docIndexType":5,
		"type":"ArticleLineInfo"
	},
	{
		"indexInfos":[
			{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"Total exonéré","sourceValue":"Total exonéré","text":"Total exonéré","rectangle":{"x1":1157,"y1":1390,"x2":1389,"y2":1419}},"lockValue":false,"idUnit":3,"id":"DESCRIPTION_ARTICLES_INDEX","name":"Description","numPage":1,"docIndexType":1,"type":"VarcharIndexInfo"},
			{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"103.01","sourceValue":"103,01","text":"103,01","rectangle":{"x1":2304,"y1":1391,"x2":2413,"y2":1423}},"lockValue":false,"idUnit":3,"id":"MONTANT_ARTICLES_INDEX","name":"Montant","numPage":1,"docIndexType":2,"type":"DecimalIndexInfo"}
		],
		"lockValue":false,
		"idUnit":3,
		"id":"ARTICLES_INDEX",
		"name":"Articles",
		"numPage":1,
		"docIndexType":5,
		"type":"ArticleLineInfo"
	}
]

getArticleLine(info, IDLigne, idUnit)

This method is used to get the item line corresponding to a lineid and the IdUnit id unit

var ligneInfos = getArticleLine(pParameters, "ARTICLES_INDEX", 2);
return JSON.stringify(ligneInfos);

Result

{
	"indexInfos":[
		{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"Remise","sourceValue":"Remise","text":"Remise","rectangle":{"x1":1160,"y1":1340,"x2":1284,"y2":1369}},"lockValue":false,"idUnit":2,"id":"DESCRIPTION_ARTICLES_INDEX","name":"Description","numPage":1,"docIndexType":1,"type":"VarcharIndexInfo"},
		{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"322.28","sourceValue":"322.28","text":"322,28","rectangle":{"x1":2302,"y1":1341,"x2":2418,"y2":1373}},"lockValue":false,"idUnit":2,"id":"MONTANT_ARTICLES_INDEX","name":"Montant","numPage":1,"docIndexType":2,"type":"DecimalIndexInfo"}
	],
	"lockValue":false,
	"idUnit":2,
	"id":"ARTICLES_INDEX",
	"name":"Articles",
	"numPage":1,
	"docIndexType":5,
	"type":"ArticleLineInfo"
}

getIndexFromArticleLine(infoLine, idIndex)

This method retrieves the Info object corresponding to the idIndex id from an InfoLine item line

var ligneInfos = getArticleLine(pParameters, "ARTICLES_INDEX", 2);
var detectionInfo = getIndexFromArticleLine(ligneInfos, "DESCRIPTION_ARTICLES_INDEX");
return JSON.stringify(detectionInfo);

Result

{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"Remise","sourceValue":"Remise","text":"Remise","rectangle":{"x1":1160,"y1":1340,"x2":1284,"y2":1369}},"lockValue":false,"idUnit":2,"id":"DESCRIPTION_ARTICLES_INDEX","name":"Description","numPage":1,"docIndexType":1,"type":"VarcharIndexInfo"}

Special Item Line

The methods below this box can only be used for a scripted index that belongs to an article row. To perform these examples, a scripted index has been added to the article line

getCurrentArticleLines(info)

This method is a shortcut to the getArticleLines() method with the parameter:

  • Info: the list of invoice details
  • id: is based on the global variable GROUPED_INDEX_ID
var lignesInfos = getCurrentArticleLines(pParameters);
return JSON.stringify(lignesInfos );

Result

[
	{
		"indexInfos":[
			{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"Régularisation","sourceValue":"Régularisation","text":"Régularisation","rectangle":{"x1":1160,"y1":1295,"x2":1399,"y2":1332}},"lockValue":false,"idUnit":1,"id":"DESCRIPTION_ARTICLES_INDEX","name":"Description","numPage":1,"docIndexType":1,"type":"VarcharIndexInfo"},
			{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"425.29","sourceValue":"425,29","text":"425,29","rectangle":{"x1":2301,"y1":1297,"x2":2420,"y2":1330}},"lockValue":false,"idUnit":1,"id":"MONTANT_ARTICLES_INDEX","name":"Montant","numPage":1,"docIndexType":2,"type":"DecimalIndexInfo"},
			{"source":2,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"[null,null,null]","sourceValue":"","text":"[null,null,null]","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"lockValue":false,"idUnit":1,"id":"TEST_SCRIPT_ARTICLES_INDEX","name":"Test script","numPage":-1,"docIndexType":1,"type":"VarcharIndexInfo"}
		],
		"lockValue":false,
		"idUnit":1,
		"id":"ARTICLES_INDEX",
		"name":"Articles",
		"numPage":1,
		"docIndexType":5,
		"type":"ArticleLineInfo"
	},
	{
		"indexInfos":[
			{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"Remise","sourceValue":"Remise","text":"Remise","rectangle":{"x1":1160,"y1":1340,"x2":1284,"y2":1369}},"lockValue":false,"idUnit":2,"id":"DESCRIPTION_ARTICLES_INDEX","name":"Description","numPage":1,"docIndexType":1,"type":"VarcharIndexInfo"},
			{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"322.28","sourceValue":"322.28","text":"322,28","rectangle":{"x1":2302,"y1":1341,"x2":2418,"y2":1373}},"lockValue":false,"idUnit":2,"id":"MONTANT_ARTICLES_INDEX","name":"Montant","numPage":1,"docIndexType":2,"type":"DecimalIndexInfo"},
			{"source":2,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"[null,null,null]","sourceValue":"","text":"[null,null,null]","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"lockValue":false,"idUnit":2,"id":"TEST_SCRIPT_ARTICLES_INDEX","name":"Test script","numPage":-1,"docIndexType":1,"type":"VarcharIndexInfo"}
		],
		"lockValue":false,
		"idUnit":2,
		"id":"ARTICLES_INDEX",
		"name":"Articles",
		"numPage":1,
		"docIndexType":5,
		"type":"ArticleLineInfo"
	},
	{
		"indexInfos":[
			{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"Total exonéré","sourceValue":"Total exonéré","text":"Total exonéré","rectangle":{"x1":1157,"y1":1390,"x2":1389,"y2":1419}},"lockValue":false,"idUnit":3,"id":"DESCRIPTION_ARTICLES_INDEX","name":"Description","numPage":1,"docIndexType":1,"type":"VarcharIndexInfo"},
			{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"103.01","sourceValue":"103,01","text":"103,01","rectangle":{"x1":2304,"y1":1391,"x2":2413,"y2":1423}},"lockValue":false,"idUnit":3,"id":"MONTANT_ARTICLES_INDEX","name":"Montant","numPage":1,"docIndexType":2,"type":"DecimalIndexInfo"},
			{"source":2,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"[null,null,null]","sourceValue":"","text":"[null,null,null]","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"lockValue":false,"idUnit":3,"id":"TEST_SCRIPT_ARTICLES_INDEX","name":"Test script","numPage":-1,"docIndexType":1,"type":"VarcharIndexInfo"}
		],
		"lockValue":false,
		"idUnit":3,
		"id":"ARTICLES_INDEX",
		"name":"Articles",
		"numPage":1,
		"docIndexType":5,
		"type":"ArticleLineInfo"
	}
]

This method is useful when using multiple item line templates within the same document. It allows you to quickly reach information from your parent line without confusing it with information from other item line templates

getCurrentArticleLine(info)

This method is a shortcut to the getArticleLine() method with the following parameter:

  • Info: The list of information on the invoice.
  • id: is based on the GROUPED_INDEX_ID variables
  • idUnit is based on the global variable ID_UNIT
var ligneInfos = getCurrentArticleLine(pParameters);
return JSON.stringify(ligneInfos );

Result of the 1st article line

{
	"indexInfos":[
		{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"Régularisation","sourceValue":"Régularisation","text":"Régularisation","rectangle":{"x1":1160,"y1":1295,"x2":1399,"y2":1332}},"lockValue":false,"idUnit":1,"id":"DESCRIPTION_ARTICLES_INDEX","name":"Description","numPage":1,"docIndexType":1,"type":"VarcharIndexInfo"},
		{"source":0,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"425.29","sourceValue":"425,29","text":"425,29","rectangle":{"x1":2301,"y1":1297,"x2":2420,"y2":1330}},"lockValue":false,"idUnit":1,"id":"MONTANT_ARTICLES_INDEX","name":"Montant","numPage":1,"docIndexType":2,"type":"DecimalIndexInfo"},
		{"source":2,"marker":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"value":{"textPropositionByCapture":"","sourceValue":"","text":"","rectangle":{"x1":0,"y1":0,"x2":0,"y2":0}},"lockValue":false,"idUnit":1,"id":"TEST_SCRIPT_ARTICLES_INDEX","name":"Test script","numPage":-1,"docIndexType":1,"type":"VarcharIndexInfo"}
	],
	"lockValue":false,
	"idUnit":1,
	"id":"ARTICLES_INDEX",
	"name":"Articles",
	"numPage":1,
	"docIndexType":5,
	"type":"ArticleLineInfo"
}

Special Consistency Index

getConsistencyAllDatas(indexCoherence)

This method is used to retrieve data reported by the data retrieval script from a consistency index.

var indexCoherence = getFirstIndexFromID(pParameters, "COHERENCE_INDEX");
var data = getConsistencyAllDatas(indexCoherence));

Example of a result

[
	{"CODE_ITEM" : "#253", "NAME" : "HDD 2To", "DATE" : "24/07/2023" },
	{"CODE_ITEM" : "#254", "NAME" : "HDD 1To", "DATE" : "01/08/2023" }
]

getConsistencyHeaders(indexCoherence)

This method is used to retrieve the data headers reported by the data retrieval script from a consistency index.

var indexCoherence = getFirstIndexFromID(pParameters, "COHERENCE_INDEX");
var headers = getConsistencyHeaders(indexCoherence));

Example of a result

[
	{"title" : "Code", "id" : "CODE_ITEM", "type" : "String", "availableValues" : ["#253", "#254", "#255"] },
	{"title" : "Nom", "id" : "NAME", "type" : "String" },
	{"title" : "Date de creation", "id" : "DATE", "type" : "Date" }
]

getConsistencyColumnDatas(indexCoherence, columnID))

This method retrieves all values in a column of data reported by the data retrieval script from a consistency index.

var indexCoherence = getFirstIndexFromID(pParameters, "COHERENCE_INDEX");
var data = getConsistencyColumnDatas(indexCoherence, "CODE_ITEM"));

Example of a result

[ "#253", "#254" ]

getConsistencyDataLineIDUnit(indexCoherence, lineNumber)

This method retrieves all of the items in a row of data reported by the data retrieval script from a consistency index (first item = 1).

var indexCoherence = getFirstIndexFromID(pParameters, "COHERENCE_INDEX");
var data = getConsistencyDataLineIDUnit(indexCoherence, 1));

Example of a result

{"CODE_ITEM" : "#253", "NAME" : "HDD 2To", "DATE" : "24/07/2023" }

getConsistencyDataIDUnit(indexCoherence, lineNumber, columnID)

This method is used to retrieve specific data from the data retrieval script from a consistency index based on its row number and column identifier.

var indexCoherence = getFirstIndexFromID(pParameters, "COHERENCE_INDEX");
var data = getConsistencyDataLineIDUnit(indexCoherence, 1, "CODE_ITEM"));

Example of a result

"#253"