You need to sign in to do that
Don't have an account?
Please correct the error in SOQL statement
List<LQPricebook__c> lqp = new list<LQPricebook__c>();
//////////////////////////////////////////////////////
///6 PriceBook Check////////////////
//////////////////////////////////////////////////////
lqp = [SELECT ID, Name, ValidForm__c
FROM LQPricebook__c WHERE clm.Claim_Invoice_Date__c >= LQPricebook__c.ValidForm__c
and (clm.Claim_Invoice_Date__c <= LQPricebook__c.ValidForm__c + ((365/12)* 3))
];
if (lqp.size() != 0){
System.debug( 'exists' +lqp[0].ID);
clm.Pricebookno__c = lqp[0].ID ;
}else {
clm.Pricebookno__c = NULL;
}
In tthe above code I am getting an eror in SOQL statement. Could anyone can tell me whats the wrong in that??
I am getting an error like 'Unexpected token: LQPricebook__c.ValidFrom__c'
Thanks in advance
Simple typo - clm needs a : in front of it to make it a bind variable:
All Answers
The right hand side of a condition in a where cause must be a literal, so having the following:
is not allowed because 'LQPricebook__c.ValidForm__c' is not a literal value, rather it is the value of another field. I also can't see where 'clm' is coming from - it doesn't appear in the code or SOQL query.
Can you be more clear,what you want top achieve and what is clm here.
List<Claim__c> stdClaims = new List<Claim__c>();
for(Integer i = 0; i < Trigger.new.size(); i++){
Claim__c clm = Trigger.new[i];
System.debug('trigger claim number: ' + i);
try{
List<LQPricebook__c> lqp = new list<LQPricebook__c>();
//////////////////////////////////////////////////////
///6 PriceBook Check///////////////
//////////////////////////////////////////////////////
lqp = [SELECT ID, Name, ValidForm__c
FROM LQPricebook__c WHERE clm.Claim_Invoice_Date__c >= LQPricebook__c.ValidForm__c
and (clm.Claim_Invoice_Date__c <=
LQPricebook__c.ValidForm__c + ((365/12)* 3))
//IsPublished__c =: True
//and Status__c = 'Active'
];
if (lqp.size() != 0){
System.debug( 'exists' +lqp[0].ID);
clm.Pricebookno__c = lqp[0].ID ;
}else {
clm.Pricebookno__c = NULL;
}
} Catch(Exception ee) {
System.debug('ClaimTrigger exception '+ee);
}
The above mentioned code is clear I guess
But I am geeting an error still
What I need to get is like
If the Claim date is between in the LQpricebook.validfrom__c and LQPricebook__c.ValidForm__c + ((365/12)* 3
then It will return the ID of the LQPricebook__c
I think you are trying for related fields....if yes then use '__r'.
And if not then brief it what you want to do...specially after that FROM part.
Your SOQL is the wrong way around. You can use the clm variable on the right hand side, not the left, so you have to invert the operators e.g.:
also, you can't apply calculations to the field value like:
You'll have to create a formula field that contains this value and then query against that.
As you said I changed like this
lqp = [SELECT ID, Name, ValidForm__c
FROM LQPricebook__c WHERE LQPricebook__r.ValidForm__c <= clm.Claim_Invoice_Date__c
//and (clm.Claim_Invoice_Date__c <=
//LQPricebook__r.ValidForm__c + ((365/12)* 3))
//IsPublished__c =: True
//and Status__c = 'Active'
];
This time I want to test only for one condition but I am getting the error this time on
Error:'Unexpected token clm.Clain_Invoice_Date__c'
I dont have any clue how to solve this???
Could u guys give some ideas
Thanks in advance
Simple typo - clm needs a : in front of it to make it a bind variable:
Thanks
Super!!!!!!