2

There are a couple of classes failing with the following errors for a particular user who is trying to install a Managed package : "System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Acct Region on Opportunity is required field!: [Region__c]"

What are the potential ways to resolve this type of unit test error while installing managed package?

5

Sounds like the unit tests in the managed application are creating an Opportunity and are not including a custom field called Region__c. To get the application to install, disable the validation rule that requires the Region field.

If you are the owner of the managed package and need to be able to work around customizations that have been made to objects included in the package, then you have a few options. Look at SmartFactory. It uses describes to get a list of all fields in an object and fills them all with data. Alternately you can provide hooks for your customers to define their own data needs. I remember seeing a blog post about creating an interface that you can implement to define data. Can't find the link now.

  • Sure, I verified that our managed package does not have any "custom field called Region__c". So this is user specific customization where they have a custom field as required. So in future there might be a different person having his own custom field attached to an opportunity as a required field and they might again be unsuccessful in installation of the managed package... Other than each user "disable the validation rules while installation" is there any other approach that can be implemented on the code (Before creating a new package) that will avoid such installation issues? – user2507024 Aug 26 '13 at 19:43
  • 2
    Take a look at SmartFactory. It uses describes to get a list of all fields in an object and fills them all with data. Alternately you can provide hooks for your customers to define their own data needs. I remember seeing a blog post about creating an interface that you can implement to define data. Can't find the link now. – Daniel Hoechst Aug 26 '13 at 20:02
  • Daniel, appreciate your help. I will research and update the post so that it might help the community in future. – user2507024 Aug 26 '13 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.