INVALID_FIELD_FOR_INSERT_UPDATE - Dependent class is invalid and needs recompilation:

417 views
Skip to first unread message

ksogo...@gmail.com

unread,
Oct 27, 2017, 2:28:46 PM10/27/17
to Illuminated Cloud Q&A

Hi Scott,

I added a new module to my existing workspace, then added it to SVN.  Retreval of the data from the salesforce site is not a problem.  However, I can't get the "Save" or "Force Save" to work and some kind of errors like:

Deployment Failed
                    INVALID_FIELD_FOR_INSERT_UPDATE - Dependent class is invalid and needs recompilation:
                    Class <ClassName> :
                    SELECT ID, CompanyName, Username FROM USER
                    ^
                    ERROR at Row:1:Column:12
                    No such column 'CompanyName' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

OR another example:

Deployment Failed: DUPLICATE_VALUE - duplicate value found: <unknown> duplicates value on record with id: <unknown>


However, this class and all other classes I tried are saved no problem directly inside the saleforce site, etc.  So far I haven't been able to save any classes from this new module yet because it is complaining about dependent class needing recompilation or a duplicate value.  Other modules work fine.

Any ideas what might be causing this?

Appreciate your help,

Karine

Scott

unread,
Oct 27, 2017, 2:59:40 PM10/27/17
to Illuminated Cloud Q&A
Karine, do you mind turning off Apex deployment via the Tooling API to see if the problem still occurs. I've seen a class of issues, albeit rare, when deploying specifically through the Tooling API. I want to start by seeing if these issues fall into that category. You can disable Tooling API deployment via Illuminated Cloud>Configure Application>Validation and Deployment where you'll uncheck Prefer Tooling API for>Apex. Let's start there and see whether that tells us more.

Regards,
Scott

ksogo...@gmail.com

unread,
Oct 27, 2017, 3:26:53 PM10/27/17
to Illuminated Cloud Q&A


Thank you very much, Scott, for the speedy reply!  That actually worked and I am able to save my changes.  

Should I keep the setting off for now?   What would that affect?

Thanks again,
Karine


Scott

unread,
Oct 27, 2017, 3:30:20 PM10/27/17
to Illuminated Cloud Q&A
Oh, that's good to hear (well, as good as an inconsistency between two supposedly equivalent APIs can be!). So here's where things get interesting...now re-enable the Tooling API and see if things just work. I believe this particular issue you're hitting only occurs when first creating an Apex class through the Tooling API if it contains references to certain system fields. Once the classes are created everything should work fine. Let me know if it doesn't.

Regards,
Scott

ksogo...@gmail.com

unread,
Oct 27, 2017, 3:32:49 PM10/27/17
to Illuminated Cloud Q&A

Scott,
Just double-checked and my visualforce components and static resource deployment were also not working with the setting checked.  So I unchecked all the boxes for "Prefer Tooling API for" and it's working.

is there any downside to having it unchecked?

Thanks!

Karine

Scott

unread,
Oct 27, 2017, 3:55:59 PM10/27/17
to Illuminated Cloud Q&A
Yes. The metadata API tends to be quite a bit slower on average than the tooling API, so whenever possible I do recommend using the tooling API for deployment. In my experience it's the difference between a couple of seconds to save a single file and potentially up to minutes of the metadata API deployment queues aren't being friendly.

Regards,
Scott
Reply all
Reply to author
Forward
0 new messages