You need to sign in to do that
Don't have an account?
Mohit Kapoor
Having problems handling standard fields in a VF page
I have a part of code where we are calling in a list and displaying the values on VF page, The code is
public void orderMod() {
string str = ApexPages.CurrentPage().getParameters().get('strSerialVal');
system.debug('----------------------------------> ' + str);
str = str.replace('_[]=c', '__c'); //parse values
str = str.replace('&', ','); //parse values
system.debug('----------------------------------> ' + str);
String[] stringLst;
stringLst = str.split(',');
system.debug('----------------------------------> ' + stringLst);
listFieldToShow.clear();
//listFieldToShow.add('Name');
for(string i : stringLst)
{
listFieldToShow.add(i);
}
system.debug('----------------------------------> QUERY LIST: ' + listFieldToShow);
setupQuery();
system.debug('----------------------------------> QUERY String: ' + theQuery);
}
The problem that I am facing is with standard fields. As standard fields do not have __c, those fields are being left out from the displayed list on the VF page.
public void orderMod() {
string str = ApexPages.CurrentPage().getParameters().get('strSerialVal');
system.debug('----------------------------------> ' + str);
str = str.replace('_[]=c', '__c'); //parse values
str = str.replace('&', ','); //parse values
system.debug('----------------------------------> ' + str);
String[] stringLst;
stringLst = str.split(',');
system.debug('----------------------------------> ' + stringLst);
listFieldToShow.clear();
//listFieldToShow.add('Name');
for(string i : stringLst)
{
listFieldToShow.add(i);
}
system.debug('----------------------------------> QUERY LIST: ' + listFieldToShow);
setupQuery();
system.debug('----------------------------------> QUERY String: ' + theQuery);
}
The problem that I am facing is with standard fields. As standard fields do not have __c, those fields are being left out from the displayed list on the VF page.
if((!str.contains('Name'))||(!str.contains('OwnerId'))){
//logic
}
But that brings me to another question, I am doing a sort and all the fields are having a sequence lets say there are City__c, Address__c, Name,State__c,OwnedID.
What would be logic so that the order is maintained. Until now it was pretty simple, but if I put something like this, then I would need a logic to get the positions of the fields.
Got any idea. Thanks.
I see you have
stringLst = str.split(',');
so the way I suggested you should be applied after splitting the String.
Regarding your next question,once you have identified the Fields you sould add them in another List in the order you want it to be.
Hope this helps !!