Fix the bug in the sample and the when creating the entiry and group.
the error check condition is wrong, so write a helper function "isOKToSave" to check the condition.