You need to sign in to do that
Don't have an account?
Arrays format.
Hi
Trying to use an array to give a field a value based on the url element 'form' which i have used from a previous page.
I cant seem to get the right format for the for loop, ths code below throws up, Compile Error: Loop must iterate over a collection type: Integer. Am a bit lost as to what to do. Please help if you can, thanks.
String[] mystrings = new String[]{'SIS__c', 'MSQ__c', 'PDQ_39__c'};
String[] mystring2 = new String[]{'StrImp', 'MSquiz', 'PDQ'};
public void PNExtMethod(){
for(Integer i : mystrings.size()){
if (ApexPages.currentPage().getParameters().get('form') == mystrings[i]){
System.debug(i);
pn.Relobject__c = mystring2[i];
}
}
}*
Man,
mystrings.size() - it's JUST ONE INTEGER DIGIT. It's not an array.
Instead of
you have to write
I hope it will help you.
All Answers
Man,
mystrings.size() - it's JUST ONE INTEGER DIGIT. It's not an array.
Instead of
you have to write
I hope it will help you.
Thank you
Sorry new to this and limited experience elsewhere.
I wonder if you could be so kind as to help a little more. The method needed to display the result is not coming to me.
I now have :
String[] mystrings = new String[]{'SIS__c', 'MSQ__c', 'PDQ_39__c'};
String[] mystring2 = new String[]{'StrImp', 'MSquiz', 'PDQ'};
public void PNExtMethod(){
for(Integer i=0; i<mystrings.size(); i++){
if (ApexPages.currentPage().getParameters().get('form') == mystrings[i]){
System.debug(i);
pn.Relobject__c = mystring2[i];
i = 100;
}
}
}
With the i set to something that will never be reached to make it hop out the loop when it has found the right value but the value isn't being given to the field pn.Relobject__c ?
Do i need to execute this higher up in the controller or does it not matter?
Do i need to change or remove the void statement?
Please your patience is appreciated.
Steve
Instead of
use
So the code wil llook like
break; will stop looping. So you will finish iteratign in loop and start doing stuff after the loop.
Thanks got it all sorted now.
sorry it was so simple but thats the sort of thing I keep falling over on.
Thanks again
Steve