Write the code that you'd put inside a method, but without the method signature. From the actions list, select the action named Execute JavaScript Code. In the Choose an operation search box, enter inline code. Select the plus sign ( +) that appears, and select Add an action. To add the action between steps, move your mouse pointer over the arrow that connects those steps. To add the action at the end of your workflow, select the plus sign ( +), and then select Add an action. This example adds the action under the Office 365 Outlook trigger. You can add an action either as a new step at the end of your workflow or between steps. On the designer, add the Inline Code action to your workflow. In the Azure portal, open your logic app workflow in the designer. The Create HTML table action then uses the Result token to reference the results from the Inline Code action and creates a single result. In this example, the code snippet returns the result by calling the match() function, which finds any matches in the email message body to the specified regular expression. However, by including the return statement, you can more easily reference the action results later in your workflow by using the Result token in later actions. The Inline Code action doesn't syntactically require a return statement. Add the closing semicolon ( ) at the end to finish the code statement. To differentiate the email message's Body property that you selected from the trigger's body property, rename the second body property to Body instead. For more information, seeĪdd dependencies as parameters to an Inline Code action later in this article. Incorrect .Īlso, in the Inline Code action, you have to add the Actions parameterĪnd then add these action names to that parameter. Those references have to enclose these action names with square brackets ( ) If your code snippet references action names that include the dot (. For more information about the workflowContext object, see Reference trigger and action outputs using the workflowContext object later in this article. The workflowContext object includes properties that give your code access to the outputs from the trigger and preceding actions in your workflow, such as the trigger's body property, which differs from the email message's Body property. For this example, the list shows the outputs from the Outlook trigger, including the email message's Body property.Īfter you select the Body property, the Inline Code action resolves the token to a read-only workflowContext JSON object, which your snippet can use as input. This list makes these outputs easier to use and reference from your workflow. The dynamic content list shows the outputs from the trigger and any preceding actions when those outputs match the input format for the edit box that's currently in focus. With your cursor still in the Code box, from the open dynamic content list, find the When a new email arrives section, and select the Body property, which references the email message's body. The code then creates a variable named email that stores the email message's body content from the trigger outputs. The following example code snippet first creates a variable named myResult that stores a regular expression, which specifies a pattern to match in input text. If you start typing a recognized keyword, the autocomplete list appears so that you can select from available keywords, for example: Use this list later, you can ignore and leave the list open for now. When your cursor is in the Code box, the dynamic content list appears. The following diagram shows the highlights from example workflow: The sample code snippet extracts any email addresses that exist the email body and returns those addresses as output that you can use in a subsequent action. The workflow runs when a new email arrives in the associated Outlook email account. This article shows how the action works in an example workflow that starts with an Office 365 Outlook trigger. To run code that doesn't fit these attributes, you can create and call a function through Azure Functions instead. Doesn't support the require() function for running JavaScript. Doesn't require working with the Variables actions, which are unsupported by the action. Actionįor more information, review Standard built-in objects. The Inline Code connector also hasĭifferent limits, based on whether your logic app workflow is Consumption or Standard. This connector has an action that returns the result from the code snippet so that you can use that output in your workflow's subsequent actions.Ĭurrently, the connector only has a single action, which works best for a code snippet with the following attributes, but more actions are in development. To create and run a code snippet in your logic app workflow without much setup, you can use the Inline Code built-in connector. Applies to: Azure Logic Apps (Consumption + Standard)
0 Comments
Leave a Reply. |