You need to sign in to do that
Don't have an account?
Simple---Very Uregent..pls help
for(Ordr__c o : Trigger.new)
{
//record created by manager, assign ownership to employee
if(o.Employee__c!=null)
{
if(employeeMap.get(o.Employee__c).User_Name__c==null)
{
o.OwnerId=employeeMap.get(o.Employee__c). State__r.Mkt__r.AGM__c ;
}
What i am basically doing is i have an order in which there is an employee field which is a look up to employee and employee is look up to user
When employee field is nul in an order the owner of the order should be assigned to the market agm
When i am trying to make the employee field blank and save its not getting updated....Could you say where shuld i make a change
It would be a little easier, if you show us your query with all related objects and releated fields.
You're filtering out Employee Records where the User_Name is NULL in your SOQL Query
Map<Id,Employee__c> employeeMap=new Map<Id,Employee__c>([Select Id, User_Name__c,State__r.Mkt__r.AGM__c
from Employee__c Where Id in:employeeIds and User_Name__c!=null]);
Naturally,
if(employeeMap.get(o.Employee__c).User_Name__c==null)
will never be true therefore, as there isn't an Employee Record with a NULL User_Name__c thanks to your query above.
if(employeeMap.get(o.Employee__c)==null)
{
o.OwnerId=employeeMap.get(o.Employee__c).State__r.Mkt__r.AGM__c;
}
the original query is this way.
What i am basically doing is i have an order in which there is an employee field which is a look up to employee and employee is look up to user
When employee field is nul in an order the owner of the order should be assigned to the market agm
When i am trying to make the employee field blank and save its not getting updated....Could you say where shuld i make a change
I'd say get rid of the User_Name__c != null in your SOQL Query.
So,
Map<Id,Employee__c> employeeMap=new Map<Id,Employee__c>([Select Id, User_Name__c,State__r.Mkt__r.AGM__c
from Employee__c Where Id in:employeeIds ]);
I did that way but its not getting upsdated