You need to sign in to do that
Don't have an account?
nitial term of field expression must be a concrete SObject: LIST<Place__c> at line 70 column 35
Can any one help me out
public class Ticket
{
string[] StartP =new String[]{};
string[] EndP = new String[]{};
public integer b;
public integer c;
public integer z{get; set;}
public integer BR;
public integer a {get; set;}
public String BS {get; set;}
public PageReference submit()
{
return null;
}
public integer getnumber()
{
return a;
}
public List<selectOption> getitems()
{
List<SelectOption> op1 = new List<SelectOption>();
op1.add(new selectOption('Miyapur','Miyapur'));
op1.add(new selectOption('Moosapet','Moosapet'));
return op1;
}
public List<selectOption> getitems1()
{
List<SelectOption> op2 = new List<SelectOption>();
op2.add(new selectOption('Bharatnagar','Bharatnagar'));
op2.add(new selectOption('Moosapet','Moosapet'));
return op2;
}
public String[] getStartP()
{
return StartP;
}
public void setStartP(String[] StartP)
{
this.StartP = StartP;
}
public String[] getEndP()
{
return EndP;
}
public void setEndP(String[] EndP)
{
this.EndP = EndP;
}
public integer i{get; set;}
public integer w{get; set;}
public integer x{get; set;}
public integer v {get; set;}
public String MSg{get; set;}
public Integer getScode()
{
List<Place__c> p = new List<Place__c>();
p =[Select Distance__c,BusStations__c from Place__c];
for( List<Place__c> m : p)
{
if(m.BusStations__c == EndP )
{
i = integer.valueof(m.Distance__c );
}
}
for(List<Place__c> z : p)
{
if(z.BusStations__c == Startp)
{
w = integer.valueof(z.Distance__c);
}
}
try{
x = (i-w);
}catch(System.Exception e)
{
System.debug('Exception occured: ' + e);
}
return x;
}
List<Place__c> q =new List<Place__c>();
public List<Place__c> getEcode()
{
q = [select Distance__c,BusStatoonCode__c from Place__c where BusStations__c =:EndP];
return q;
}
Public List<Place__c> getinfo()
{
List<Place__c> k = [select Distance__c,BusStatoonCode__c from Place__c where BusStations__c =:StartP];
return k;
}
}
set<string> bs = new set<string>();
According to your code bs is a Set of String. But you access that set like Sobject list. bs String list has not any Distance__c field or BusStations__c fields. It contains only Strings.
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
All Answers
List<Place__c> p = new List<Place__c>();
p =[Select Distance__c,BusStations__c from Place__c];
for( List<Place__c> m : p)
{
if(m.BusStations__c == EndP )
{
i = integer.valueof(m.Distance__c );
}
****************************************************************
In the above code in for loop write as follows and check it
for(Place__c m; p)
If this answers your question mark it as solution
Thank you for your reply
I too tried in that way then the result is.
Error: Ticket Compile Error: Comparison arguments must be compatible types: String, LIST<String> at line 67 column 15
so I took list<Place>.
Is there any other option?
Thanks in advance.
what is the Place
Place __c
Let me explain you clearly
for(object Name(standard obj example contact, lead etc) if custom object like product__c variable : List name)
Make sure your place__c is an object
If this answers your question mark it as solution, Its up to you.
Hi suree..
sorry Place__c is a custom object.
if i am not using list<Place__c> then the above error displays so i used
for(List<Place__c> m:P)
after replacing with list the above error corrects and later in line 70
where i am trying to retrive the distance__c value to the variable now,here comes the error. so what to do here.
line 67 error is comming because you did not declare the list at the beginignof class
like public List<place__c> p;
coluld you please send me line 69 70 71 lines of code.
Note General meaning of this error is the filed you are using is not matching with the object, (you may know this jst to share i am writing)
Thanks for discussing regarding this error
public integer i{get; set;}
public integer w{get; set;}
public integer x{get; set;}
public integer v {get; set;}
public String MSg{get; set;}
List<Place__c> p = new List<Place__c>();
public Integer getScode()
{
p =[Select Distance__c,BusStations__c from Place__c];
for( List<Place__c> m : p)
{
if(m.BusStations__c == EndP )
{
i = integer.valueof( m.Distance__c); error comes here
}
}
for(Place__c z : p)
{
if(z.BusStations__c == Startp)
{
w = integer.valueof(z.Distance__c);
}
}
try{
x = (i-w);
}catch(System.Exception e)
{
System.debug('Exception occured: ' + e);
}
return x;
}
you are looking for a single value from a collection,
first you write it as follows i = integer.valueof( m.Distance__c[0]);
but i am not sure it will solve your problem
what my suggestion is
create one set to collect all the busstop values as follows
Public set<string Or any of your data type> bstop = set<string>();
for( List<Place__c> m : p)
{
bs.add(m.BusStations__c);
}
if(bs.BusStations__c == EndP)
{
then you code
}
sorry i had urgnet requirement to do in the office, ok even if you have any question post it i will try to help you but aft 5 ,o clock
as your suggestion used set<String> bs = new set<String>
set<string> bs = new set<string>();
for( List<Place__c> m : p)
{
bs.add(m.BusStations__c);
}
if(bs.BusStations__c == EndP )
{
i = integer.valueof(m.Distance__c);
}
then other error like Error: Ticket Compile Error: Variable does not exist: m.Distance__c at line 56 column 35
So i added Distance__c in set<String> like
set<string> bs = new set<string>();
for( List<Place__c> m : p)
{
bs.add(m.BusStations__c);
bs.add(m.Distances__c);
}
if(bs.BusStations__c == EndP )
{
i = integer.valueof(bs.Distance__c);
}
Then again the same error came...:(
ok waiting for your help..
thank you.
Can any one help me out for the above error..
set<string> bs = new set<string>();
According to your code bs is a Set of String. But you access that set like Sobject list. bs String list has not any Distance__c field or BusStations__c fields. It contains only Strings.
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Thank you for the reply
Then can you tel me then why this error
public class Ticket
{
string[] StartP =new String[]{};
string[] EndP = new String[]{};
public integer b;
public integer c;
public integer z{get; set;}
public integer BR;
public integer a {get; set;}
public String BS {get; set;}
public PageReference submit()
{
return null;
}
public integer getnumber()
{
return a;
}
public List<selectOption> getitems()
{
List<SelectOption> op1 = new List<SelectOption>();
op1.add(new selectOption('Miyapur','Miyapur'));
op1.add(new selectOption('Moosapet','Moosapet'));
return op1;
}
public List<selectOption> getitems1()
{
List<SelectOption> op2 = new List<SelectOption>();
op2.add(new selectOption('Bharatnagar','Bharatnagar'));
op2.add(new selectOption('Moosapet','Moosapet'));
return op2;
}
public String[] getStartP()
{
return StartP;
}
public void setStartP(String[] StartP)
{
this.StartP = StartP;
}
public String[] getEndP()
{
return EndP;
}
public void setEndP(String[] EndP)
{
this.EndP = EndP;
}
List<Place__c> p = new List<Place__c>();
public integer i{get; set;}
public integer w{get; set;}
public integer x{get; set;}
public integer v {get; set;}
public String MSg{get; set;}
public Integer getScode()
{
p =[Select Distance__c,BusStations__c from Place__c where BusStations__c =:StartP];
for( List<Place__c> m : p)
{
if(m.BusStations__c == EndP )
{
i = integer.valueof(m.Distance__c);
}
}
for(List<Place__c> z : p)
{
if(z.BusStations__c == Startp)
{
w = integer.valueof(z.Distance__c);
}
}
try{
x = (i-w);
}catch(System.Exception e)
{
System.debug('Exception occured: ' + e);
}
return x;
}
List<Place__c> q =new List<Place__c>();
public List<Place__c> getEcode()
{
q = [select Distance__c,BusStatoonCode__c from Place__c where BusStations__c =:EndP];
return q;
}
Public List<Place__c> getinfo()
{
List<Place__c> k = [select Distance__c,BusStatoonCode__c from Place__c where BusStations__c =:StartP];
return k;
}
}
you are taking start p and endp as string array but when comparing in the query as a variable,
try like this
p=[ select x, y from xy where x =:startp[0]];
or
p=[select x, y from xy where x IN startp[i]]
if you have more start points put i if not 0
Hi suree i tried like this
Is this correct way public List<Place__c> getScode()
{
p = [Select Distance__c,BusStations__c from Place__c];
for( List<Place__c> m: p)
{
if(m.BusStations__c == EndP[0] )
{
i = integer.valueof(m.Distance__c);
}
}
if this is correct means again the same error is coming..
let us checkweather the query is getting the values are not
p = [Select Distance__c,BusStations__c from Place__c];
after this can you write debug log
system.debug('******************** Value of Distance__c,BusStations__c' +p);
goto Monitoring-debug log create debuglog on your name run the class then come back to the debug log tab refresh and check the first log with ctrl + f and type *************** click enter