Power Automate variables

Anonymní
2025-06-24T15:51:20+00:00

How to convert variable from loop (currentItem) on text variable?

Microsoft 365 a Office | Instalovat, uplatnit, aktivovat | Jiné | Jiné

Otázka je uzamčená. Tato otázka se migrovala z komunity podpory Microsoftu. Můžete hlasovat, jestli je užitečná, ale nemůžete k ní přidávat komentáře či odpovědi ani ji nemůžete sledovat.

Počet komentářů: 0 Žádné komentáře
Odpověď přijatá autorem otázky
Anonymní
2025-06-25T12:09:22+00:00

Hi Jana, thank you so much for the update — great job figuring that out! :)

And you're right, Jana! The issue was caused by Power Fx being enabled. With Power Fx, it uses ${CurrentItem}[0], but without it, it uses %CurrentItem[0]%, which works correctly in your flow.

So yes — turning off Power Fx fixed the problem.

Hope it helps, please let me know if you need further assistance.

Regards,

Arlene D.

Byla tato odpověď užitečná?

Počet osob, které tuto odpověď považovaly za užitečnou: 1.
Počet komentářů: 0 Žádné komentáře

Počet dalších odpovědí: 4

Seřadit podle: Nejstarší
  1. Anonymní
    2025-06-24T17:23:31+00:00

    Hi there, I'm Arlene, an independent advisor, here to help.

    To convert the current item from a loop to a text variable in Power Automate:

    Inside the loop (like Apply to each), add a Set variable action.

    Choose your text variable.

    Set the value to:

    string(items('Apply_to_each')?['YourFieldName'])

    (Replace 'YourFieldName' with the actual column or field name.)

    This turns the loop item into a text value. Let me know if that works for you.

    Regards,

    Arlene D.

    Byla tato odpověď užitečná?

    Počet komentářů: 0 Žádné komentáře
  2. Anonymní
    2025-06-25T07:29:10+00:00

    Hi Arlene,

    I am sorry, but I am not understanding well - I am beginner in RPA. :)

    I will describe the issue.

    I want to use variable in VBS script (to work in SAP). The part of the script is this:

    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/usr/radX_AISEL").select
    session.findById("wnd[0]/usr/ctxtSD_SAKNR-LOW").text = "${CurrentItem}[0]"
    session.findById("wnd[0]/usr/ctxtSD_BUKRS-LOW").text = "JCZ"
    session.findById("wnd[0]/usr/ctxtSO_BUDAT-LOW").text = "1.1.2025"
    session.findById("wnd[0]/usr/ctxtSO_BUDAT-HIGH").text = "15.1.2025"

    This script is in loop and the data are from Excel - for each Excel row run the script (each Excel row = CurrentItem)

    So I want use this variable from loop:

    ${CurrentItem}[0]

    But I get this error: The untypect object argument to the Text function has an incorrect type. Expected: Text, Actual: Text.

    So I think, I have to convert this variable to Text.

    This is the window for set variable (as you wrote I should use):

    Here to the value field should I write this?

    string(items('Apply_to_each')?['YourFieldName'])

    Next question - in another older flow, I have again the loop with Excel rows. I get CurrentItem variable. But it works well in next actions (in this case for naming of files or folders) Why?

    The variable isn´t with $, but is described like this: %CurrentItem[4]%

    Why is there the difference and what does it mean?

    Thank you

    Jana

    Byla tato odpověď užitečná?

    Počet komentářů: 0 Žádné komentáře
  3. Anonymní
    2025-06-25T10:24:21+00:00

    Hi, Jana! Thanks for getting back to me.

    In the Hodnota (Value) field, just type this:

    %CurrentItem[0]%

    This gets the first column from your Excel row. If you need a different column, just change the number (e.g. [1] for the second column).

    Then use your new variable (NewVar2) in your script like this:

    .text = "%NewVar2%"

    That’s it! Let me know if you’re not sure which column number to use.

    Regards,

    Arlene D.

    Byla tato odpověď užitečná?

    Počet komentářů: 0 Žádné komentáře
  4. Anonymní
    2025-06-25T11:31:19+00:00

    Hi Arlene,

    I found the issue... :)

    When I created a new flow, I had Power Fx enabled.

    Then the variables was like with = or with written like this: ${CurrentItem}[0]

    When I have Power Fx not enabled, then it is like this: %CurrentItem[0]%.

    And in this way it works without setting text variable.

    So this was the problem, I mean.

    Jana

    Byla tato odpověď užitečná?

    Počet komentářů: 0 Žádné komentáře