Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Web resource method does not exist

Posted on by 215

I'm getting the above error on one of my scripts on the Opportunity form and I'm unsure why. This is the first time I've actually tried writing a script and implementing it on a form, so I imagine it's a fairly simple fix I'm just not aware of!

I have added the code as a web resource and enabled it on my form. I have also saved and published these changes and cleared my cache before testing.

pastedimage1632839936020v1.png

These are the error details:

ReferenceError: Web resource method does not exist: NewBusOppError
Error Details:
Event Name: onchange
Function Name: NewBusOppError
Web Resource Name: samar_/NewBusinessOppError
Solution Name: Active
Publisher Name: DefaultPublisherorg36a1d10f

And this is my script:

var Safe = window.Safe || {};
//This function gives an error message if the Opp Type is New Business but there is an Originating Lead.
(function () {
this.newbusopperror = function (executionContext) {
var formContext = executionContext.getFormContext();

// GET Opportunity Type
var opportunityTypeValue = formContext
.getAttribute("safe_opportunitytype")
.getValue();
var record_id = opportunityTypeValue[0].id;
//var salesProcess = formContext.getAttribute("samar_salesprocess").getOption(value);
var Lead = formContext
.getAttribute("originatingleadid")
.getValue();

if (
opportunityTypeValue != null &&
record_id.toUpperCase() == "{8815B22C-80E0-EA11-A813-000D3A4B2C9E}" && Lead == null
) {
alert("New Business Sales Should Always Start as a Lead");
}
};
}.call(Safe));

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: Web resource method does not exist

    Hi ONE BEE,

    Create a separate thread as it is already closed.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform/Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

  • ONE BEE Profile Picture
    ONE BEE 15 on at
    RE: Web resource method does not exist

    My code is showing script error

    Web resource method does not exist: HideorShowSecSession
    Event Name: onchange
    Function Name: HideorShowSec
    Web Resource Name: new_HideorShowSecSolution
    code is as follow

    function HideorShowSection(executionContext) {
    debugger;
    var formContext = executionContext.getFormContext();

    var tabvalue = formContext.getAttribute("new_tabselection").getValue();
    formContext.ui.tabs.get("tab_6").setVisible(false);
    formContext.ui.tabs.get("tab_4").setVisible(false);
    formContext.ui.tabs.get("tab_5").setVisible(false);


    if (tabvalue == 100000000){
    formContext.ui.tabs.get("tab_4").setVisible(true);
    formContext.ui.tabs.get("tab_5").setVisible(false);
    formContext.ui.tabs.get("tab_6").setVisible(false);
    }

    else if (tabvalue == 100000001){
    formContext.ui.tabs.get("tab_5").setVisible(true);
    formContext.ui.tabs.get("tab_6").setVisible(false);
    formContext.ui.tabs.get("tab_4").setVisible(false);
    }


    else (tabvalue == 100000002){
    formContext.ui.tabs.get("tab_6").setVisible(true);
    formContext.ui.tabs.get("tab_5").setVisible(false);
    formContext.ui.tabs.get("tab_4").setVisible(false);
    }
    }

  • Verified answer
    Inogic Profile Picture
    Inogic 24,094 on at
    RE: Web resource method does not exist

    The error occurs due to the function name “newbusopperror”. We cannot call as it is, since in your code you have used objectname.

    So while calling you need to add object name along with the function name i.e. Safe.newbusopperror, while triggering the function.

    4621.form-properties.jpg

    Hope this  helps.

    Thanks!

  • thecharwest Profile Picture
    thecharwest 215 on at
    RE: Web resource method does not exist

    Ah, I knew it would be a simple fix! Thanks so much.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Web resource method does not exist

    Hi thecharwest,

    Usually this error is caused by these two reasons:

    1. Your JS code  has syntax issue.

    2. You give the wrong function name when you create event.

    In your case, your code syntax is correct. So you could give the wrong function name.

    Please change newbusopperror to Safe.newbusopperror:

    pastedimage1632880735095v3.png

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans