Here is the code I have created in the App_Code folder. When i call the function from an item transformation it always returns zero.
using System;
using System.Reflection;
using CMS.Base;
using CMS.Core;
using CMS.DataEngine;
using CMS.SiteProvider;
using CMS.DocumentEngine;
public class CustomFunctions
{
public static int ChildCount(string nodeGuid)
{
int childCount = 0;
int nodeId = 0;
if (!string.IsNullOrEmpty(nodeGuid))
{
Guid nodeGUID = new Guid(nodeGuid);
if (nodeGUID != null)
{
nodeId = TreePathUtils.GetNodeIdByNodeGUID(nodeGUID, SiteContext.CurrentSiteName);
if (nodeId > 0)
{
TreeProvider tp = new TreeProvider(CMS.Base.CMSActionContext.CurrentUser);
TreeNode node = tp.SelectSingleNode(nodeId);
childCount = node.Children.Count;
}
return childCount;
}
else
{
childCount = 0;
}
return childCount;
}
return childCount;
}
}