You need to sign in to do that
Don't have an account?
ehartye
Need suggestions - Trigger on CaseSolution
Those of you familiar with the table structure for Cases and Solutions know that the CaseSolution table is used to allow a many-to-many relationship.
I'm trying to trigger apex when the user adds a solution or removes one from the case. The problem is that you can do this without editing the case or the solution. You also cannot trigger on the CaseSolution SObject.
Does anyone have a suggestion for triggering on this event?
One option: Try overriding the case view page with a custom VF page that immediately redirects to the regular case detail page with the override=1 parameter so it goes to the standard page layout. You will notice that the solution attachment function is broken. Stick with me here..
If you alter your code to pass along the "a_case_soln" parameter like this:
public class caseOverrideController {
private final Id caseId;
public caseOverrideController(ApexPages.StandardController controller) {
caseId = controller.getRecord().Id;
}
public pageReference caseRedirect(){
if (ApexPages.CurrentPage().getParameters().containsKey('a_case_soln'))
return new pageReference('/'+caseId+'?nooverride=1&a_case_soln='+ApexPages.CurrentPage().getParameters().get('a_case_soln'));
else return new pageReference('/'+caseId+'?nooverride=1');
}
}
Then it will attach your solution to the case!
You could then do whatever you like from within the controller.
This will only work for solutions attached through the UI though, since it's a VF solution.
All Answers
One option: Try overriding the case view page with a custom VF page that immediately redirects to the regular case detail page with the override=1 parameter so it goes to the standard page layout. You will notice that the solution attachment function is broken. Stick with me here..
If you alter your code to pass along the "a_case_soln" parameter like this:
public class caseOverrideController {
private final Id caseId;
public caseOverrideController(ApexPages.StandardController controller) {
caseId = controller.getRecord().Id;
}
public pageReference caseRedirect(){
if (ApexPages.CurrentPage().getParameters().containsKey('a_case_soln'))
return new pageReference('/'+caseId+'?nooverride=1&a_case_soln='+ApexPages.CurrentPage().getParameters().get('a_case_soln'));
else return new pageReference('/'+caseId+'?nooverride=1');
}
}
Then it will attach your solution to the case!
You could then do whatever you like from within the controller.
This will only work for solutions attached through the UI though, since it's a VF solution.
Thank you for the quick and detailed reply.
I wound up doing something very similar. Rather than override the Case View page, I used an embedded visual force page on the page layout.