You need to sign in to do that
Don't have an account?

Call a respective account and contact name basd on a linked custom object
I have a custom object, that includes multiple fields,
But the account and contact names are taken from the respective account and contact standard objects,
So if you go in the custom object fields, you will se that they are lookup fields for those standard objects,
Question: The following few lines call a specific user data based on their IP address:
public with sharing class main_sub {
public List<Trainee__c> trainee{get;set;}
public List<Contract> license{get;set;}
public PageReference Sub{
license = new List<Contract>();
license = [select StartDate,
Host_Name__c,License_Type__c,Volume_Serial_Number__c,Expiration_Date__c,Physical_Address__c from Contract where Physical_Address__c=:'IP ADDRESS' ];
}
}
How can I call the Account name and Contact name for that IP address?
If someone can provide a link to an example that explains this, That would be great,
Thanks
You can swap the __c in soql to __r to get information from the object related to in the lookup field.
If the Contract is not the object with the account and contact look up fields but is part of 3rd object that has lookups then you could still apply the same principle with something like this:
SELECT Account__r.Name, Contact__r.Name,Contract__r.Host_Name__c,Contract__r.License_Type__c,Contract__r.Volume_Serial_Number__c,Contract__r.Expiration_Date__c,Contract__r.Physical_Address__c
FROM thirdObject__c
WHERE Contract__r.Physical_Address__c = :'IP Address'
presuming that name of the lookup fields on ThirdObject__c are Account__c, Contact__c, and Contract__c respectively.