Skip to Content
author's profile photo Former Member
Former Member

Querying node elements through root elements

Hi,

This is the structure of my BO.

Root{

element ID : Identifier;

node test [0..n]{

element weight : percent;

element rank : percent;

}

}

You all know that one instance of ID at root level can have multiple instances of weight and rank at its node level.

I want to change all the values of weight and rank at node level to some defined values of weight and rank for a given particular ID at root level through querying in ABSL. How could I achieve that? Please help!

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on May 04, 2011 at 04:52 PM

    Hi Srivatsava,

    access to the subnode-instances of a BO instance is directly possible on root level via path navigation. For example, within the After Modify Event of the root node of a BO, you can access the subnode Test via

    foreach (instance in this.test){
      instance.weight = ...; // your new value needs to be assigned here
      instance.rank = ...;  // your value value needs to be assigned here
    }
    

    So within the root-node ABSLs, 'this' is always directing to a specific root node instance and navigation to a subnode with cardinality n always has to be done via a foreach loop. So querying is not necessary.

    When you want to access the BO instance from a second defined BO, then you need to use a query (if no association is available which directs to a specific BO instance).

    Defining the query access to the first BO within an ABSL script of the second BO is quite simple (assume this.ID.Content contains the ID of the BO instance you want to access):

    var query;
    var query_selparam;
    var query_result;
    
    // define query of the first BO (called myBO in your example)
    query = myBO.QueryByElements;
    
    // fill the query parameter for the ID
    query_selparam = query.CreateSelectionParams();
    query_selparam.Add(query.ID.Content, "I", "EQ", this.ID.Content)
    
    // execute the query - result is a collection of instances - since ID was not defined as alternative key more
    // than one instance is possible in your case as a result set!
    
    query_result = query.Execute(query_selparam);
    
    // loop over all myBO instances
    foreach (instance in query_result) {
    
        // loop over all subnode instances of a given myBO root instance
        foreach (test_instance in instance.test){
           test_instance.weight = ...; // your value needs to be assigned here
           test_instance.rank = ...,     // your value needs to be assigned here
        }
    
    }
    

    I hope that info helps.

    Regards,

    Thomas

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.