Question

Reading the entity and publishing it in detail

How do I read all the records from my entity object created in system config and insert it in one go in the detail section .

 

 

Like 0

Like

1 comments

Dear Hemalatha,

You can go two ways here. First one involves writing script task in business process, the other one expects a new function to be added to the detail page schema. The ESQ function in second approach should be triggered in the onEntityInitialized function, or in any other function up to your needs.

In any case both approaches require firstly creating ESQ to the object and retrieve a collection of records. (Donating object)

Once you get the collection, you need to create InsertQuery using ESQ and insert each resulting element of the collection to the needed object. (Recipient object)

You can use the example below as a guideline:

getInsertRecordsToDetailQuery: function() {
	var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {rootSchemaName: "UsrObject"});
	esq.addColumn("UsrName");
	esq.addColumn("UsrNumber");
	esq.addColumn("UsrOwner");
 
	var detailType = this.get("UsrType");
	esq.filters.addItem(esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "UsrObject.Type", detailType.displayValue));
	esq.getEntityCollection(function(result) {
		 if (result.success) {
				var batchQuery = Ext.create("Terrasoft.BatchQuery");
				result.collection.each(function(item) {
					var insertQuery = Ext.create("Terrasoft.InsertQuery", { rootSchemaName: "UsrDetail" });
					insertQuery.setParameterValue("UsrName", item.get("UsrName"), Terrasoft.DataValueType.TEXT);
					insertQuery.setParameterValue("UsrNumber", item.get("UsrNumber").value, Terrasoft.DataValueType.INTEGER);
					insertQuery.setParameterValue("UsrOwner", item.get("UsrOwner").value, Terrasoft.DataValueType.GUID);
					batchQuery.add(insertQuery);
				 }, this);
				batchQuery.execute();
			}
	}, this);
}

Here are the articles on our academy on writing ESQ:

Server side ESQ for Script Task if you choose business process:

https://academy.bpmonline.com/documents/technic-sdk/7-12/use-entityschemaquery-creation-queries-database

Client side if you choose to add function to the detail schema:

https://academy.bpmonline.com/documents/technic-sdk/7-12/building-paths…

Regards,

Anastasia Botezat

Show all comments