Question

Get an object by ID

Hi everyone,

We created a custom entity that has a Contact lookup called [UsrConsumidor] and we need to get a value from a Contact's field called [UsrTotalPtsAcumulados].



We got an exemple from the bpm'online academy (https://academy.bpmonline.com/documents/technic-sdk/7-10/entityschemaqu…) and followed the exactly same structure, but it's not working. 

​var contactId = this.get("UsrConsumidor");
 
// Create Terrasoft.EntitySchemaQuery class instance with [Contact] root schema.
	var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
	rootSchemaName: "Contact"
});
 
// Add column with name of main contact of accounts that refers to given contact.
esq.addColumn("UsrVouchers.UsrConsumidor.UsrTotalPtsAcumulados", "ContactTotalPtsAcumulados");
 
// Get one record from selection on the basis of [Id] of card object and display it in an info window.
esq.getEntity(contactId, function(result) {
	if (!result.success) {
		// error processing/logging, for example
		this.showInformationDialog("Data query error");
		return;
	}
	this.showInformationDialog(result.entity.get("ContactTotalPtsAcumulados"));
}, this);

The error that is given in the console is: "errorCode: "FormatException", message: "Expected hex 0x in '{0}'." "

Am I doing something wrong or is there an easier way to get an object by ID?

Best regards,

Rogério Zampieri.

Like 0

Like

1 comments

Dear Rogerio,

You don't need to join tables, your root schema is already "Contact", you just need to specify the filter.

Moreover, please use this statement to achieve Id of the contact:

​var contactId = this.get("UsrConsumidor").value



 

​var contactId = this.get("UsrConsumidor").value;
 
// Create Terrasoft.EntitySchemaQuery class instance with [Contact] root schema.
var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
	rootSchemaName: "Contact"
});
 
// Add column with name of main contact of accounts that refers to given contact.
esq.addColumn("UsrTotalPtsAcumulados");
esq.filters.add("IdFilter", esq.createColumnFilterWithParameter(
				Terrasoft.ComparisonType.EQUAL, "Id", contactId));
 
// Get one record from selection on the basis of [Id] of card object and display it in an info window.
esq.getEntity(contactId, function(result) {
	if (!result.success) {
		// error processing/logging, for example
		this.showInformationDialog("Data query error");
		return;
	}
	this.showInformationDialog(result.entity.get("ContactTotalPtsAcumulados"));
}, this);

Regards,

Anastasia

Show all comments