web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Web Resource doesn't exist - Stuck with this problem for a week

(1) ShareShare
ReportReport
Posted on by 2
I'm getting this Script Error when I'm trying to wire my JS file to my CRM:
 
ReferenceError: Web resource method does not exist: NameOnChange
    at b._handleMethodNotExistError (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:14:1272803)
    at b.execute (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:14:1271391)
    at https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:4:121402
    at i (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:14:97179)
    at re._executeIndividualEvent (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:4:121376)
    at re._executeEventHandler (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:4:118194)
    at Object.execute (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:4:117584)
    at w._executeSyncAction (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:14:623113)
    at w._executeSync (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:14:622840)
    at w.executeAction (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:14:622622)
    at t.dispatch (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:14:627959)
    at Object.dispatch (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:14:900934)
    at dispatch (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:14:627448)
    at Object.execute (https://content.powerapps.com/resource/uci-infra-bus/scripts/17.1dcb02d7db3115cf5c29ee4703a12049.js:4:19354)
    at w._executeSyncAction (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:14:623113)
    at w._executeSync (https://content.powerapps.com/resource/uci-infra-bus/scripts/app.9bfa873a8412319c44f38e34756503b6.js:14:622840)
Error Details:
Event Name: onchange
Function Name: NameOnChange
Web Resource Name: new_AccountScripts
Solution Name: Active
Publisher Name: DefaultPublishereversourcedev
 
This is my code which I isolated into a separate file:
var Sdk = window.Sdk || {};
(
    function () {
        this.formOnLoad = function (exeuctionContext) {
        },
        this.NameOnChange = function (executionContext) {
            const firstName = formContext.getAttribute("firstname").getValue();
            const lastName = formContext.getAttribute("lastname").getValue();
            const middleName = formContext.getAttribute("middlename").getValue();
            const nameRegex = /^[a-zA-Z]+$/;
            let isValid = true;
            formContext.getControl("firstname").clearNotification();
            formContext.getControl("lastname").clearNotification();
            formContext.getControl("middlename").clearNotification();
            let isfieldModified = false;

            if (firstName && !nameRegex.test(firstName)) {
                formContext.getControl("firstname").setNotification("First Name contains invalid characters");
                isValid = false;
            }
            if (lastName && !nameRegex.test(lastName)) {
                formContext.getControl("lastname").setNotification("Last Name contains invalid characters");
                isValid = false;
            }
            if (middleName && !nameRegex.test(middleName)) {
                formContext.getControl("middlename").setNotification("Middle Name contains invalid characters");
            }
            if (isValid && isfieldModified) {
                formContext.getAttribute("eve_fieldmodified").setValue(new Date());
            }
        },
    }
)
AccountScripts.js

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

I have the same question (0)
  • Suggested answer
    SteRe Profile Picture
    14 on at
    Web Resource doesn't exist - Stuck with this problem for a week
    Hi 
    I did not check the whole script in detail if there are semicolon missing or something else but pretty obvious is this. 
    You use executionContext as parameter and later on formContext. But you never declare formContext. Add this
    var formContext = executionContext.getFormContext();
    at the beginning of your function NameOnChange. 
     
    Further some general hints. To use this script you need to create a web resource and publish it. Even when you change something, after every upload you need to publish again. Further you need to add the web resource to form libraries and add some events. As you are getting an error I guess you did this part, but did you also publish before?
  • Suggested answer
    Ben356 Profile Picture
    13 on at
    Web Resource doesn't exist - Stuck with this problem for a week
    Hello,
     
    I have used this code to reproduce the error
     

     
    The namespace "Sdk" that was declared on top needs to be called at the end.
     
    Correct code.

     
    In addition:
    • remember to declare formContext before using it
    • The function should be called with its name space when creating the event
     

    Hope that fixes the error.
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 123 Super User 2025 Season 2

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 89

#3
#ManoVerse Profile Picture

#ManoVerse 85

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans