You need to sign in to do that
Don't have an account?
devadasu
unexpected token: SELECT at line 3 column 13
trigger doJobPostingText on Requisition__c (before insert)
{
String str1=SELECT Id from Job_Category__c;
String str2=SELECT Job_Category__c from Requisition__c;
for (Requisition a : Trigger.new)
{
if((str1)==(str2))
{
insert a;
}
else
{
a.AddError('The Discipline should Be selected According to Job Category');
}
}
}
{
String str1=SELECT Id from Job_Category__c;
String str2=SELECT Job_Category__c from Requisition__c;
for (Requisition a : Trigger.new)
{
if((str1)==(str2))
{
insert a;
}
else
{
a.AddError('The Discipline should Be selected According to Job Category');
}
}
}
try using the Single qutes around your string varables s given below:-
trigger doJobPostingText on Requisition__c (before insert)
{
String str1='SELECT Id from Job_Category__c';
String str2='SELECT Job_Category__c from Requisition__c';
for (Requisition a : Trigger.new)
{
if((str1)==(str2))
{
insert a;
}
else
{
a.AddError('The Discipline should Be selected According to Job Category');
}
}
}
Hope this should resolve your error message.
regards
pallav
1) Put your SOQL statements in square brackets [SELECT ...].
2) Are you sure those two SELECTs will always return only one record?
3) SOQL returns object records, not primitives. Thus, your first query should be
String str1=[SELECT Id from Job_Category__c].Id;
(assuming your assumption in 2) is correct)
4) The block
if((str1)==(str2)) {
insert a;
}
is redundant (and will probably either not compile or throw an error), as you are in the middle of an insert trigger
That's a start anyhow - without delving into the actual intended behaviour of your trigger.
-philbo