After reading tons of links, posts and many documents, I decided to ask for help here, hopping some guru can help me with this issue:
<!-- Visualforce Remote object component for Products -->
<apex:remoteObjects >
<apex:remoteObjectModel name="PriceBookEntry" jsShorthand="Prod" fields="id, Name, Pricebook2Id, UnitPrice, IsActive">
</apex:remoteObjectModel>
</apex:remoteObjects>
I have done this javascript fuction to display records from PriceBookEntry Object using remoteObject in Javascript:
function fetchPB(){var wh = new SObjectModel.Prod();
wh.retrieve({
where:{
Pricebook2Id : {eq:'01so0000002r3TBAAY'},
IsActive : {eq:true},
UnitPrice : {gt: 0}
},
limit: 5
},function(err, records){
if(err) alert(err.message);
else {
records.forEach(function(record) {
var divCol = $('<div class="row">');
var p = record.get("Pricebook2Id");
alert('row => ' + record.toString());
var detail = $('<p>'+record.get("Name")+'<br/></p>');
var link1 = $('<p><br/><input type="check" name="optCheck"></p> ');
link1.click(function(){
$('#inputProduct2').val(record.get("UnitPrice"));
});
detail.append(link1);
h3.append(detail);
divCol.append(product);
divCol.appendTo('#prodRow');
});
}
});
}
When I execute this function I can see in the developer console of my browser the post action and the data is coming from the server
Even I see the data is coming I can't get the object's values, if I display a javascript alert with the object information I can't see values only this:
console.log('---here---',record.toString());
open browser console and check the result.console.log('---here---',record);
.. check this is returning JS object or not.