Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
kalariviswa Contributor.
Contributor.
1791 views

Storing result of each for-each operation in a node set

Hi All,

I have a case , where my input event has multiple roles like <roleinfo>Role1#Role2#Role3<roleinfo>

I have used a node spliter followe by a for each command to assign each of the role.

But during each for each i would like to set a event id say for example 1001 for success and 1002 in case of failure in role assignment. That is for example if Role 1 and 3 assignment is success and Role 2 assignment is failure, then i am looking for a output in a local variable like 1001;1002;1001 , where each node will specify the status of each activity.

To achieve this i had written the below code inside my for-each statement for role assignment , but i am getting only the last event id in the local variable
For Each(roleinfo)
{
Assingrole
if success
Set event id =1001
else
set event id =1002
<do-set-local-variable name="var-event-id-node" scope="driver">
<arg-node-set>
<token-join delimiter=";">
<token-local-variable name="var-event-id"/>
</token-join>
</arg-node-set>
</do-set-local-variable>
}

in the above code the output i am getting is 1001 only. Can some one please help me here.
Labels (1)
0 Likes
11 Replies
Knowledge Partner
Knowledge Partner

Re: Storing result of each for-each operation in a node set

kalariviswa wrote:

> <do-set-local-variable name="var-event-id-node" scope="driver">
> <arg-node-set>
> <token-join delimiter=";">
> <token-local-variable name="var-event-id"/>
> </token-join>
> </arg-node-set>
> </do-set-local-variable>


First of all, you seem to be unclear about what a nodeset is and what not.
Token Join produces a String value and takes a Nodeset as input, nevertheless
you give it a String as input and assign it's output to a variable of type
nodeset...

If you want a semi-colon delimited string for output as you described it,
something like this should work:

<do-set-local-variable name="var-event-id-csv-string" scope="driver">
<arg-string>
<token-join delimiter=";">
<token-local-variable name="var-event-id-csv-string"/>
<token-local-variable name="var-event-id"/>
</token-join>
</arg-string>
</do-set-local-variable>

--
http://www.is4it.de/en/solution/identity-access-management/
______________________________________________
https://www.is4it.de/identity-access-management
0 Likes
kalariviswa Contributor.
Contributor.

Re: Storing result of each for-each operation in a node set

Thanks for the quick help.. For the above case , i got an local variable value set as 1001#;#1002#;#1003

I would like to execute a set of conditions if the expression #;# is not present in the local variable var-event-id-node . I think i am some where missing a regular expression. Can you please guide me..

<if-xpath op="not-true">contains($var-event-id-node,"*#;#*")</if-xpath>
0 Likes
Knowledge Partner
Knowledge Partner

Re: Storing result of each for-each operation in a node set

kalariviswa wrote:

> Thanks for the quick help.. For the above case , i got an local variable
> value set as 1001#;#1002#;#1003
>
> I would like to execute a set of conditions if the expression #;# is not
> present in the local variable var-event-id-node . I think i am some
> where missing a regular expression. Can you please guide me..
>
> <if-xpath op="not-true">contains($var-event-id-node,"*#;#*")</if-xpath>


contains() checks for a literal expression, not a regular expression. Therefor
remove the asterisks around the delimiter and it should work just fine. Or use

<if-local-variable mode="regex" name="var-event-id-node"
op="not-equal">.*#;#.*</if-local-variable>


--
http://www.is4it.de/en/solution/identity-access-management/
______________________________________________
https://www.is4it.de/identity-access-management
0 Likes
Knowledge Partner
Knowledge Partner

Re: Storing result of each for-each operation in a node set


Hi kalariviswa,
contains() will give you right answer (you have delimiter in this
string), but what is your next step?
Your business requirements still not clear for me, but if you need, you
can convert your string 1001#;#1002#;#1003 back to nodeset and use cycle
(For Each) for go thru every string (node) in your nodeset.


