Azure logic app use a variable inside inline_code action
Asked Answered
A

1

7

I have a logic app that looks something like this: enter image description here

In the js code action, I just wanted to check if the name of the file (that had triggered the workflow) match some pattern. So my Inline code action has something like:

    var input = workflowContext.trigger.outputs.headers.x-ms-file-name;
    if(input.match(/^([0-9]){3}_Hello/))
        return true;
    else 
        return false;

However, it seems that the action can't get the file name because the x-ms-file-name is splitted by a '-'. So, I tried to solve this problem by creating a variable called fileName in an the action before it enter image description here

and then use it in the inline code action. But I don't know how to call the variable inside inline code action. What should I write here:

    var input = ????;
    if(input.match(/^([0-9]){3}_Hello/))
        return true;
    else 
        return false;

Any suggestion to how to solve this problem?

Note (I am not sure if it is relevant but in case it helps): I am using the standard logic app so I amp supposed to not have/use Integration account

Angkor answered 12/10, 2021 at 9:9 Comment(0)
A
0

It seems that I can just simply write the following in the inline action:

    var input = workflowContext.trigger.outputs.headers['x-ms-file-name'];
    if(input.match(/^([0-9]){3}_Hello/))
        return true;
    else 
        return false;
Angkor answered 12/10, 2021 at 9:41 Comment(1)
Good workaround, and that ??? is fair enough: it looks like inline Js steps don't support variables access, they are just not available in the workflow context object which gets passed in (see learn.microsoft.com/en-us/azure/logic-apps/…).Conventioner

© 2022 - 2024 — McMap. All rights reserved.