Hi there, first post so I am sorry its one coming cap in hand for help!
We have a drupal site, and we have added an entity to save data into.
However when saving (after a json submission to a service I have written), sometimes the value of one particular field does not save.
The data is in the correct format for the field
If the same data is resubmitted it will save the next time fine quite often
It doesnt happen every time, it seems to be sporadic although occasionally we get a run of a few together
For now I have put in place a workaround where by after saving the entity, the entity is reloaded and then this field is examined, and if its not correct, the code calls an update script which then reloads the entity and pushes this value into it again and saves it, but obviously thats a horrible hack and I would like it just to save correctly in the first place.
Has anyone else come across this issue with one particular field on an entity not reliably saving data?
Ive setup a variable into which I have copied the content of the entity just before I save, and I can see the value is certainly in there, but for some reason when it creates the entity it doesnt populate (sometimes) just this one field.
Thanks in advance for any help that you may be able to give me.
Regards
Simon
Comments
It sounds like you are using
It sounds like you are using custom code, how did you create the entity and what does the code look like.
(And for future reference, you can edit your own posts and change the forum it belongs in).
Hi, yes its custom code.
Hi, yes its custom code.
I populate the entity like so:
$entity->field_requeststatus = array(LANGUAGE_NONE => array(0 => array('value' => 'pending')));
$entity->field_dealer_id = array(LANGUAGE_NONE => array(0 => array('value' => $data->dealerId)));
Then when I do a save:
$entity->save();
$data->booking = entity_id("service_booking",$entity);
The field for dealerId is occasionally getting no value (its there in the entity before the save, I have emailed myself the object)
I check it after by pulling up the entity again based on the entity id I grab after it saves (into a new variable) and the dealer id hasnt saved.
Its a very peculiar behaviour and it only ever seems to effect that field.
It is NOT a data quality issues, I am 100% sure of that as I have conducted literally hundreds of tests now (its been an issue for a couple of months)
We have a workaround in place where it simply calls another script which updates the entity (I found if trying to save again in the same script the same thing will happen)
Its on amazon cloud based hosting
What type of field is 'field
What type of field is 'field_dealer_id'? Not all field types use 'value'.
The field is of type text,
The field is of type text, and is set for max length of 255
The data inserted is a string as well.
Like I said before though, if you make an identical submission multiple times (ie just clicking submit on the same data) it will save some times and not others, thats the really hard to comprehend thing for me, that you can have the same inputs but get different outputs.
Sorry for the bump, just
Sorry for the bump, just wondering if anyone else had any input?
Seems unlikely we are the first people to have this issue so would really appreciate any feedback from others who have done as well.
Hi, how did you fix this
Hi, how did you fix this issue? I'm having exactly same issue. Date field in the entity does not get saved at random times on submit. This Date field is the entity field which is in turn in a entity field (Nested entity fields). Any help will be much appreciated.