You need to sign in to do that
Don't have an account?
Jos Vervoorn
I have created 4 VF pages. 2 for case creation on comm portal (different types) and 2 for internal support agents. As we have come a long way we now also have 4 controller extensions.
However .. we would like to make it more efficient as the final method within these extensions all deal with the actual insert of the case record. We would like to create a separate class providing a single method to actually perform the insert.
Now my question is .. would .. it be easy to create another controller providing a method to actually create the case and prevent repeating the mapping of values in each extension as when we need to add/remove a field .. we need to make sure it's done in all 4 classes. if possible please share the basic idea ...
Code effeciency
I have created 4 VF pages. 2 for case creation on comm portal (different types) and 2 for internal support agents. As we have come a long way we now also have 4 controller extensions.
- case type A - Portal
- case type B - portal
- case type A - internal
- case type B - internal
However .. we would like to make it more efficient as the final method within these extensions all deal with the actual insert of the case record. We would like to create a separate class providing a single method to actually perform the insert.
//** Mapping of values for case record creation objCase.RecordTypeId = RecType.id; objCase.AssetId = AssetID; objCase.BusinessHoursId = objCase.Entitlement.BusinessHoursId; If (IsMainContactTypeValue == 'Partner'){ objCase.CaseCreatedByPartnerUser__c = true; } else { objCase.CaseCreatedByPartnerUser__c = false; } try{ insert objCase; } catch (Exception e){ System.debug('** ** ** Controller || Creation of Service Request failed ....'); }Now, in general, the mapping of these various case fields for every type of case record is the same. Some have fewer values .. could be explicitly NULL.
Now my question is .. would .. it be easy to create another controller providing a method to actually create the case and prevent repeating the mapping of values in each extension as when we need to add/remove a field .. we need to make sure it's done in all 4 classes. if possible please share the basic idea ...
Public class MyComp_XYZ extends MyComp_ABC
So this extension now contains all the 'shared' methods .... reducing code duplication.
Regards,
Jos/
All Answers
You could use the following approach.
Hope this helps.
Public class MyComp_XYZ extends MyComp_ABC
So this extension now contains all the 'shared' methods .... reducing code duplication.
Regards,
Jos/