Working with the CORRECT Array

Hi All,

I have a problem regarding an asana project.
We will create a List of our Asana Tasks from a specified project that contains the following informations:

TaskId
TaskName
ProjectId (of the actual project)
ProjectName (of the actual project)
SectionID (of the acutal project)
SectionName (of the actual project)

My problem is, that a task can be a membership of several projects and sections. But we only want the ID and name of the project and Section of the specified project.

Here is an example. Our task is related to different Projects and Sections:

 "memberships": [
            {
                "project": {
                    "gid": "1202229622425000",
                    "name": "Great Project",
                    "resource_type": "project"
                },
                "section": {
                    "gid": "1208966331440000",
                    "name": "Section 1",
                    "resource_type": "section"
                }
            },
            {
                "project": {
                    "gid": "1206247714259000",
                    "name": "Small Project",
                    "resource_type": "project"
                },
                "section": {
                    "gid": "1206612663165458",
                    "name": "Section 2",
                    "resource_type": "section"
                }
            }
        ],

If I am working on the “Great Project” how can I achieve to receive the informations from the first array and not from the second one.

Otherwise, if i work on the “small project” how can I achieve to receive the informations form the second array?

Can someone help? I need the project.gid and section.gid

Thanks a lot and best regards,
Jane

Hi @Jane_Slaar

You should use the map function and get the first item of the array.


Please find both functions attached:
{{first(map(17.memberships; “project.gid”; “project.name”; “Great Project”))}}
{{first(map(17.memberships; “section.gid”; “section.name”; “Section 1”))}}
Copy/paste them to your scenario and replace the memberships array with an array from your scenario.

Hey @ponvaskon

thanks lot for your help.

I was trying something similar, the challenge ist, that the section is a variable and not known to me.

So we need the value from the section id and section name if the project equals the predefined value.

Best regards Jane

Hi @Jane_Slaar

The project and section are parts of the same collection. You can get the section ID and name if the project value is known.



Please find both functions attached:
{{first(map(17.memberships; “section.name”; “project.name”; “Great Project”))}}
{{first(map(17.memberships; “section.gid”; “project.name”; “Great Project”))}}

3 Likes

Hi @ponvaskon

thank you so much! :grinning_face:

Everything worked so good, with your solution.

Best regards, and have a nice sunday :wink:

2 Likes

@Jane_Slaar you are welcome!

1 Like