+ Start a Discussion
SUMANTH ELLURUSUMANTH ELLURU 

User should be able to raise a case if a position is a high priority position and hasn't got closed with a suitable profile in 30 days

User should be able to raise a case (link it with a position) if a position is a high priority position and hasn't got closed with a suitable profile in 30 days. Based on the case Title ("High priority Position not closed in 30 days"), case should be auto assigned to HR head (a user in the system).

Hi 
i need a trigger for this question and i am not having any idea
can any one help me how to start this.
Gokula KrishnanGokula Krishnan
Hi Sumanth,

I suggest you to use workflow and trigger.

1. Create a checkbox field in Case, (like: is 30 days completed?)
2. Create a workflow rule, use first criteria, and then use time based workflow to update the above checkbox field to TRUE after 30 days.
3. Create a Trigger on Case, check your logic include the above checkbox field is TRUE and assign to HR(User).
Eg:
if( 30_days_completed == TRUE && CaseTitle == "High priority Position not closed in 30 days" && Position ==  'High"){
 //assign to HR user.
}

Thanks..

If it helps you, please mark is as best answer, so it will be helpful for other developers.
SUMANTH ELLURUSUMANTH ELLURU
hi gokul
can you help me with giving trigger code.
i am new to trigger
Gokula KrishnanGokula Krishnan
Hi Sumanth,

Try this,
Trigger CaseTrg on Case(After update){
	
	User HRuser = [select id from user where UserRole.Name = 'HR Head' limit 1];
	
	List<case> CaseUpdate = new List<Case>();
	Map<id,case> OldMapval = new Map<id,Case>();
	OldMapval = Trigger.oldMap);
	
	For(Case c : Trigger.new){
		if( c.30_days_completed__c == TRUE && OldMapval.get(c.id).30_days_completed__c != c.30_days_completed__c  && c.CaseTitle == 'High priority Position not closed in 30 days' && c.Position__c ==  'High'){
			Case Cins = new Case();
			Cins.id = c.id;
			Cins..Ownerid = HRuser.id;
			CaseUpdate.add(Cins);
		}
	}
	
	// Give your Exact API names For : 30_days_completed__c,CaseTitle and Position__c
	
	If(CaseUpdate.size()>0)
		update CaseUpdate;

}

Thanks...