You need to sign in to do that
Don't have an account?
test test 5030
Getting error in post install script in managed packe
Hello,
We are created a apex code to update view with visualforce page in managed package. We are calling apex code as a post install script in the managed package and below is the code.
global class PostInstallClass implements InstallHandler {
global void onInstall(InstallContext context) {
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
MetadataService.ActionOverride actionOverrides1 = new MetadataService.ActionOverride();
actionOverrides1.actionName = 'View';
actionOverrides1.type_x = 'Visualforce';
actionOverrides1.content = 'VFAPIPage';
actionOverrides1.comment = 'Configure Visual Force page with Opportunity.';
MetadataService.CustomObject customObject = new MetadataService.CustomObject();
customObject.fullName = 'Opportunity';
customObject.actionOverrides = new MetadataService.ActionOverride[] { actionOverrides1 };
service.updateMetadata( new MetadataService.Metadata[] { customObject });
}
}
The packaging is not installaling and giving post install error message and below is the error message.
Message : You have uncommitted work pending. Please commit or rollback before calling outLine no : 10822 getStackTraceString Class.recoapi.MetadataService.MetadataPort.updateMetadata: line 10822, column 1 Class.recoapi.PostInstallClass.UpdateView: line 21, column 1 Class.recoapi.PostInstallClass.onInstall: line 3, column 1null
The apex code is working fine in my organization but its not woking in destion instance while installing managed package with post install script.
Please share possible options with us, to change opportunity view with visualforce page using apex code.
We are created a apex code to update view with visualforce page in managed package. We are calling apex code as a post install script in the managed package and below is the code.
global class PostInstallClass implements InstallHandler {
global void onInstall(InstallContext context) {
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
MetadataService.ActionOverride actionOverrides1 = new MetadataService.ActionOverride();
actionOverrides1.actionName = 'View';
actionOverrides1.type_x = 'Visualforce';
actionOverrides1.content = 'VFAPIPage';
actionOverrides1.comment = 'Configure Visual Force page with Opportunity.';
MetadataService.CustomObject customObject = new MetadataService.CustomObject();
customObject.fullName = 'Opportunity';
customObject.actionOverrides = new MetadataService.ActionOverride[] { actionOverrides1 };
service.updateMetadata( new MetadataService.Metadata[] { customObject });
}
}
The packaging is not installaling and giving post install error message and below is the error message.
Message : You have uncommitted work pending. Please commit or rollback before calling outLine no : 10822 getStackTraceString Class.recoapi.MetadataService.MetadataPort.updateMetadata: line 10822, column 1 Class.recoapi.PostInstallClass.UpdateView: line 21, column 1 Class.recoapi.PostInstallClass.onInstall: line 3, column 1null
The apex code is working fine in my organization but its not woking in destion instance while installing managed package with post install script.
Please share possible options with us, to change opportunity view with visualforce page using apex code.
The issue happens if you are doing a DML before you do a Callout .
Please refer below links for similar discussion this may help you out.
https://developer.salesforce.com/forums/?id=906F00000008vMmIAI
http://salesforce.stackexchange.com/questions/41440/system-calloutexception-you-have-uncommitted-work-pending
http://salesforce.stackexchange.com/questions/58436/apex-batch-you-have-uncommitted-work-pending-please-commit-or-rollback-before
http://salesforce.stackexchange.com/questions/36494/you-have-uncommitted-work-pending-please-commit-or-rollback-before-calling-out
http://salesforce.stackexchange.com/questions/40583/you-have-uncommitted-work-pending-please-commit-or-rollback-before-calling-out
Hope this helps you!
If this helps you mark it as solved it will make available for others as a proper solution.
Thanks and Regards
Sandhya