0

query result:

{
    type: 'Order',
    Id: null,
    OwnerOfVehicleRegDocument__r: {
        type: 'Account',
        Id: null,
        Name: 'CK-Carrossier 2',
    },
    RenterOfVehicleRegDocument__r: null,
}, {
    type: 'Order',
    Id: null,
    OwnerOfVehicleRegDocument__r: {
        type: 'Account',
        Id: null,
        Name: 'MURUGAN ADV',
    },
    RenterOfVehicleRegDocument__r: {
        type: 'Account',
        Id: null,
        Name: 'ARTEGY',
    },
}

code:

var Accrecords =  sforce.connection.query("SELECT OwnerOfVehicleRegDocument__r.Name,RenterOfVehicleRegDocument__r.Name FROM order where OwnerOfVehicleRegDocument__r.Name!= null and accountid= '"+ accid +"'");
var records = Accrecords.getArray("records");

alert(records);
var ordvehrecords=[];
var Renterrecords=[]; 
for (var i=0; i<records.length; i++) {
    var recordname = records[i];
    ordvehrecords.push(record.OwnerOfVehicleRegDocument__r.Name);

    Renterrecords.push(record.RenterOfVehicleRegDocument__r.Name);//here not able to get the values
}
0

1 Answer 1

2

If you do not want records which have null in RenterOfVehicleRegDocument__c field. You can change the query filter as:

var Accrecords =  sforce.connection.query("SELECT OwnerOfVehicleRegDocument__r.Name,RenterOfVehicleRegDocument__r.Name FROM order where OwnerOfVehicleRegDocument__r.Name!= null and RenterOfVehicleRegDocument__c != null AND accountid= '"+ accid +"'")

If you want records having null in RenterOfVehicleRegDocument__c but want to skip those records in logic then you can skip them by condition:-

for (var i=0; i<records.length; i++) {
    var recordname = records[i];
    ordvehrecords.push(record.OwnerOfVehicleRegDocument__r.Name);

    if(record.RenterOfVehicleRegDocument__r != null) {
        Renterrecords.push(record.RenterOfVehicleRegDocument__r.Name);//here not able to get the values
}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .