You need to sign in to do that
Don't have an account?
Staci
update field trigger help
I have a trigger that I want to change the substatus based on the profile of the Case Owner field. This is what I have, but its not updating the Substatus and I'm not sure if this (objCase.Owner.Profile.Name) is right. Any help would be grately appreciated.
trigger CW_Update_Substatus_based_on_Case_Owner on Case (before update)
{
for (Case objCase : Trigger.new)
{
if (objCase.Owner.Profile.Name == 'CW Dealer Portal User')
{
objCase.Substatus__c = 'Open with Dealer';
}else{
if (objCase.Owner.Profile.Name == 'CW MineStar Support - Tier 2')
{
objCase.Substatus__c = 'Open with Support Advocates';
}
else
{
objCase.Substatus__c = 'Open with Product Specialists';
}
} }
}
trigger CW_Update_Substatus_based_on_Case_Owner on Case (before update)
{
for (Case objCase : Trigger.new)
{
if (objCase.Owner.Profile.Name == 'CW Dealer Portal User')
{
objCase.Substatus__c = 'Open with Dealer';
}else{
if (objCase.Owner.Profile.Name == 'CW MineStar Support - Tier 2')
{
objCase.Substatus__c = 'Open with Support Advocates';
}
else
{
objCase.Substatus__c = 'Open with Product Specialists';
}
} }
}
if this was helpful, hit the Like link.
All Answers
and then modify your IF conditions something like this:
if this was helpful, hit the Like link.
trigger CW_Update_Substatus_based_on_Case_Owner on Case (before update)
{
Map<Id,Case> caseMap = new Map<Id,Case>([Select Id,Owner.Profile.Name from Case where Id IN : Trigger.new]);
for (Case objCase : Trigger.new)
{
if (caseMap != null && caseMap.containsKey(objCase.Id) && caseMap.get(objCase.Id).Owner.Profile.Name == 'CW Dealer Portal User')
{
objCase.Substatus__c = 'Open with Dealer';
}else{
if (caseMap != null && caseMap.containsKey(objCase.Id) && caseMap.get(objCase.Id).Owner.Profile.Name == 'CW MineStar Support - Tier 2')
{
objCase.Substatus__c = 'Open with Support Advocates';
}
else
{
objCase.Substatus__c = 'Open with Product Specialists';
}
} }
if this was helpful, hit the Like link.