You need to sign in to do that
Don't have an account?
mat_tone_84
syntax of query to get field in other object
Hi,
I need to create a vf page into contact for get a field of a custom object, is it be possible ?
the query is like: "select customobject_customfield from customobject where customobject_customfield = :contact_city"
I will create a new visualforcepage , put it into the layout of contact and get a custom message to the user.
I'm able to create the trigger with query by eclipse, but it is the first time that I have to create a query into visualforcepage
Someone can give me some help with the syntax ?
thanks
Hi,
Try the below code snippet as reference:
<apex:page standardController="Contact" extensions="dispalyObjectA" >
<apex:dataTable value="{!listobj}" var="m" columnswidth="100px,100px" cellpadding="4" border="1">
<apex:column headervalue="ID" value="{!m.id}" />
<apex:column headervalue="Nmae" value="{!m.name}" />
<apex:column headervalue="Number" value="{!m.Number1__c}" />
<apex:column headervalue="Price" value="{!m.objB_price__c}" />
</apex:dataTable>
</apex:page>
=========Apex Controller===========
public class dispalyObjectA {
public List<ObjectA__c> listobj{get;set;}
public dispalyObjectA(ApexPages.StandardController controller)
{
listobj=new List<ObjectA__c>();
listobj=[select id,name,Number1__c, objB_price__c from ObjectA__c where Number1__c=70 Limit 10];
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
All Answers
Hi,
Try the below code snippet as reference:
<apex:page standardController="Contact" extensions="dispalyObjectA" >
<apex:dataTable value="{!listobj}" var="m" columnswidth="100px,100px" cellpadding="4" border="1">
<apex:column headervalue="ID" value="{!m.id}" />
<apex:column headervalue="Nmae" value="{!m.name}" />
<apex:column headervalue="Number" value="{!m.Number1__c}" />
<apex:column headervalue="Price" value="{!m.objB_price__c}" />
</apex:dataTable>
</apex:page>
=========Apex Controller===========
public class dispalyObjectA {
public List<ObjectA__c> listobj{get;set;}
public dispalyObjectA(ApexPages.StandardController controller)
{
listobj=new List<ObjectA__c>();
listobj=[select id,name,Number1__c, objB_price__c from ObjectA__c where Number1__c=70 Limit 10];
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi,
the code works properly, but I need the last answer for filtering the query
which is the right syntax for filtering with contact's field?
I try to declare above "Contact C" and then filtering with number1__c = :c.customfield__c but doesn't work, I get "attemp to referenc a null object"
thanks!!
I'm looking for another way for filtering but doesn't work....
<apex:column headervalue="ID" value="{!if( m.Number1__c = c.customfield__c ,m.number1__c,'not show')}" />
I get syntax error Error: Syntax error. Missing ')'
I solved the problem in this way, adding "rendered" into the apex:column