Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

How can I add a JavaScript file reference (as dll file in .NET) into my D365 FO project?

Posted on by 155
Hi experts,

I want to add a reference to a JavaScript file like the way we add dll file of .NET in D365FO. Is it possible? if yes, how can we do that? 

Actually, I have written my logic, consider a method in a JavaScript file and I want to call that method in my D365FO.

I will be thankful to you.

Regards,
Arif
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    How can I add a JavaScript file reference (as dll file in .NET) into my D365 FO project?
    As I said, it's sounds like a completely wrong idea to me. If you want to call JavaScript code from F&O, run it it somewhere else, such as in an Azure Function. Inside F&O, you can use either X++ or .NET Assemblies, not JavaScript.
     
    A place where F&O uses JavaScript is on the client side, i.e. in web browsers. It means that you can use it when developing extensible controls, but not to mix it with X++ on server side.
  • Arif Hussain Profile Picture
    Arif Hussain 155 on at
    How can I add a JavaScript file reference (as dll file in .NET) into my D365 FO project?
    Sir Martin Dráb,

    I have completed it in .NET and it meets my requirements and for that I am really thankful to you. And know I am trying to learn if in future I have any requirements like these doing any integration with any JavaScript or other than .NET language then how can I do that. I first thought I can do the same way like .NET but I got stuck and it's really a new thing for me to learn. I also tried creating a resource and adding my JavaScript file there but I do not know how to use that. Please suggest me with your best knowledge.

    Regards,
    Arif Hussain
  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    How can I add a JavaScript file reference (as dll file in .NET) into my D365 FO project?
    Hmm, so you have a solution that you can use in X++ (through .NET Interop), but you decided not to use it and rather to rewrite it in JavaScript, which you then can't use from X++. Why? It sounds like investing time to artificially create a dead end.
  • Arif Hussain Profile Picture
    Arif Hussain 155 on at
    How can I add a JavaScript file reference (as dll file in .NET) into my D365 FO project?
    Sir Martin Dráb,

    I am waiting for your kind response. 
  • Arif Hussain Profile Picture
    Arif Hussain 155 on at
    How can I add a JavaScript file reference (as dll file in .NET) into my D365 FO project?
    Sir Martin Dráb,

    Suppose, I have the same requirement of integrating with a third-party website which verify an invoice which you already answered in the below link mentioned but it is in .NET dll file

    https://community.dynamics.com/forums/thread/details/?threadid=c061ef80-2747-ee11-be6d-6045bdebe084

    Now, I have written the same code in JavaScript file which contains a method with a parameter as object. So, now I have to access that file in D365FO directly without accessing any .NET code.

    Please suggest to your best understanding.

    Thanks and regards,

    Arif Hussain
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    How can I add a JavaScript file reference (as dll file in .NET) into my D365 FO project?
    If you want to use JavaScript through .NET Interop, you'll have to compile JavaScript to CIL. As far as I know, no such a compiler exists, therefore it's not a good idea.
     
    There are ways how to use JavaScript from C#, but if you ask me, you shouldn't be doing such things. Either use a CLI language or implement this thing in JavaScript as a separate component.
     
    It may be more efficient if you explain your business requirements to us, so we can help you to design a solution that is technically possible.
  • Arif Hussain Profile Picture
    Arif Hussain 155 on at
    How can I add a JavaScript file reference (as dll file in .NET) into my D365 FO project?
    Sir Bharani Preetham

    I have found how to access that resource like this. 
     
    internal final class JavaScriptTestJob
    {
        public static void main(Args _args)
        {
            ResourceNode textFileResourceNode = SysResource::getResourceNode(resourceStr(JavaScriptResource));
    
        }
    }

    Now, I have a method in my JavaScript file with a parameter and I have to call that from D365FO x++ and pass an argument. How can I do that?
  • Arif Hussain Profile Picture
    Arif Hussain 155 on at
    How can I add a JavaScript file reference (as dll file in .NET) into my D365 FO project?
    Sir Bharani Preetham

    I really appreciate your prompt response. Can you please let me know how to use that resource in my code? I am trying to access it like the below image but it's showing me an error.



    Regards,
    Arif Hussain
  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,605 Super User 2024 Season 1 on at
    How can I add a JavaScript file reference (as dll file in .NET) into my D365 FO project?
    You can create a resource in which you can place the javascript file. For reference of this, you can check extensible controls. There javascript file will be used as a resource.
  • Arif Hussain Profile Picture
    Arif Hussain 155 on at
    How can I add a JavaScript file reference (as dll file in .NET) into my D365 FO project?
    SirMartin Dráb,

    Can you please share your insight about it?

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans