Closed shafiqhossain closed 8 years ago
Text field update is working now. But similar way others still not working. Here is my code:
XmlRpcStruct integerField = new XmlRpcStruct(); XmlRpcStruct integerInnerField = new XmlRpcStruct(); node.Remove("field_fields_integer"); if (oldIntegerList.Count == 0) { XmlRpcStruct integerValueField = new XmlRpcStruct(); integerValueField.Add("value", "100"); integerInnerField.Add("0", integerValueField); integerField.Add("und", integerInnerField); } else { if (oldIntegerList.Count > 0) { int count = 0; foreach (string val in oldIntegerList) { XmlRpcStruct integerValueField = new XmlRpcStruct(); int int_val = Convert.ToInt32(val) + 5; integerValueField.Add("value", int_val.ToString()); integerInnerField.Add(count.ToString(), integerValueField); count++; } integerField.Add("und", integerInnerField); } } node["field_fields_integer"] = integerField;From Drupal log I see parameter passes structure like this:[field_fields_integer] => Array ( [und] => Array ( [0] => Array ( [value] => 100 ) ) )
Everything is updating now. I guess there could be some cache issue.
Thanks
I am struggling to update three fields. Not sure where making the mistake. Fields are not updated and there is no exception either. These fields are empty and dump shows like this:
field_fields_text_field : [Object[]]: hashcode { 23240469 }{} field_fields_integer : [Object[]]: hashcode { 17324607 }{} field_fields_entity_reference : [Object[]]: hashcode { 21703739 }{}
//text field update string oldTextValue = "Test String"; XmlRpcStruct textField = new XmlRpcStruct(); XmlRpcStruct textFieldInner = new XmlRpcStruct(); textFieldInner.Add("value", oldTextValue + " (UPDATES) "); textFieldInner.Add("format", ""); textFieldInner.Add("safe_value", oldTextValue + " (UPDATES) "); textField.Add("und", textFieldInner); node.Remove("field_fields_text_field"); node["field_fields_text_field"] = textField;
//integer field update int oldIntegerValue = 5; var newIntegerValue = oldIntegerValue + 1; XmlRpcStruct integerField = new XmlRpcStruct(); node.Remove("field_fields_integer"); integerField.Add("und", newIntegerValue); node["field_fields_integer"] = integerField;
//entity reference field update string oldEntityTitle = "Test Node"; string oldEntityID = "62";
try 1:
XmlRpcStruct entityField = new XmlRpcStruct(); string accountEntity = oldEntityTitle + " (" + oldEntityID + ")"; entityField.Add("und", accountEntity); node.Remove("field_fields_entity_reference"); node["field_fields_entity_reference"] = entityField;
try 2:
XmlRpcStruct entityField = new XmlRpcStruct(); XmlRpcStruct entityInnerField = new XmlRpcStruct(); entityInnerField.Add("target_id", oldEntityID); entityField.Add("und", entityInnerField); node.Remove("field_fields_entity_reference"); node["field_fields_entity_reference"] = entityField;
try 3:
XmlRpcStruct entityField = new XmlRpcStruct(); XmlRpcStruct entityInnerField = new XmlRpcStruct(); string accountEntity = oldEntityTitle + " (" + oldEntityID + ")"; entityInnerField.Add("target_id", accountEntity); entityField.Add("und", entityInnerField); node.Remove("field_fields_entity_reference"); node["field_fields_entity_reference"] = entityField;
try 4:
XmlRpcStruct entityField = new XmlRpcStruct(); entityField.Add("und", oldEntityID); node.Remove("field_fields_entity_reference"); node["field_fields_entity_reference"] = entityField;
none of these is updating the node. Could you please help me out on this?