How to traverse a property set.

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.

Sorry, there are no polls available at the moment.

11 Responses to How to traverse a property set.

  1. You are doing gr8 work Neel.Please add some comments in your script examples,then new developers also can understand easily.

  2. You are doing gr8 work Neel.Please add some comments in your script examples,then new developers also can understand easily.

  3. Hi, I find your material very interesting.

    Can you explain how to extract data from XML files using eScript. (consider 4 levels)

  4. Hi, I find your material very interesting.

    Can you explain how to extract data from XML files using eScript. (consider 4 levels)

  5. This code traverse only first child properties.
    I can’t understand the meaning of:
    while(j.GetChildCount()>0)
    {
    if you make this:
    k = j.GetChild(0);
    Thanks.

  6. This code traverse only first child properties.
    I can’t understand the meaning of:
    while(j.GetChildCount()>0)
    {
    if you make this:
    k = j.GetChild(0);
    Thanks.

  7. Hi Neel,
    I am doing the Same traversing method, like I have a Parent Prop set and Child Propset which  is built in Heirarchy way the Strructure Looks like this:

       
          204781
          07/01/2010 00:00:00
          Service Order
          Bangalore
          Audi
          100923
          GBR00048A
          2
          07/01/2010 00:00:00
         
           
              2011
             
             51141035220
              Turmeric
             
         
       
       
    The Problem now which ia m facing is i sucessfully traversed the First Node, i meant copying it to another Propset, “OrderEntry-Orders”
    oOrderEntryOrders = SiebelMessage.GetChild(0); // Copies the Prop set to that Object
    but when i use this code

    oOrderEntryLine items=oOrderEntryOrders.GetChild(0);// In Bookshelf this the syntax they have given
    Which copies the Child Property set in to a Propset variable
    It takes the Value of the Order Field : Example AccountNumber,
    So how we can traverse to the Child..

    any Ideas!!

Leave a Reply

Contribute