You need to sign in to do that
Don't have an account?
annoyingmouse
Variable does not exist...? Surely some mistake
Don't call me Shirley!
So I'm working through some example AJAX stuff that I've found in the documentation and I'm trying to apply it to a custom object I've made:
<apex:page controller="MyController" tabStyle="Person__c"> <apex:pageBlock title="Hello {!$User.FirstName}!"> You are displaying People from the app. Click a person's name to view his or her details. </apex:pageBlock> <apex:pageBlock title="People"> <apex:form > <apex:dataTable value="{!people}" var="aPerson" width="100%"> <apex:column > <apex:facet name="header"> <b>Name</b> </apex:facet> <apex:commandLink action="{!invokeService}" value="{!aPerson.FullName__c}" rerender="resultPanel"> <apex:param name="id" value="{!aPerson.id}"/> </apex:commandLink> </apex:column> <apex:column > <apex:facet name="header"> <b>Number</b> </apex:facet>{!aPerson.PrimaryContactNo__c} </apex:column> </apex:dataTable> </apex:form> </apex:pageBlock> <apex:outputPanel id="detail"> <apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false"/> </apex:outputPanel> </apex:page>
With MyController looking like this:
public class MyController { public PageReference invokeService() { Id id = System.currentPageReference().getParameters().get('id'); //result = [SELECT Name FROM Person__c WHERE Id=:id].Name; result = [SELECT DateOfBirth__c FROM Person__c WHERE Id=:id]; return null; } public List<Person__c> getPeople() { return [SELECT Id, FullName__c, PrimaryContactNo__c FROM Person__c ORDER BY LastModifiedDate DESC LIMIT 10]; } }
Thing is, I keep getting this error:
Error: MyController Compile Error: Variable does not exist: result at line 5 column 9
I've tried adding ".DateOfBirth__c" to the end of the braced SOQL to no avail as the original code had ".Name" at the end...
Any idea as to what I'm missing?
Cheers,
Dom
check now...
All Answers
result varaible is not defined
person__c result = [SELECT DateOfBirth__c FROM Person__c WHERE Id=:id];
Hey Kirin,
that's brilliant as I'm no longer getting the error but I think I'm missing a trick now in that I don't get anything back. I'm guessing it to do with my outputpanel being configured incorrectly...?
Here it is:
Any ideas?
Dom
try to change this and try
Hi Kiran,
thanks for the suggestion but it's still not working. Damned if I know what to try next. Thank you anyway though. Not getting any errors just not able to display the result.
Cheers,
Dom
change and try like the below
<apex:page controller="MyController" tabStyle="Person__c">
<apex:pageBlock title="Hello {!$User.FirstName}!">
You are displaying People from the app.
Click a person's name to view his or her details.
</apex:pageBlock>
<apex:pageBlock title="People">
<apex:form >
<apex:dataTable value="{!people}" var="aPerson" width="100%">
<apex:column >
<apex:facet name="header">
<b>Name</b>
</apex:facet>
<apex:commandLink action="{!invokeService}" value="{!aPerson.FullName__c}" rerender="resultPanel">
<apex:param name="id" value="{!aPerson.id}"/>
</apex:commandLink>
</apex:column>
<apex:column >
<apex:facet name="header">
<b>Number</b>
</apex:facet>{!aPerson.PrimaryContactNo__c}
</apex:column>
</apex:dataTable>
</apex:form>
</apex:pageBlock>
<apex:outputPanel id="resultpanel">
<apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false"/>
</apex:outputPanel>
</apex:page>
Hi Kiran,
I'd clocked that as well so it's altered in the latest version I've got up there but I still don't get anything back from the server that's in anyway different.
I've had a squint using Firebug and it seems to squirt the whole page back... I guess that makes sense as the VisualForce page is enclosed in an iFrame I think.
Just a shame I can't get this working... I'm not totally stoopid so I guess I'm missing something obvious - I dare say I'll kick myself when I realise what it it ;-)
Ho Hum...
Cheers though,
Dom
p.s. Thanks for your efforts, I really do appreciate it!
hey this code is working for me check it out once i used account object here change accordingly
<apex:page controller="MyController" tabStyle="account">
<apex:pageBlock title="Hello {!$User.FirstName}!">
You are displaying People from the app.
Click a person's name to view his or her details.
</apex:pageBlock>
<apex:pageBlock title="People">
<apex:form >
<apex:dataTable value="{!people}" var="aPerson" width="100%">
<apex:column >
<apex:facet name="header">
<b>Name</b>
</apex:facet>
<apex:commandLink action="{!invokeService}" value="{!aPerson.name}" rerender="resultPanel">
<apex:param name="cid" value="{!aPerson.id}"/>
</apex:commandLink>
</apex:column>
<apex:column >
<apex:facet name="header">
<b>Number</b>
</apex:facet>{!aPerson.phone}
</apex:column>
</apex:dataTable>
</apex:form>
</apex:pageBlock>
<apex:outputPanel id="resultPanel">
<apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false"/>
</apex:outputPanel>
</apex:page>
class
public class MyController {
public PageReference invokeService() {
Id id = System.currentPageReference().getParameters().get('cid');
//result = [SELECT Name FROM Person__c WHERE Id=:id].Name;
account result = [SELECT id,name FROM Account WHERE Id=:id];
return null;
}
public List<account> getPeople() {
return [SELECT Id, name,phone FROM account
ORDER BY LastModifiedDate DESC LIMIT 10];
}
}
Hello again Kiran,
you're right, it works a treat! It's just that that works on standard objects and I'm looking at custom objects and that's where my issue lies. I use very, very few Standard objects as I'm primarily using this as a data store - it's just that I was hoping that SalesForce could act as a PaaS in this instance and I'm finding that without the ability to do this it perhaps isn't so well suited to what I was after doing :-(
Still, it's all learning isn't it? ;-)
Thanks again Kiran, you've been a star!
Cheers,
Dom
even with custom object also i am getting the result if you dont mind could you give the access to the instance then i will check once..very strange
Hey Kiran,
you're more than welcome to have a look at my application. Sorry about the delay in replying but I created it afresh in my development environment so that you could have a look. How do I go about granting you access?
I've been thrashing about trying to get it to work so as it stands it keeps throwing errors...
Cheers,
Dom
create a user with my email address kiranmutturu@gmail.com and assign sys admin profile and using personla set up u can grant me the login.. if you are not sure abt this procedure the share the credentials to my mail id...u need to set up the network access also to access ur appp...for this go to sys admin profile and set the login id range from 0.0.0.0 to 255.255.255.255... once this is done u can delete all these things..
Hi Kiran,
all done... I think... let me know if there's any problems. The page I was working on is /apex/person
Thanks again,
Dom
check now...
That works a treat, I'll just have to see what it was you did.
Thanks a lot!!!!
Cheers,
Dom