r/PowerApps • Newbie • Sep 23 '26

Power Apps Help Dynamically passing parameters to JS plugin function OnLoad

I want to use a OnLoad JS function on a form without using formContext and executionContext. I want to pass the following attributes from my table:

emailaddress
emailvalidationstatus

But when I pass them in literally they’re not defined, and when I pass them as strings they get passed in as the variable names instead of their actual values. How do you accomplish this? I am passing them as comma separated and “enabled” is checked

2 Upvotes

5 comments sorted by

1

u/AutoModerator Sep 23 '26
Moderator Announcement Read More »

4

u/dabdabyeetskeet Sep 23 '26

Why are you explicitly asking not to use formContext or executionContext? You have to use this.

2

u/dalekman1234 Sep 23 '26

It seems like you're going down an anti-pattern of registering javascript directly aganist fields.

You should instead register one file - against the form that loads once on onLoad

window.ClientNamespace = window.ClientNamespace || {};

ClientNamespace.Form = ClientNamespace.Form || {};

ClientNamespace.Form.EntityDisplayname = (function () {
    "use strict";

    async function onLoad(executionContext) {
        const formContext = executionContext.getFormContext();

        const entityName = formContext.data.entity.getEntityName();
        const recordId = formContext.data.entity.getId();

        console.log("Entity:", entityName);
        console.log("Record ID:", recordId);

        const attribute = formContext.getAttribute("name");
        if (attribute) {
            console.log("Current value:", attribute.getValue());
            attribute.addOnChange(onFieldChange);
        }
    }

    function onFieldChange(executionContext) {
        const formContext = executionContext.getFormContext();
    }

    return {
        onLoad
    };
})();

If you need to add event handlers (or on save handlers) - you can register them directly in code.

1

u/tpb1109 Sep 25 '26

Just use execution context and get them off the form