[SOLVED] Cannot Upsert Financial Force Sales Invoice Object (No current comany)

We're using the Financial Force for our accounting package within Salesforce, and have written a new class for a change we're implementing which is nothing to do with Sales Invoice object. However, when we tried to deploy the change set, an error occurs on the already deployed trigger on the Sales Invoice object with a working Test Class. The error message on the deployment log shows:

Run Failures:
scmffa_SalesInvoiceTriggerTest.CodeCoverageTest System.DmlException: Update failed. First exception on row 0 with id a28i0000005KabVAAS; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, c2g.ffb_SalesInvoice: execution of BeforeUpdate

caused by: c2g.CODAException: The company must be one of the current companies.|codaCompany__c|null|2|0|

The trigger above was provided by SCM with a working Test Case, but it's throwing an error with The company must be one of the current companies. error. After some digging, I found the following:

Solution:

The problem is that the user who is deploying the change set does NOT have default company set. You can technically rewrite the Test Case to create a c2g__codaCompany__c object, and assign it within the Apex Test case, but the easier solution is to (1) create a user company, and (2) selecting the company for that user. This should already be done for the user anyways. Also, it's important to use @isTest(SeeAllData=true) so that you don't have to dynamically create the company within your test case.

  1. Click on the + (Plus) Tab, and choose User Companies menu item.
  2. Salesforce Plus Tab

  3. Create a new User Company for the user.
  4. User Companies

  5. Login as the user who will be deploying the change set, and Select a default Company for the user.
  6. Select Company

By creating a user company and selecting the default company for the user who will be deploying the change, The company must be one of the current companies" error will disappear.

Comments

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.