You need to sign in to do that
Don't have an account?
azlane
Need help creating trigger on the case object
I am new to creating triggers and was wondering if someone could help me create the following triggers...
When a case is assigned to a specific user (meaning it is owned by a queue) and the status is New, Review or Queue, then change Status to Assigned and update Engineer field to the Case Owner.
I was told this could be done with a workflow for every Engineer value... very time consuming.
----
Also, when the case Status is updated to Reassigned, update the case owner to the Engineer value.
More information may be needed so just let me know.
Thanks
Thry the following code. Hope this ll fulfil your requirement
If you try this please let me know does it work or not.
Regards,
Samarjit
All Answers
Can you list your fields and their datatypes. And could you elaborate your first trigger.
provide field details and buzziness need in more detail manner
thanks,
Bala
Thanks for the reply.
This is will be used for internal cases. So basically when an Engineer changes ownership from a queue to their user name and set the status to New, Review or Queue, we need sfdc to update the Engineer field to populate the value of the case owner and update the status to Assigned. I can live without the Assigned status if needed. I hope these helps.
The fields involved are...
Field Label: Case Owner
Field Name: Owner
Data Type: Lookup(User,Queue)
Field Label:Engineer
API Name: Engineer__c
Data Type: Lookup(User)
Field Label: Status
Field Name: Status
Data Type: Picklist
-value needs to be either
Hi,
Try the following code and see if it is working according to your requirement
trigger CaseUpdateTrigger on Case (before update) {
for(Case c : Trigger.New){
if(c.OwnerId == userinfo.getuserId()&& c.status == 'New'){
c.Engineer__c = c.OwnerId;
c.Status = 'Assigned';
}
if(c.Status=='Assigned'){
c.ownerId = c.Engineer__c;
}
}
}
Let me know if anything goes wrong or doesn't work.
Thry the following code. Hope this ll fulfil your requirement
If you try this please let me know does it work or not.
Regards,
Samarjit
I apologize for the time it took to reply, I was out of the office. I ended up using the following and it works...
Now, I am working on creating a test class for it. Any ideas would be greatly appreciated.
To test the trigger write a test class
@isTest
private classname{
static testMethod void method(){
}
}
In this class add the test method and insert one case update it so that it will fire that trigger
Hope this helps you.