AEMaaCS | AEM Forms | Using globals.functions comes back as undefined | Community
Skip to main content
Level 1
February 4, 2026
Solved

AEMaaCS | AEM Forms | Using globals.functions comes back as undefined

  • February 4, 2026
  • 2 replies
  • 52 views

Hello!

I’m trying to follow the documentation provided here : 
https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/forms/adaptive-forms-authoring/authoring-adaptive-forms-core-components/create-an-adaptive-form-on-forms-cs/create-and-use-custom-function-core-component/custom-function-core-component-scope-function

Essentially I’m attempting to set the property of a field to either being valid or invalid depending on its content and then validating it.

I’m attempting to call : globals.functions.setProperty(field, {valid: true}), as well as globals.functions.validate(field) but neither seem to be working.

In order to try and figure out why I’m encountering this issue, I’ve added some console.logs at various levels of my code and I’ve noticed that if I attempt to log globals.functions, it comes back as undefined.

This seems to be the crux of my issue since I obviously can’t call global functions if they aren’t defined, but I was under the impression this was part of aem core components so I’m unsure what I am missing.

Any help would be greatly appreciated.

Best answer by AmitVishwakarma

Hi ​@NorahLa1 globals is not a true global variable. It only exists as a hidden, last parameter that AEM passes into your custom function at runtime. If you don’t declare it as the last parameter, or you try to use it outside that function (e.g. in the console or top‑level JS), it will be undefined. Docs explicitly say the scope param has to be the last one and is hidden in the rule editor UI https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/forms/adaptive-forms-authoring/authoring-adaptive-forms-core-components/create-an-adaptive-form-on-forms-cs/create-and-use-custom-function-core-component/custom-function-core-component-create-function

Correct usage (AEMaaCS, Core Components)

  1. Define your custom function with globals as the last argument:
    • // my-custom-functions.js
      function validateMyField(field, globals) {
      // mark as valid/invalid
      globals.functions.setProperty(field, { valid: true });
      // run validation
      globals.functions.validate(field);
      }
  2. Register this function as a custom function (per the doc you linked) and then, in the Rule Editor, call it as if it only had the explicit parameters, for example:
    validateMyField(field)

    AEM will automatically inject the hidden globals parameter as the last argument at runtime https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/forms/adaptive-forms-authoring/authoring-adaptive-forms-core-components/create-an-adaptive-form-on-forms-cs/create-and-use-custom-function-core-component/custom-function-core-component-create-function

  3. What you must not do:

    • Don’t try console.log(globals.functions) in the browser console or at top level in a clientlib – there is no global globals object there, so it will always be undefined.

    • Don’t omit the globals parameter or put it in the middle of the parameter list; it must be the last argument.

Check below points:

Thanks,
Amit

2 replies

kautuk_sahni
Community Manager
Community Manager
February 5, 2026

@Pranay_M ​@abhilashy577678 ​@AmitVishwakarma ​@Stephan_Reiners Tagging you to see if you might want to share any best practices or insights on this topic. Your expertise would be greatly appreciated, thank you!

Kautuk Sahni
AmitVishwakarma
Community Advisor
AmitVishwakarmaCommunity AdvisorAccepted solution
Community Advisor
February 10, 2026

Hi ​@NorahLa1 globals is not a true global variable. It only exists as a hidden, last parameter that AEM passes into your custom function at runtime. If you don’t declare it as the last parameter, or you try to use it outside that function (e.g. in the console or top‑level JS), it will be undefined. Docs explicitly say the scope param has to be the last one and is hidden in the rule editor UI https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/forms/adaptive-forms-authoring/authoring-adaptive-forms-core-components/create-an-adaptive-form-on-forms-cs/create-and-use-custom-function-core-component/custom-function-core-component-create-function

Correct usage (AEMaaCS, Core Components)

  1. Define your custom function with globals as the last argument:
    • // my-custom-functions.js
      function validateMyField(field, globals) {
      // mark as valid/invalid
      globals.functions.setProperty(field, { valid: true });
      // run validation
      globals.functions.validate(field);
      }
  2. Register this function as a custom function (per the doc you linked) and then, in the Rule Editor, call it as if it only had the explicit parameters, for example:
    validateMyField(field)

    AEM will automatically inject the hidden globals parameter as the last argument at runtime https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/forms/adaptive-forms-authoring/authoring-adaptive-forms-core-components/create-an-adaptive-form-on-forms-cs/create-and-use-custom-function-core-component/custom-function-core-component-create-function

  3. What you must not do:

    • Don’t try console.log(globals.functions) in the browser console or at top level in a clientlib – there is no global globals object there, so it will always be undefined.

    • Don’t omit the globals parameter or put it in the middle of the parameter list; it must be the last argument.

Check below points:

Thanks,
Amit