Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get Apex Trigger to Deploy in Production #199

Closed
sharoncannon opened this issue Jun 29, 2015 · 17 comments
Closed

Can't get Apex Trigger to Deploy in Production #199

sharoncannon opened this issue Jun 29, 2015 · 17 comments

Comments

@sharoncannon
Copy link

I'm relatively new to all of this, but had no issues following the steps through and deploying in our sandbox. I've now gone to manually go through the process again in our production org and for some reason the apex trigger just will not deploy - it's for opportunities. We have other triggers in place working already.
I get a message saying it's deployed, and then to "deploy it". No error messages saying it can't deploy.

I've double checked that an existing trigger of this name does not exist, and also checked that it's not showing under Apex triggers - I can see our pre-existing ones.

capture

Any suggestions gratefully received as I need this to urgently resolve some financial roll-ups.

@LALeif
Copy link

LALeif commented Jun 30, 2015

Hi Sharon,
I am having the same issue, it looks like some existing Test Calsses are not working which is causing the Test Coverage to be too low. I came to this page to log my own issue but I think I will log it here with yours, as the core problem is the same.

The problem I found is that one of the TestTrigger classes that was setup in 2013 is causing an error becasue the field type of the Custom Object Name was changed from Text to Autonumber. No matter what I try, I cannot change the filed name in the Test Class. I have tried to use Eclipse and Force.com IDE to comment out the field, rename it, and save it but I always get the same error :
image. I have been able to save the changes to my sandbox, but when I validate the Change Set, the error comes up again:
image

This seems like such a simple problem to resolve, but now I have spent hours on it! Does anyone have any suggestions to get around this? Thanks in advance if you have any suggestions!

@sharoncannon
Copy link
Author

I was originally on 1.1, so have upgraded both production and sandbox to 1.2 which now gives me the coverage error. I rebuilt all the triggers in the sandbox to make sure they had the additional line mentioned in a previous issue and have tried using a change set to deploy the changes with no joy so far. The test classes are still all failing with not enough coverage, and I tried removing one to see if that stopped the error in production, and I can't even remove them from production at the moment. Will have to see if I can edit to add the line in mentioned. Although I've not edited previously so will have to see how I go.

@sharoncannon
Copy link
Author

Error I get is the following for code coverage - nothing else. The opportunity trigger is one I'm trying to deploy and doesn't exist already which is concerning as it's been updated as suggested in the previous post.

capture2

@afawcett
Copy link
Collaborator

afawcett commented Jul 1, 2015

Please make sure you are using v1.20 and also your generated test class code (shown on the Manage Child Trigger page) has call to "dlrs.RollupService.testHandler" it. If it does not, please go back to your Sandbox, click Manage Child Triggers, then allow it to remove the trigger and test classes, then re-deploy it (by clicking Deploy on the same page), this will generate a new style test class. This new style test class will give you more information as to the underlying issue causing the code coverage, which is likely that the child objects require more test data to be passed to them in the test code.

@afawcett
Copy link
Collaborator

afawcett commented Jul 1, 2015

