yuuvis® RAD Q&A

0 votes
by (750 points)

Hello,

I want to sync a table from my DMS Object "rechnung" to my Process using server-side Scripting. I've tried something like this but it doesn't work (process is failing).

My Code:

	// Zahlungsbedingungen Tabelle Syncen dms object => bpm process
	this.$.variable("zahlungsbedingungen").addArray(rechnung.zahlungsbedingungen);

	// Zahlungsbedingungen Tabelle Syncen bpm process => dms process
	rechnung.zahlungsbedingungen = this.$.variable("zahlungsbedingungen").toArray();

What is the right way to do this?
The two datafields have the same structure:

DMS Object:

BPM Process:

1 Answer

+1 vote
by (2.3k points)
selected by
 
Best answer

Hi Marcel,

you need to create the line in the table by calling the function .createItem() on the Table. You then fill the new line item and push it to the table via push on the tables

Here is an example how i like to do that specifically. I tend to put such stuff in configs ans write the code more generically but i hope it is still readable for you.

//load simple tables
$.log.info(LOG_PREFIX + ' start loading simple tables');
var simpleTablesToLoad = config.tablesToSync;
for (tableNameDms in simpleTablesToLoad) {
	if (Object.hasOwnProperty.call(simpleTablesToLoad, tableNameDms)) {
		var tableLoadConfig = simpleTablesToLoad[tableNameDms];
		var colMap = tableLoadConfig.colMap;
		if (dmsObject.data[tableNameDms]) {
			$.log.info(LOG_PREFIX + ' loading table ' + tableNameDms);
			var targetTable = $.variable(tableLoadConfig.wfName);
			targetTable.value = [];

			dmsObject.data[tableNameDms].forEach(function (element) {
				var item = targetTable.createItem();
				item.value = {};
				for (dmsColKey in colMap) {
					if (Object.hasOwnProperty.call(colMap, dmsColKey)) {
						var wfColKey = colMap[dmsColKey];
						item.value[wfColKey] = element[dmsColKey];
					}
				}
				targetTable.value.push(item);
			});
		}
	}
}

a corresponding config for my usecase could look like:

var config = {	
//the tables that must be synced between dms and wf
tablesToSync: {
	tlistecontainernummern: {
		wfName: 'tabContainerNumbers',
		colMap: {
			stcontainernummer: 'sContainerNummer',
			stcontainertyp: 'sContainerTyp',
			stforwardingreference: 'sForwardingReference',
		},
	},
},

};

Related questions

0 votes
1 answer
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
...