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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Why are my functions not being found on the form?

(0) ShareShare
ReportReport
Posted on by 90

Hi all,

I am practicing writing JS functions on forms, and I can't seem to resolve this error. I have added a few functions to my web resource, all which worked previously. But now that I am adding the notification function to this form, it's breaking all of the other functions above which previously worked? I added my code to to a syntax checker and it all checked out as well. Any ideas?

if (typeof (Dom) == "undefined") { Dom = { __namespace: true }; }
if (typeof (Dom.Scripts) == "undefined") { Dom.Scripts = { __namespace: true }; }
if (typeof (Dom.Scripts.Opportunity) == "undefined") { Dom.Scripts.Opportunity = { __namespace: true }; }


Dom.Scripts.Opportunity.Form = {
	OnLoad: function (executionContext) {
		debugger
		if (executionContext == null)
			return;
		var formContext = executionContext.getFormContext();
		Dom.Scripts.Opportunity.Form.opportunityFormTesting(executionContext);
		Dom.Scripts.Opportunity.Form.HideOpportunitySummary(executionContext);
	},
	opportunityFormTesting: function (executionContext) {
		debugger
		if (executionContext == null)
			return;
		var formContext = executionContext.getFormContext();
		var optionSetTemperature = formContext.getControl("dom_temperature");
		//var optionSetChoice = optionSetLabelName.getAttribute();

		//var optionSetChoice = formContext.getControl("dom_temperature").getAttribute().getValue();		
		var optionSetChoice = formContext.getAttribute("dom_temperature").getValue();

		//if (optionSetChoice == null) {
		//return;
		if (optionSetChoice == (179820000)) {//Celsius
			optionSetTemperature.setLabel("Celsius");//Approach 1

			//formContext.getControl("dom_temperature").setLabel("Celsius");//Approach 2

		}
		else if (optionSetChoice == (179820001)) {//F

		}

	},
	HideOpportunitySummary: function (executionContext) {
		debugger
		if (executionContext == null)
			return;
		var formContext = executionContext.getFormContext();
		var tabObj = formContext.ui.tabs.get("Summary");
		var sectionObj = tabObj.sections.get("Opportunity_details");
		var optionSetChoice = formContext.getAttribute("dom_hideopportunitysummary").getValue();

		if (optionSetChoice == (179820000)) {
			sectionObj.setVisible(false);
		}
		else if (optionSetChoice == (179820001)) {
			sectionObj.setVisible(true);
		}
		
	},
	addOpportunityNameRecommendation: function (executionContext) {
		debugger
		if (executionContext == null)
			return;
		var formContext = executionContext.getFormcontext();
		var myControl = formContext.getControl("name");
		var oppName = formContext.data.entity.attributes.get("name");
		var specialChar = /[^\w\s]/g;
		var searchedString = oppName.search(specialChar);

		if (searchedString == -1)
			return;

		else if (myControl.addNotification({
			messages: 'Are you sure you would like to include special characters on this opportunity name?',
			notificationLevel: 'RECOMMENDATION',
			uniqueId: 'my_unique_id'
		})
		}
	},
	__namespace: true
};

	

I have the same question (0)
  • Dominic Pilione Profile Picture
    90 on at

    The addOpportunityNameRecommendation function on the bottom is the one that isn't working and is causing all of the functions above to break. Here is the error code:

    One of the scripts for this record has caused an error. For more details, download the log file.

    Web resource method does not exist: Dom.Scripts.Opportunity.Form.OnLoad
     
    I get this error code for each function on the form that I try to initiate
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Dominic Pilione,

    Did you try the solution in this thread?

    community.dynamics.com/.../web-resource-not-found

  • Suggested answer
    Bipin D365 Profile Picture
    28,985 Moderator on at

    Hi,

    There is a syntax error in your JS code.

    Please use below tool to validate your JS code.

    esprima.org/.../validate.html

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 107 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 92

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans