fix some bug which causes the 'add()' method to fail
on inserting into database. improved the createRecord and added
condition
whether to populate Id if for edit and keep it null if its a new record.