Getting values from the previous cycle
Asked by DavidBernardoSI1996:

Hello, I'm trying to create a check list, with pickable values, the structure of the data goes, as for example:

-\> Host

- Groups

Users

- Groups

Users

-\> Host

- Groups

Users

When I'm cycling through the values I want to divide them by Groups, but before the name of the Group there should also be the name of the Host it belongs too, this is what I have:

![print1.png](https://community.atlassian.com/t5/image/serverpage/image-id/283313i13A9393091529EEE/image-size/large?v=v2&px=999 "print1.png")

Which results in this:

![print2.png](https://community.atlassian.com/t5/image/serverpage/image-id/283314iDC7EACBC4DAC95C6/image-size/large?v=v2&px=999 "print2.png")

The value after the "Host:" is missing, how do I access the {{lookupObjects.Name}}?

Thank you


Answers:
author: DavidBernardoSI1996
body: Hello, after some research I've found that this is a documented issue, and is currently on hold to be solved, here is the link to the issue:

<https://jira.atlassian.com/browse/JSDCLOUD-12834>


author: Bill Sheboy
body: Hi [@DavidBernardoSI1996](/t5/user/viewprofilepage/user-id/5286766)

First thing, I am not using Assets and so my suggestion is based on what I understand about rules. With the disclaimer out of the way...

Once you are inside of a rule iterator like {{#lookupObjects}} it can only see that information at that point, and lower. And so referencing {{lookupObjects.Name}} will not work inside that loop.

And also...you are trying to access the Host name inside of the {{#Groups}} iterator; it is no longer visible.

One alternative is to create a separate Host heading, and then add the lower level items.

Kind regards,  
Bill

comments: author: DavidBernardoSI1996
body: I've changed the format, so that instead of:

HostA - GroupA

HostA - GroupB

It's like this:

HostA

- GroupA

- GroupB

But now I have a different question, what if I wanted to compare a value to make it so it only renders the group and its option if Profile = Admin, like so:

![print3.png](https://community.atlassian.com/t5/image/serverpage/image-id/283550i5C69344BD1BC64C1/image-size/large?v=v2&px=999 "print3.png")


author: Bill Sheboy
body: If the attribute is visible at that point, you can use list filtering and conditional logic for that: <https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588>

Your change is close, and with a slight adjustment, and let's assume your Profile is defined in the Group, the change would be:

```
{{#lookupObjects}}

# Host: {{Name}}

{{#Groups}}
{{#if(equals(Profile,"Admin"))}}
--- **Group** - {{Name}}:
{{#Users}}

[x] {{Name}}

{{/}}
{{/}}
{{/}}
{{/}}
```

If your Profile is not in the Groups level, you may need to adjust your AQL to filter (if that is possible).


author: DavidBernardoSI1996
body: I've tried with the code you sent me, but I'm not sure why it isn't working, none of the groups are showing up, so after that I wrote the value inside Profile, like so:

![print4.png](https://community.atlassian.com/t5/image/serverpage/image-id/283565i2A43AFF256156CAF/image-size/large?v=v2&px=999 "print4.png")

And this is what I got:

![print5.png](https://community.atlassian.com/t5/image/serverpage/image-id/283566iA7D076019D86AE29/image-size/large?v=v2&px=999 "print5.png")

Not sure why the equals is not working


author: Bill Sheboy
body: What is the type / structure of Profile? I suspect it may not be just text and instead has a lower level attribute that represents the "Admin" you are testing. You can confirm that by writing the entire {{lookupObjects}} result to the audit log. And once it is found, add the attribute to the filter.

For example, let's assume Profile has a Type, Name, etc. and the Name is the one you want. The filter would become:

{{#if(equals(Profile.Name,"Admin"))}}


author: DavidBernardoSI1996
body: I've also tried the .Name, and nothing is written down when I use {{Profile.Name}}, the value is a select value that only has 2 option, "Admin" or "NonAdmin"


author: DavidBernardoSI1996
body: ![print6.png](https://community.atlassian.com/t5/image/serverpage/image-id/283573i9C0965AF972CD804/image-size/large?v=v2&px=999 "print6.png")![print7.png](https://community.atlassian.com/t5/image/serverpage/image-id/283574i8715BFC66D51E17B/image-size/large?v=v2&px=999 "print7.png")


author: DavidBernardoSI1996
body: The images above are the field type and the selectable values


author: Bill Sheboy
body: What do you see in the audit log if you write the entire {{lookupObjects}} to the audit log?

If it is a single-select as shown in the image, perhaps try this:

{{#if(equals(Profile.value,"Admin"))}}


author: DavidBernardoSI1996
body: In the audit log it only shows the Key of the Host, nothing more, also tried .value and still nothing.


author: DavidBernardoSI1996
body: I've found this that might be related to the issue, but it refers to a custom field in Jira not Insight, <https://community.atlassian.com/t5/Jira-questions/Using-String-Manipulation-functions-on-Select-List-Fields-Jira/qaq-p/1477939>


author: DavidBernardoSI1996
body: I did this audit log to see what it returned, and everything looks normal:

![print8.png](https://community.atlassian.com/t5/image/serverpage/image-id/283579i86FE1C54F39B83B1/image-size/large?v=v2&px=999 "print8.png")


author: Bill Sheboy
body: When you explicitly write just Profile to the audit log, I wonder if it is only showing the default attribute. That is why I suggested writing the entire thing as it would show the entire JSON structure: {{lookupObjects}}

We can also try some hackery...forcing the expression to text like this:

{{#if(equals(Profile.toLowerCase(),"admin"))}}


author: Bill Sheboy
body: Hi [@DavidBernardoSI1996](/t5/user/viewprofilepage/user-id/5286766)

Just following up to check if this answered your question. If so, please consider marking this one as "answered". That will help others with a similar need find solutions faster. If not, please let the community know what help you need with the rule changes.

Thanks!


author: DavidBernardoSI1996
body: Hello, after some research I've found that this is a documented issue, and is currently on hold to be solved, here is the link to the issue:

<https://jira.atlassian.com/browse/JSDCLOUD-12834>


author: Bill Sheboy
body: Thanks for the link to the open issue, David.

There was a work-around noted for that ticket using created variables, but that may not help for your case while in the iterator (due to the other scoping problem with those).