How to traverse a property set.
By neel | February 12, 2008
As we all know that property sets in Siebel are generally used to store hierarchal data. Product configurator engine uses property set to store complete data structure.
Property sets can store have simple values in form of properties example:
var newps = TheApplication().NewPropertySet();
newps.SetProperty(“Property1”,”value1”);
newps.SetProperty(“Property2”,”value2”);
To retrieve these properties we will use GetProperty method available.
newps.GetProperty(“Property1”) which will return the value as “value1” (without quotes)
To create a hierarchical property set we can use AddChild method and similarly GetChild method to retrieve a child.
Here I want to share a piece of code which can help you traverse any given property set and display its information in form of RaiseErrorText. This can be very helpful if you work with property sets a lot. The code goes as follow
function ShowHierarchy(hierarchy)
{
var stemp = “”,
spropname=”",
spropval=”";
spropname = hierarchy.GetFirstProperty();
while (spropname != “” && spropname != null )
{
stemp += spropname + ” = ” + hierarchy.GetProperty(spropname) + “\n”;
spropname = hierarchy.GetNextProperty();
}
var j = hierarchy.Copy();
var k;
stemp +=”\nType = ” + j.GetType() + “\nValue = ” + j.GetValue() + “\nChild = ” + j.GetChildCount() + “\n”;
while(j.GetChildCount()>0)
{
k = j.GetChild(0);
j = k;
stemp +=”\nType = ” + j.GetType() + “\nValue = ” + j.GetValue() + “\nChild = ” + j.GetChildCount();
spropname = k.GetFirstProperty();
while (spropname != “” && spropname != null )
{
stemp += “\ChildProperties = ‘” + spropname + “‘ = ” + k.GetProperty(spropname) + “\n”;
spropname = k.GetNextProperty();
}
}
}
You can call this method like this
ShowHierarchy(PropertySet);
You can pass any propertyset and it will display it information like
- Number of properties
- Name and value of Properties
- Number of Children for each property set
- Name and Type of each child of property set.
Try it and do let me know your feedback on this by answering the Poll below. Your answer will help me to determine if I should write more posts like these.
[poll=5]
Subscribe by Email
(1 votes, average: 4 out of 5)
May 10th, 2008 at 1:24 pm
You are doing gr8 work Neel.Please add some comments in your script examples,then new developers also can understand easily.