I have written Dynamics CRM JScript code to populate fields based on previous input, but while running the script I am getting error as "Web resource method does not exist".
**My code: -**
var B_line = window.B_line || {};
(function() {
this.formOnLoad = function(executionContext) {
const formContext = executionContext.getFormContext();
const businessarea = formContext.getAttribute("new_buniessarea21").getText();
const businessline = formContext.getControl("new_businessline21");
function Options() {
businessline.clearOptions();
for (var i = 0; i < arr.length; i++) {
businessline.addOption({
value: arr[i].value,
text: arr[i].text
});
}
}
```
}).call(B_line)
I using this command B_line.formOnLoad to call the function OnChange of the event.
Showing error as "Web resource method does not exist"
Can anyone help me out?
Error image
Hi
Please use this code that i modified
function var B_line(executionContext) {
debugger;
const formContext = executionContext.getFormContext();
const businessarea = formContext.getAttribute("new_buniessarea21").getText();
const businessline = formContext.getControl("new_businessline21");
function Options() {
businessline.clearOptions();
for (var i = 0; i < arr.length; i++) {
businessline.addOption({
value: arr[i].value,
text: arr[i].text
});
}
}
}
-->Main issue is you didn't close the function
call the function name as var B_line in form onload step in form properties
Please Rply if you find this useful
Hi there,
I believe there is something need to re-check around script namespace declarations.
Following code works perfectly. Please try this.
if (typeof (B_line) === "undefined")
{ B_line = {}; }
B_line.formOnLoad = function(executionContext) {
const formContext = executionContext.getFormContext();
Xrm.Utility.alertDialog("testing script success")
}
Also I see in your scrip there is arr.length n loop, where are you getting the arr variable?
If any other issues try to debug in browser pressing F12 and adding debugger; at the beginning of the code.
I have entered it correctly
Pls check
Hi Rajath,
Please check your event, library and function name is entered correctly in handler properties
If you found this helpful, like or verify my answer
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,522 Super User 2024 Season 2
Martin Dráb 228,441 Most Valuable Professional
nmaenpaa 101,148