--
If you find this post helpful, please show your appreciation by clicking
on the star below :cool:
------------------------------------------------------------------------
al_b's Profile: https://forums.netiq.com/member.php?userid=209
View this thread: https://forums.netiq.com/showthread.php?t=55964

0 Likes
kalariviswa Contributor.
Contributor.

Re: Storing result of each for-each operation in a node set

Thanks Al_B, thanks for your comments. I Had followed lhaeger approach and it was successful. Thanks again 🙂 ..
0 Likes
kalariviswa Contributor.
Contributor.

Re: Storing result of each for-each operation in a node set

lhaeger;2430196 wrote:
kalariviswa wrote:

> Thanks for the quick help.. For the above case , i got an local variable
> value set as 1001#;#1002#;#1003
>
> I would like to execute a set of conditions if the expression #;# is not
> present in the local variable var-event-id-node . I think i am some
> where missing a regular expression. Can you please guide me..
>
> <if-xpath op="not-true">contains($var-event-id-node,"*#;#*")</if-xpath>


contains() checks for a literal expression, not a regular expression. Therefor
remove the asterisks around the delimiter and it should work just fine. Or use

<if-local-variable mode="regex" name="var-event-id-node"
op="not-equal">.*#;#.*</if-local-variable>


--
http://www.is4it.de/en/solution/identity-access-management/



Thanks So much ...It worked, i was able to store it in a local variable in ITP and call the same variable and check it in OTP. Thanks.
0 Likes
Knowledge Partner
Knowledge Partner

Re: Storing result of each for-each operation in a node set

kalariviswa wrote:

> Thanks So much ...It worked, i was able to store it in a local variable
> in ITP and call the same variable and check it in OTP. Thanks.


Glad to hear that, just keep in mind that driver scope variables are available
to both subscriber and publisher thread and are persistent between events. So
make sure you do not accidentally use a value from another object or channel...

--
http://www.is4it.de/en/solution/identity-access-management/
______________________________________________
https://www.is4it.de/identity-access-management
0 Likes
Knowledge Partner
Knowledge Partner

Re: Storing result of each for-each operation in a node set

Lothar Haeger wrote:

> kalariviswa wrote:
>
> > Thanks So much ...It worked, i was able to store it in a local
> > variable in ITP and call the same variable and check it in OTP.
> > Thanks.

>
> Glad to hear that, just keep in mind that driver scope variables are
> available to both subscriber and publisher thread and are persistent
> between events. So make sure you do not accidentally use a value from
> another object or channel...


Also if this information is only required in the current operation, you
should use Operation Data instead of a driver scoped variable.
Alex McHugh - Knowledge Partner - Stavanger, Norway
Who are the Knowledge Partners
If you appreciate my comments, please click the Like button.
If I have resolved your issue, please click the Accept as Solution button.
0 Likes
Knowledge Partner
Knowledge Partner

Re: Storing result of each for-each operation in a node set

alexmchugh;2430240 wrote:
Lothar Haeger wrote:

> kalariviswa wrote:
>
> > Thanks So much ...It worked, i was able to store it in a local
> > variable in ITP and call the same variable and check it in OTP.
> > Thanks.

>
> Glad to hear that, just keep in mind that driver scope variables are
> available to both subscriber and publisher thread and are persistent
> between events. So make sure you do not accidentally use a value from
> another object or channel...


Also if this information is only required in the current operation, you
should use Operation Data instead of a driver scoped variable.


This right approach will come with experience: in my oldest drivers I used Driver scoped variables, now I use Operation Property instead. 🙂
0 Likes
Knowledge Partner
Knowledge Partner

Re: Storing result of each for-each operation in a node set

True,

If you end up using Driver scoped variables I always initialize them with a null value such as 0 or '' or even "null" so I know it is empty before setting it. You can also set (remove) it after using it to clean it up. The point is to be careful when using them.
0 Likes
kalariviswa Contributor.
Contributor.

Re: Storing result of each for-each operation in a node set

Thanks So much ...It worked, i was able to store it in a local variable in ITP and call the same variable and check it in OTP. Thanks.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.