Customer IsSavable behavior

Hello,

Quick question on the ‘IsSavable’ field behavior on a Customer record (and likely on other data entities as well) - I am observing that IsSavable can be equal to ‘false’ in instances where there are no errors listed in BrokenRulesCollection.

Is this because IsSavable can also be set to false when there are simply no changes to be saved on the Customer record? Or is there another possible cause? What I am observing is this is indeed the case - if I have at least one field updated, IsSavable gets flipped to true, but if not it stays false; however I want to ensure this is not a coincidence before updating my error handling code.

I can supply code snippets/data we are passing in if needed.

Thanks so much for any help on this,
Alex

Hi Alex. There are child collections on the parent objects, in your case the contacts. One of these is likely invalid. You can’t save the parent if a child is invalid since saving the parent also saves the child collection. What you’ll need to do is iterate through the children and check their business rules and IsValid status.

Interesting - got it, that makes sense. I will update my code to loop through child entities as well.

One follow-up though - in debug mode, I purposely stepped over my check for ‘IsSavable’ to see if it would still happen to save, and it did when I ran Customer.Save(). So IsSavable was false, yet I was able to save the Customer.

Does this make sense and could it still be due to the child entities? Or is that something else? This was a case where nothing actually changed on the Customer so it is tough to tell if it actually saved the record or not, but it at least did not throw an error back to me.

Alex

Yes, IsSavable can be false and you can call save. It won’t really do anything because the object is likely not dirty. You can check IsDirty to see if that is true/false, IsSavable depends on IsDirty.