web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
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?

(1) ShareShare
ReportReport
Posted on by 206
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
I have the same question (0)
  • Arif Hussain Profile Picture
    206 on at
    SirMartin Dráb,

    Can you please share your insight about it?
  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    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
    206 on at
    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
  • Arif Hussain Profile Picture
    206 on at
    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?
  • Suggested answer
    Martin Dráb Profile Picture
    237,813 Most Valuable Professional on at
    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
    206 on at
    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
  • Arif Hussain Profile Picture
    206 on at
    Sir Martin Dráb,

    I am waiting for your kind response. 
  • Martin Dráb Profile Picture
    237,813 Most Valuable Professional on at
    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
    206 on at
    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
  • Suggested answer
    Martin Dráb Profile Picture
    237,813 Most Valuable Professional on at
    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 512 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 291 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans