0
votes

I am creating items on the fly via Sitecore Web Service. So far I can create the items from this function:

AddFromTemplate

And I also tried this link: http://blog.hansmelis.be/2012/05/29/sitecore-web-service-pitfalls/

But I am finding it hard to access the fields. So far here is my code:

public void CreateItemInSitecore(string getDayGuid, Oracle.DataAccess.Client.OracleDataReader reader)
    {
        if (getDayGuid != null)
        {
            var sitecoreService = new EverBankCMS.VisualSitecoreService();
            var addItem = sitecoreService.AddFromTemplate(getDayGuid, templateIdRTT, "Testing", database, myCred);

            var getChildren = sitecoreService.GetChildren(getDayGuid, database, myCred);

            for (int i = 0; i < getChildren.ChildNodes.Count; i++)
            {
                if (getChildren.ChildNodes[i].InnerText.ToString() == "Testing")
                {
                    var getItem = sitecoreService.GetItemFields(getChildren.ChildNodes[i].Attributes[0].Value, "en", "1", true, database, myCred);

                    string p = getChildren.ChildNodes[i].Attributes[0].Value;
                }
            }
        }
    }

So as you can see I am creating an Item and I want to access the Fields for that item. I thought that GetItemFields will give me some value, but finding it hard to get it. Any clue?

2

2 Answers

1
votes

My advice would be to not use the VSS (Visual Sitecore Service), but write your own service specifically for the thing you want it to do.

This way is usually more efficient because you can do exactly the thing you want, directly inside the service, instead of making a lot of calls to the VSS and handle your logic on the clientside.

For me, this has always been a better solution than using the VSS.

0
votes

I am assuming you are looking to find out what the fields looks like and what the field IDs are.

You can call GetXml with the ID, it returns the item and all the versions and fields set in it, it won't show fields you haven't set.