# What are adhoc functions in workflows?

**URL:** <https://community.dynatrace.com/t/what-are-adhoc-functions-in-workflows/46094>\
**Category:** Automations\
**Tags:** workflows, automations\
**Created:** [June 13, 2024, 5:07am UTC](https://community.dynatrace.com/t/what-are-adhoc-functions-in-workflows/46094 "2024-06-13T05:07:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [June 13, 2024, 5:07am UTC](https://community.dynatrace.com/t/what-are-adhoc-functions-in-workflows/46094/1 "2024-06-13T05:07:29Z")

</div>

Good morning,

Getting confused by below options, I assume, reading the documentation

_You add a code section in your Notebook and add custom code, which we refer to as an "Ad-hoc function._

This is in workflows also a task with JS code? And does below mean I have enabled “ad hoc” for workflows and not for notebooks.

And for now I assume ad hoc function are the only way to connect to the vault?

And I hope the user is still validated to have access?

KR Henk

 ![henk_stobbe_0-1718254350156.png](https://global.discourse-cdn.com/dynatrace/original/3X/5/c/5c741b1abee69b450f704ac76ea07aa45bd69f0f.png)

---

<div class="post-metadata">

**Author:** ![christian\_kreuz](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/christian_kreuz/32/21669_2.png) [@christian\_kreuz](https://community.dynatrace.com/u/christian_kreuz)\
**Post date:** [June 17, 2024, 9:24am UTC](https://community.dynatrace.com/t/what-are-adhoc-functions-in-workflows/46094/2 "2024-06-17T09:24:33Z")

</div>

Hi! Ad-hoc function is a very generic term for describing “a function that is written ad-hoc” - vs. a function that is part of an (existing) App.

In Notebooks you implicitly create an Ad-hoc function by writing Code in a Code-tile. In Workflows, this is the “Run JavaScript” action.

> [@henk\_stobbe](https://community.dynatrace.com/user/11427)&nbsp;wrote:
> 
> And for now I assume ad hoc function are the only way to connect to the vault?

In the future, a deeper integration between Vault and “some” Workflow Action is planned. For now, the “Run JavaScript” action is the only way to access secrets stored in Vault.

> And I hope the user is still validated to have access?

If you restrict the access in Vault to certain users, only those users can access the secret. In Workflows, the user is whoever is set as the [actor of a Workflow](https://docs.dynatrace.com/docs/platform-modules/automations/workflows/security#workflow-actor) (not necessarily the user that clicks “Run”).

Based on your screenshot, you seem to have already performed the first step and selected [AppEngine as a scope](https://docs.dynatrace.com/docs/platform-modules/digital-experience/synthetic-monitoring/general-information/credential-vault-for-synthetic-monitors#appengine-scope). In addition, you allowed access without an app context (for ad-hoc functions like the Run JavaScript action).

You can furthermore enable “Owner access only” below, or specify a list of “Users with access”.

---

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [June 17, 2024, 10:05am UTC](https://community.dynatrace.com/t/what-are-adhoc-functions-in-workflows/46094/3 "2024-06-17T10:05:52Z")

</div>

Hello Christian,

Thanks again for your long and detailed answer. One small extra question from my side.

![henk_stobbe_0-1718618335195.png](https://global.discourse-cdn.com/dynatrace/original/2X/7/76e23998c716562eaaa7e593873215517f540eac.png)

So if I understand correctly, above selection has no real implication at this moment?

And the ad hoc function also runs in the actor context, who needs vault access.

If both are yes, then I got it!

KR Henk

---

<div class="post-metadata">

**Author:** ![christian\_kreuz](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/christian_kreuz/32/21669_2.png) [@christian\_kreuz](https://community.dynatrace.com/u/christian_kreuz)\
**Post date:** [June 17, 2024, 11:09am UTC](https://community.dynatrace.com/t/what-are-adhoc-functions-in-workflows/46094/4 "2024-06-17T11:09:44Z")

</div>

Hi,

you have to set “Dynatrace apps with access” when selecting the AppEngine scope. By default it is set to “all applications”.

While this does not have an immediate implication on your Workflow and the ad-hoc function used, I would still recommend to set it to “Workflows” for two reasons:

1. It’s easier identifiable where you use the secrets afterwards
2. By setting it to “All applications” you are theoretically giving every app access to your secret (while, of course, still adhering to the “Owner access only” or “Users with access” configuration)
