Skip to main content

Notifications

Announcements

No record found.

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

Web Resource method does not exist due to a single function [Solved]

Posted on by 5

EDIT POST: I have solved the issue I had, it was a Javascript syntax mistake.

I can't find an option to delete this post so I am just editing this. If there is any admin around, please close and delete this post.

Thanks

  • Suggested answer
    Loym Profile Picture
    Loym 5 on at
    RE: Web Resource method does not exist due to a single function [Solved]

    Hi Pablo,

    Thank you very much for taking your time, I had already edited the post before your answer saying that I found the error.

    You are right, it was the foreach causing the problem because I was using await inside the callback of the foreach, which wasn't an async function, hence Dynamics just threw that error that script was not loaded because of this syntax error.

    Once I changed it to a for loop it worked.

    As I said before, thank you very much for your time in order to help me with my problem.

    Greetings.

  • Verified answer
    PabloCRP Profile Picture
    PabloCRP 1,086 on at
    RE: Web Resource method does not exist due to a single function [Solved]

    Hi Loym ,

    What if you change the forEach function by simple for statement in patientPurchasesOnDemand

    // this
    obj.Purchases.forEach(function (purchase) {
        var invoiceRetrieved = await Ab.SharedLogic.retrieveRecordFromWebAPI("invoice", purchase.purchaseId, "?$select="   Ab.SharedLogic.Entities.InvoiceFields.IdAbInvoice, Xrm);
        if (invoiceRetrieved === null) {
            await this.insertInvoiceInCrm(formContext, purchase);
            console.log("Fin insercion");
        }
    });
    
    //By
    var len = obj.Purchases.length; 
    for(var i = 0 ;i< len;i  ){
        var purchase = obj.Purchases[i];
        var invoiceRetrieved = await Ab.SharedLogic.retrieveRecordFromWebAPI("invoice", purchase.purchaseId, "?$select="   Ab.SharedLogic.Entities.InvoiceFields.IdAbInvoice, Xrm);
        if (invoiceRetrieved === null) {
            await this.insertInvoiceInCrm(formContext, purchase);
            console.log("Fin insercion");
        }
    }

    regards.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans