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 };