You need to sign in to do that
Don't have an account?
masthan khan
how to find dynamic manager for a user
Hai,
I am trying to find the manager and managers.Manager when ever a record is inserted using trigger but it throwing error variable does not exist.
Code
public class Opportunity_handler {
public string opname{set;get;}
public static void afterInsert(List<Opportunity> optylist){
for(opportunity a:optylist){
string opname;
opname=a.name;
}
opportunity op=[select id,ownerid from opportunity where name=:opname];
user ow=[select id,manager.name,manager.id from user where id=:op.ownerid];
user mg1=[select id,manager.id from user where id=:ow.manager.id];
user vp1=[select id,manager.id from user where id=:mg1.manager.id];
}
}
Error: Variable opname doesnot exist
I am trying to find the manager and managers.Manager when ever a record is inserted using trigger but it throwing error variable does not exist.
Code
public class Opportunity_handler {
public string opname{set;get;}
public static void afterInsert(List<Opportunity> optylist){
for(opportunity a:optylist){
string opname;
opname=a.name;
}
opportunity op=[select id,ownerid from opportunity where name=:opname];
user ow=[select id,manager.name,manager.id from user where id=:op.ownerid];
user mg1=[select id,manager.id from user where id=:ow.manager.id];
user vp1=[select id,manager.id from user where id=:mg1.manager.id];
}
}
Error: Variable opname doesnot exist
I suggest you change your code by EITHER removing the static keyword from the method
OR
adding the static keyword to the definition of opname