web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / TriggerOutputs with a ...
Power Automate
Answered

TriggerOutputs with a dynamic variable

(0) ShareShare
ReportReport
Posted on by 13

Hi,

Step 1.

I got a flow that initiate when an item are created og modfied in a sharepoint list.

 

Step 2.

After that i'm doing some filtration in two others list. That gives me the information for what column/columns i need to check for a value in the trigger object.

 

Step 3. (Problem)

I would now like to pass a variable with the column name into the trigger body, so this can be done dynamically for each statement with all my identified column names in step 2.


i have tried the following:
triggerOutputs()?['body/variables('MyVariableName')']

and 

triggerOutputs()?['body/items('Apply_to_each_2')?['Felt_x0020_Navn/Value']']

Anyone that know how get one of these expression to work? i suspect that the issue is that variables('MyVariableName') and items('Apply_to_each_2')?['Felt_x0020_Navn/Value']  are being read as a string. 

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    68,707 Most Valuable Professional on at

    That's not really possible.  The variables you want to use or the value from the loop don't exist until after the trigger fires.  So there is no way to pass the value to the trigger earlier in the flow.

  • MickeyPedersen Profile Picture
    13 on at

    Maybe i did not explain it well enough.

    The triggerOutput are the first thing i get when the flow is being triggered.
    The object contains some of the following information :

    "ItemInternalId":"00",
    "ID":12,
    "Title":"test",
    "First_x0020_Name":"xxx",
    "Last_x0020_Name":"zzz"

    Let's say i  want "First name" this can be acheived from start to end of flow by doing this:
    triggerOutputs()?['body/First_x0020_Name']

     

    Further more i'm doing by myself a filtration that tells me which field names from the triggerOutput i would like to check if it contains a value. the output looks like this:

    "Felt_x0020_Navn": {
    "Value": "ADUserName"
    },
    "Felt_x0020_Navn": {
    "Value": "PrivateEmail"
    }

     

    I can get all my identified values one by one by putting them into a apply to each statement and type: items('Apply_to_each_2')?['Felt_x0020_Navn/Value']

     

    So my data is available.

     

    Example:

    TriggerOutput contains following list items: 

    "ID":12,
    "Title":"test",
    "First_x0020_Name":"xxx",
    "Last_x0020_Name":"zzz"

     

    Array contains list with columns to check for values from triggerOutput:

    "Felt_x0020_Navn": {
    "Value": "First_x0020_Name"
    },
    "Felt_x0020_Navn": {
    "Value": "PrivateEmail"
    }

    Step 1. 

    My array values are being added to apply to each function. This will make it run 2 times with the input above and current element value first time to be First_x0020_Name and the second time to be PrivateEmail .

     

    Step 2.

    I'm adding a condition. In my condition i would like to check that the identified current element (First_x0020_Name) contains a value in my triggerOutput.

    I would like to achieve this dynamically. From c# i would just pass a variable into my triggerOutput function hightlighted with bold containing my current element value (First_x0020_Name)

     

    triggerOutput function:

    triggerOutputs()?['body/variables('MyVariableName')'] = triggerOutputs()?['body/First_x0020_Name']

     

    I can't get this to work, and i think, but i do now know, that the reason for this is that function read my variable function as a string  instead of a function. But how to i escape this or solved it in another way?

    I'm aware that i need to check if value returned isblank etc. That is not the issue. The issue is how to make it dynamically to check each identified columns in triggeroutput for values given the values from array.

  • Pstork1 Profile Picture
    68,707 Most Valuable Professional on at

    I understand what you are trying to do.  But Variables don't exist in the flow and can't be defined until AFTER the Trigger fires.  So there is no way to use a variable defined in the flow inside the Trigger.  You can later in the flow compare the value of a variable that you have defined and populated with a value that comes from the trigger.

    equals(variables('MyVariableName'),triggerOutputs()?['body/First_x0020_Name'])

    But you can't use a variable to define the field you want to pull for an expression and you can't do it in the trigger since the variable doesn't exist at that point.

  • Verified answer
    MickeyPedersen Profile Picture
    13 on at

    I see where we have the misunderstanding. The flow has been triggered. So the triggeroutput lives in runtime (Data as displayed in my earlier message).

     

    The thing i am asking about is later in the flow when i want to filter through my triggeroutput data.

    I did solve the issue by myself. My syntax was worng. I had to write it like this:
    triggerOutputs()?['body']?[variables('MyVariable')]

    instead of 

    triggerOutputs()?['body/variables('MyVariableName')']

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard