1
votes

By using Sitecore webservice I created a new Page Item as Below.

var scClient = new VisualSitecoreServiceSoapClient();
// another code
var xmlNode = scClient.AddFromTemplate(parentId, pagetemplateId,itemName,database,credentials)

I cannot use the Database Items, just the web service.

From xmlNode I get the newly created GUID/Id. How do I edit the fields of newly created Item from the webservice only?

1
You might want to take a look at InsertXML method here - sdn.sitecore.net/upload/sitecore6/65/…nsgocev

1 Answers

1
votes

You can use Save() method like this:

string itemId = // id from AddFromTemplate() xmlNode 
string fieldId = "{some-id-of-the-field}"; // id of the field

XDocument fieldXml = new XDocument(
    new XElement("sitecore",
        new XElement("field",
            new XAttribute("itemid", itemId),
            new XAttribute("language", "en"),
            new XAttribute("version", 1),
            new XAttribute("fieldid", fieldId),
            new XElement("value", "new value of the field")
        )
    )
);

XElement fieldResponse = scClient.Save(fieldXml, "web", credentials);

EDIT:

In response to your comment: No, you cannot use field name instead of field id. Still you can use GetItemFields method exposed in VisualSitecoreServiceSoapClient to list all the fields of the item and then determine what is the id of the field with given name:

public XmlDocument GetItemFields(string id, string language, string version, bool allFields, string databaseName, Credentials credentials)