How to read object value in java script

Hi 

I would appreciate if someone could guide me how to read the value from a WiJob object, which has a lookup WiBuilding and WiBuilding has a column WiChargeRate. I added this as dependency in attributes, I can see teh value is there but I am unable to read it. Please see image below.

Like 0

Like

3 comments

Hello Waseem,



You can operate with value of the property of the JS object just by using the property name e.g. to get the "WiBuilding" value you should use "job.WiBuilding".  The value that you will get is the WiBuilding object.

The "value " property of the "WiBuilding" object stores the Id of the record in "WiBuilding" lookup (since the "WiBuilding" is the lookup). 



How to get object`s value from the database by it`s id:

https://academy.bpmonline.com/documents/technic-sdk/7-13/use-entitysche…

Best regards,

Alex

Thank you Alex, you are right I do get the value of the WiBuilding by writing Job.WiBuilding or Job.WiBuilding.value. I am struggling with the next layer which is the WiBuilding.WiChargeRate (displaying 125 in the above image). I tried Job.WiBuilding.WiChargeRate but it does not give me the value of 125. Should I try Job.WiBuilding.WiChargeRate.value. 

In regards to Entity Schema, I wrote the following ESQ and I could get the value to display in the pop up but I could not read it in to variable to do some calculation.

this.showinformationDialog works, but when I try

var chargeRate = result.entity.get("WiChargeRate") I get 0 value

The ESQ code below:

//var building = this.get("WiBuilding");

/*

var recordId = building.value;

var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {

rootSchemaName: "WiBuildings"

});

esq.addColumn("WiChargeRate", "WiChargeRate");

esq.filters.add("IdFilter", esq.createColumnFilterWithParameter(

Terrasoft.ComparisonType.EQUAL, "Id", recordId));

esq.getEntity(recordId, function(result) {

if (!result.success) {

this.showInformationDialog("Data query error");

return;

}

this.showInformationDialog(result.entity.get("WiChargeRate"));

}, this);

*/

Hi Alex

I have resolved it. The syntax needed to be as follows:

var chargeRate = job["WiBuilding.WiChargeRate"];  //read building charge rate

Thank you for your help.

Show all comments