I am inserting field values in Sitecore using Sitecore web service. If my field is a Single-Line text then it is inserting fine. But when it is a Multilist type there is no insertion.
Here is the code where I am adding the items:
private static void GetCountries(DataRow reader, XmlElement myNode)
{
myNode.RemoveChild(myNode.LastChild);
foreach (DataRow wireRow in reader.GetChildRows("Countries"))
{
var newNode = myNode.OwnerDocument.CreateElement("Value");
newNode.InnerText = wireRow["COUNTRY_NAME"].ToString();
myNode.AppendChild(newNode);
}
}
After this call, myNode for that field looks like this:
<field itemid="{2C16342E-7662-432B-9895-5EDB15914D7F}" language="en" version="1"
fieldid="{1F5956D6-EABE-4F74-A248-B25B7EE90350}" name="Categories" title=""
type="Multilist" source="/sitecore/content/data/Countries" section="Content"
tooltip=""><value>US</value><value>China</value><value>India</value></field>
After this I am calling save:
var okay = sitecoreService.Save(getItem.OuterXml, database, myCred);
But I dont see the countries in the Multilist field. What is going on here?
Multilist fields take strings of pipe-delimited GUIDs, so to add the countries into this field you will need to look up the Sitecore ID for each
Countryitem and then concatenate those with a pipe.<value>{US-GUID}|{China-GUID}|{India-GUID}</value>The Sitecore web service is not a recommended way to perform these operations. Is there a specific reason you are using the web service and not the regular API (which would make these calls much easier) ?