Also @LALeif the challange with the tool as it is now, and as the platform was until recently (prior to Summer'15), is that when new code is deployed to production (even via this tool), ALL tests had to be re-run and pass. It seems you've got some old tests that while may have run in the past no longer do, this is a pain to have to resolve these for sure, but better in the long run as they will be doing their job better. As an aside, since Summer'15, the underlying SF Metadata API now permmits my code in the tool to deploy its code to production and only insist on the its test working and not existing ones, this will for sure make this particular pain your going through with historic tests failing, go away. Its a high priority enhancement for me to make, but i don't yet have time scales for from me personally, though their are now a few other community developers working on this tool.

@sharoncannon
Copy link
Author

Hi,

Have done all of that, as a previous article suggested, but I can’t deploy the updated ones to production. It all works merrily in Sandbox.
I can’t even remove and re-generate the old ones in production to get the new testhandler in due to the code coverage issue. I also get the same issue trying to manually deploy using the manage trigger in live on a completely newly created rollup.

Guessing I’ll need to try and manually put that in using the Developer console (of which I have virtually no experience so hoping it’s as simple as copy, paste, save)??

Thanks

Sharon Cannon | Global PMO Manager

[http://www.phoenixbs.com/Libraries/Phoenix-Logo-2014/Phoenix-logo-2014_smaller.tmb.ashx?width=150&height=150&decreaseOnly=true]http://www.phoenixbs.com/
Phone: +44 203 142 8223
Mobile: +44 7425 621 894
Email: [email protected]
www.phoenixbs.comhttp://www.phoenixbs.com


Abu Dhabi | Chicago | London | New York | Sydney


From: Andrew Fawcett [mailto:[email protected]]
Sent: 01 July 2015 13:52
To: afawcett/declarative-lookup-rollup-summaries
Cc: Sharon Cannon
Subject: Re: [declarative-lookup-rollup-summaries] Can't get Apex Trigger to Deploy in Production (#199)

Please make sure you are using v1.20 and also your generated test class code (shown on the Manage Child Trigger page) has call to "dlrs.RollupService.testHandler" it. If it does not, please go back to your Sandbox, click Manage Child Triggers, then allow it to remove the trigger and test classes, then re-deploy it (by clicking Deploy on the same page), this will generate a new style test class. This new style test class will give you more information as to the underlying issue causing the code coverage, which is likely that the child objects require more test data to be passed to them in the test code.


Reply to this email directly or view it on GitHubhttps://github.com//issues/199#issuecomment-117649414.

Phoenix Business Solutions Ltd.
Registered in England No. 04826350 VAT No. 819 4726 03
Note: The information contained in this email is confidential & may be legally privileged. If you are not the intended recipient, you must not read, use or disseminate that information. Although this email and any attachments are believed to be free of any virus, or any defect that might affect any computer or IT system into which they are received or opened, it is the responsibility of the recipient to ensure that they are virus free and no responsibility is accepted by Phoenix Business Solutions for any loss or damage arising in any way from receipt or use thereof.

@afawcett
Copy link
Collaborator

afawcett commented Jul 1, 2015

Yes a copy and paste and save will do it. Though you should be able to re-generate the test code via Manage Child Trigger page OK in Sandbox, where the platform doesn't run the tests automatically. Have you tried that?

@sharoncannon
Copy link
Author

Yup, that's where I'm picking up the code from. It won't allow me to make changes to the live org meta data if I copy, paste and save (using the dev console). Any ideas for getting around this?

Have tried all of your previous suggested steps in Sandbox.

  1. Upgrade (and checked the version)
  2. Regenerate triggers
  3. Check everything in sandbox
  4. Re-run the tests on their own in Production - ironically they pass
  5. Try removing to re-generate in live (no luck - does the same thing manually deploying a roll up does)

If I can get the testhandler into live least then I might be able to get a better error when I manually deploy at least. Everything including removing and re-generating the triggers in the sandbox works perfectly. Our sandbox is a full sandbox, and is about a month old, so no major differences.

@afawcett
Copy link
Collaborator

afawcett commented Jul 1, 2015

Yes, getting the testhandler version of the test into live will get you a better error thats the use case it was designed to help with. Can you issue a Change Set with it? That's the other way of doing this, promote the trigger and test for DLRS via a Change Set, then all you do is define the rollup and tick active checkbox, you don't need to use Manage Child Trigger in production so long as the trigger gets in one way or another.

@afawcett
Copy link
Collaborator

afawcett commented Jul 1, 2015

I've recently written up some shared details on the code coverage issue described in this case, please check the details here and comment at the bottom of the wiki page.

@sharoncannon
Copy link
Author

Thanks. Have tried change sets with no joy, even trying to update the older ones. Will see if I can bang together some code to get it through referencing some samples. Otherwise will have to find another option in the interim.

@afawcett
Copy link
Collaborator

afawcett commented Jul 3, 2015

@sharoncannon how did you get on?

@afawcett
Copy link
Collaborator

afawcett commented Jul 4, 2015

I've marked this as an enhancement, as i am at least going to provide a better means to customise the generated test code without having to jump through hoops with Developer Console etc. My idea is to allow a Text Area field on the Rollup itself to allow the user to paste code that will override the generated test code. This will be used by Manage Child Rollup page and of course will get migrated along with the rest of the rollup config to production or other orgs. So keeps things in one place basically. I know this doesn't resolve the core issue, but i hope will ease the pain of sorting these type of issues.

@sharoncannon
Copy link
Author

Hi,

I managed to get my opportunity one to have ironically 100% code coverage, but then it stopped working and starting complaining due to the opportunity validation rules.
The rest will have to wait until I get back from annual leave and can sit down with one of our developers to fix this for me. I’ve got a temporary work around in place in the short term.
He’ll probably need to end up talking to someone at Financial Force – I was struggling with the validation for the Rev Rec Transaction line – It needs certain id’s etc, but I’m sure developer will get his head around that much faster than I have time for at present.

I’ll keep you updated, but thanks for your help the other day.

Cheers

Sharon Cannon | Global PMO Manager

[http://www.phoenixbs.com/Libraries/Phoenix-Logo-2014/Phoenix-logo-2014_smaller.tmb.ashx?width=150&height=150&decreaseOnly=true]http://www.phoenixbs.com/
Phone: +44 203 142 8223
Mobile: +44 7425 621 894
Email: [email protected]
www.phoenixbs.comhttp://www.phoenixbs.com


Abu Dhabi | Chicago | London | New York | Sydney


From: Andrew Fawcett [mailto:[email protected]]
Sent: 03 July 2015 18:26
To: afawcett/declarative-lookup-rollup-summaries
Cc: Sharon Cannon
Subject: Re: [declarative-lookup-rollup-summaries] Can't get Apex Trigger to Deploy in Production (#199)

@sharoncannonhttps://github.com/sharoncannon how did you get on?


Reply to this email directly or view it on GitHubhttps://github.com//issues/199#issuecomment-118397307.

Phoenix Business Solutions Ltd.
Registered in England No. 04826350 VAT No. 819 4726 03
Note: The information contained in this email is confidential & may be legally privileged. If you are not the intended recipient, you must not read, use or disseminate that information. Although this email and any attachments are believed to be free of any virus, or any defect that might affect any computer or IT system into which they are received or opened, it is the responsibility of the recipient to ensure that they are virus free and no responsibility is accepted by Phoenix Business Solutions for any loss or damage arising in any way from receipt or use thereof.

@afawcett
Copy link
Collaborator

afawcett commented Jul 5, 2015

Sure no problem, enjoy your holiday! 👍

@afawcett
Copy link
Collaborator

afawcett commented Jul 6, 2015

v1.21 includes a Test Code field to make it easier to apply custom test code. I'll close this enhancement now, but happy to keep chatting here if you need more help with the test code.

@afawcett afawcett closed this as completed Jul 6, 2015
@afawcett
Copy link
Collaborator

afawcett commented Jul 6, 2015

Oh ment to say have added a new field 'Test Code' which will, as i proposed above, allow you to paste in alternative code for the tool to use when deploying tests. This avoids the need to manually edit outside the tool via Developer Console. You can also keep the alternative test code in the same place as the rollup definition, so easier to manage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants