the sharing model cannot be updated through the api

Now I’m sure there’s a reason for this but it makes me sad a bit. Especially when working with a team of developers. Recently I found myself in the following situation,

My team and I had been building a Force.com application and were interested in implementing an UAC model. We had setup the UAC model on one of the Orgs using profiles, roles and sharing rules(we had some issues here too) and then attempted to commit these changes into our SVN repository. Happy that things were going so well, each developer checked out the code and BHAM! we were no longer able to deploy object definitions. [Slow pan to me on my knees screaming to the heavens. A thunderbolt, then a thunderclap overhead]

The reason given by the compiler was ‘the sharing model cannot be updated through the api’ and I immediately googled it expecting a neat, precise solution. Not so my friend, not so. As of this moment the first result links to a forum post that offers something in the way of a few suggestions, one of which would’ve been right for me, had it included the necessary steps(I was a sharing-model n00b at this point. Don’t judge me).

After finding nothing more than suggestions I gave up my search, and instead hacked the object definition I wanted to deploy. The hack involved scrolling to the end of the object file and changing the <sharingModel></sharingModel> node to contain the value the compiler said it needed. Of course in doing this I lost the UAC implementation but it fixed the issue.

Well that’s all for today’s post, hopefully that’ll help you too.. wait, what’s that? You want a proper solution? What do you mean by proper exactly? Not a hack? Well that’s how we roll here in London buddy, we hack first and ask questions later. We iz l33t. Okay not really.

So the first time I got the error I guessed there’d be something in the setup menus, but after a brief search I couldn’t find it. Having a mountain of more important things to do I hacked the object file and carried on my merry way. The problem, however, kept on popping up because different developers kept on committing different versions of the object files into the repository. I thought it would save time in the long run to systematically make my way through the setup menus and find the blasted link. And it did. I found the little guy by clicking Setup > Security Controls(Under ‘Administration Setup’) > Sharing settings.

Of course this fixed one developer’s Org at a time. If anyone forgot to do this, then commited an older version of the object back into the repository we’d have the same issue again. We now have to follow this procedure anytime we make sharing model changes,

  1. Developer making changes commits into repository.
  2. ALL other developers immediately change the sharing model for the object in question to that of the new object description.
  3. ALL other developers check the new object definition out.
  4. Verify because even though I put it in caps, someone will not implement steps 2 and 3.
  5. Keep on truckin’.

Perhaps someone from the Force could enlighten us as to the reason for this restriction? Pretty please.. because as our team grows the above procedure becomes more tiresome to implement.

1 thought on “the sharing model cannot be updated through the api”

  1. Face with the same issue.
    I have to implement something like UAC for one object. Trying to validate this through Force.com IDE Ant migration tool. Received annoying “The sharing model cannot be updated through the API.” This means I can’t validate my changes against production if any older unit tests fail until I update sharing model on production. But we don’t want to update sharing model on production until the release date. Closed circle if you know what I meant. Strange, that this wasn’t changed for last 5 years.

    Reply

Leave a Comment