You need to sign in to do that
Don't have an account?
jcald
Can IF statement change id in MyController side apex code?
Im kinda in a pickle of sorts....and I don't know how to go about this but here it goes....
I have an amount field, depending on the range amount (for ex. 3000-9999, 10000-14999, and 15000-20000). I would like to change the id in MyController
CONTROLLER:
public Price_Range__c getRate4() {
return [SELECT Range_Rate_Month24__c FROM Price_Range__c WHERE Id =: 'a67K00000004Emt' LIMIT 1];
}
VF PAGE:
<td><apex:outputtext value="{0, number, $000.00}">
<apex:param value="{!Worksheet__c.Points__c*Worksheet__c.Finance_Amount__c*Rate4.Range_Rate_Month24__c}"/>
</apex:outputtext>
</td>
Would it better to create an IF statement on the Amount field (Formula/Number), or create a hidden field based on the range and do a call out like:
IF( Finance_Amount__c >149999, "WHERE Id =:'a67K00000004Emt'",
IF(Finance_Amount__c >99999, "WHERE Id =:'a67K00000004Emy'",NULL
))
This compiles but I don't know if this is the right way to do this. Can someone share their knowledge on how to go about this?
Thanks
I have an amount field, depending on the range amount (for ex. 3000-9999, 10000-14999, and 15000-20000). I would like to change the id in MyController
CONTROLLER:
public Price_Range__c getRate4() {
return [SELECT Range_Rate_Month24__c FROM Price_Range__c WHERE Id =: 'a67K00000004Emt' LIMIT 1];
}
VF PAGE:
<td><apex:outputtext value="{0, number, $000.00}">
<apex:param value="{!Worksheet__c.Points__c*Worksheet__c.Finance_Amount__c*Rate4.Range_Rate_Month24__c}"/>
</apex:outputtext>
</td>
Would it better to create an IF statement on the Amount field (Formula/Number), or create a hidden field based on the range and do a call out like:
IF( Finance_Amount__c >149999, "WHERE Id =:'a67K00000004Emt'",
IF(Finance_Amount__c >99999, "WHERE Id =:'a67K00000004Emy'",NULL
))
This compiles but I don't know if this is the right way to do this. Can someone share their knowledge on how to go about this?
Thanks
Public Id;
public Price_Range__c getRate4() {
if(Finance_Amount__c >149999){
id='a67K00000004Emt';
}
else if(Finance_Amount__c >99999 && Finance_Amount__c <149999){
id='a67K00000004Emy';
}
return [SELECT Range_Rate_Month24__c FROM Price_Range__c WHERE Id =:id LIMIT 1];
}
Worksheet id;
public Price_Range__c getRate4_1() {
if(Finance_Amount__c >149999){
id='a67K00000004Emt';
}
if(Finance_Amount__c >99999){
id='a67K00000004Emy';
}
return [SELECT Range_Rate_Month24__c FROM Price_Range__c WHERE Id =:id LIMIT 1];
}
ERROR: Variable does not exist" Finance_Amount__c
can someone show me how to create a variable from a field? is it something like this....
Finance_Amount__c Amount;
Amount = [SELECT Finance_Amount__c FROM Worksheet__c WHERE Id =: '(worksheet.id)' LIMIT 1];
Error: WorksheetLender Compile Error: Illegal assignment from LIST<Worksheet__c> to worksheet at line 34 column 1
Controller:
public Price_Range__c getRate4_1() {
Worksheet amount = [SELECT Finance_Amount__c FROM Worksheet__c WHERE Id =: '01IK0000000ECGv' LIMIT 1];
if(amount >149999){
mylender='a67K00000004Emt';
}
if(amount >99999){
mylender='a67K00000004Emy';
}
return [SELECT Range_Rate_Month24__c FROM Price_Range__c WHERE Id =:mylender LIMIT 1];
}
Change the 2nd line as below
Decimal amount=[SELECT Finance_Amount__c FROM Worksheet__c WHERE Id =: '01IK0000000ECGv' LIMIT 1].Finance_Amount__c;
Error: WorksheetLender Compile Error: Illegal assignment from String to worksheet at line 41 column 1
public Price_Range__c getRate4() {
Worksheet A;
Decimal amount=[SELECT Finance_Amount__c FROM Worksheet__c WHERE Id =: '01IK0000000ECGv' LIMIT 1].Finance_Amount__c;
if(amount >149999){
A='a67K00000004Emt'; (line 41)
}
else if(amount >99999 && a <149999){
A='a67K00000004Emy';
}
return [SELECT Range_Rate_Month24__c FROM Price_Range__c WHERE Id =:A.id LIMIT 1];
}
please help Thanks