You need to sign in to do that
Don't have an account?
Abhiman Mungal
how to get the value from object through VF Pages
<apex:page standardController="Position__c" extensions="ParamBlogController">
<apex:outputPanel id="all">
<apex:form >
<apex:pageBlock title="Account Detail">
<apex:pageBlockSection title="Account">
<apex:commandButton action="{!setupContacts}" value="try"/>
<apex:inputField value="{!Position__c.Position_Type__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Contacts" columns="1">
<apex:pageBlockTable value="{!conts}" var="cont" rows="10">
<apex:column value="{!cont.Id}"/>
<apex:column value="{!cont.Name}"/>
<apex:column value="{!cont.city_state__c}"/>
<apex:column value="{!cont.Position_Type__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:outputPanel>
</apex:page>
public class ParamBlogController
{
private ApexPages.StandardController stdCtrl {get; set;}
public List<position__c> conts {get; set;}
public ParamBlogController(ApexPages.StandardController std)
{
stdCtrl=std;
}
public void setupContacts()
{
conts=[select Name,city_state__c,Department__c,Position_Id__c,Position_Type__c from position__c where Position_Type__c=:stdCtrl.getId()];
}
}
when i try to get the all records from position related records to position_types__c
<apex:outputPanel id="all">
<apex:form >
<apex:pageBlock title="Account Detail">
<apex:pageBlockSection title="Account">
<apex:commandButton action="{!setupContacts}" value="try"/>
<apex:inputField value="{!Position__c.Position_Type__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Contacts" columns="1">
<apex:pageBlockTable value="{!conts}" var="cont" rows="10">
<apex:column value="{!cont.Id}"/>
<apex:column value="{!cont.Name}"/>
<apex:column value="{!cont.city_state__c}"/>
<apex:column value="{!cont.Position_Type__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:outputPanel>
</apex:page>
public class ParamBlogController
{
private ApexPages.StandardController stdCtrl {get; set;}
public List<position__c> conts {get; set;}
public ParamBlogController(ApexPages.StandardController std)
{
stdCtrl=std;
}
public void setupContacts()
{
conts=[select Name,city_state__c,Department__c,Position_Id__c,Position_Type__c from position__c where Position_Type__c=:stdCtrl.getId()];
}
}
when i try to get the all records from position related records to position_types__c
In this case use below code:
Thanks,
Sohan Raj Gupta
All Answers
Try following.
Your Class:
VF Page:
Other changes you can make according to your requirements.
Thanks
Vinod
i try it but its not work
ThanksOnce you create a list at your Class by querying the object you just need your list at VF page like following First you need to create a correct list at your Class. This code is working for me.
you can debug your class data using system.debug(), and check is your list return the correct data or not in debug log.
anyway... what Error you are getting when you use my code ?
use below class code:
Please let me know if it helped or you need any more assistance.
Please mark this is as the solution if it solved your purpose.
Thank You,
Sohan Raj Gupta
its work fine
like this....
<apex:column value="{!cont.Position_Type__c}"/>
<apex:column value="{!cont.Location_Name__c}"/>
public class ParamBlogController
{
private ApexPages.StandardController stdCtrl {get; set;}
private ApexPages.StandardController stdCtrl1 {get; set;}
public List<position__c> conts {get; set;}
public position__c pos {get;set;}
public ParamBlogController(ApexPages.StandardController std,loc)
{
stdCtrl=std;
stdCtrl1 =loc;
this.pos = (position__c)std.getRecord();
this.pos=(position__c)loc.getRecord();
}
public void setupContacts()
{
conts=[select Name,city_state__c,Department__c,Position_Id__c,Position_Type__c from position__c where Position_Type__c=:pos.Position_Type__c and Location_Name__c=pos.Location_Name__c ];
}
}
In this case use below code:
Thanks,
Sohan Raj Gupta
I need one another help could you please tell me how to insert Position__c records through apex class with master detail values
Please explain your requirment in detail, so I can help you.
Thanks,
Sohan Raj Gupta
<apex:pageBlock >
<apex:form >
<apex:pageBlockSection title="Position" >
<apex:inputField value="{!Position__c.Name}"/>
<apex:inputField value="{!Position__c.Position_Id__c}"/>
<apex:inputField value="{!Position__c.Department__c}"/>
<apex:inputField value="{!Position__c.city_state__c}"/>
<apex:inputField value="{!Position__c.Position_Type__c}"/>
<apex:inputField value="{!Position__c.Location_Name__c}"/>
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockSection>
</apex:form>
</apex:pageBlock>
</apex:page>
in my position object i have this much fields and i want to insert records through the VF pages using Apex class.
in my position object i have two lookups fields one is positon_type__c and another is Location_Name__c when i want to insert records in position that time it will give me an error .
so what can i do....
private ApexPages.StandardController stdCtrl {get; set;}
public List<position__c> conts {get; set;}
public Position__c pos{get;set;}
public NextPage(ApexPages.StandardController std) {
stdCtrl=std;
this.pos = (position__c)std.getRecord();
}
public string position_type{get;set;}
public String save()
{
Position__c newObj = new Position__c();
newObj .position_type__c= [SELECT id FROM position_types__c WHERE Name =:pos.Position_Type__c LIMIT 1].id;
insert newObj ;
return 'success';
}
}
And this is my Apex class code
If positon_type__c is a lookup filed then it will give record ID apex class, so no need to get again ID in save function.
In save function you again create a new instance of Postion object and insert that. You should try below code:
Try above code and if will face again issue then let me know.
Thanks,
Sohan Raj Gupta