Requesting NAV data from JS client add-in

EvR
Member Posts: 178
Hi all,
Imagine the following situation.
A javascript client add-in. From the add-in I need to ask NAV to send me some data.
I can add an event handler to my add-in. Let's call it 'OnGetCustomerName'.
c#:
public delegate void GetCustomerNameEventHandler(string customerNo);
[ApplicationVisible]
event GetCustomerNameEventHandler OnGetCustomerName;
JavaScript:
var customerNo = '1000'
Microsoft.Dynamics.NAV.InvokeExtensibilityMethod("OnGetCustomerName", [customerNo]);
This will raise the event in C/AL and I can start getting the customer by its number. But I cannot return any data to the client add-in this way.
How could I return the customer name to the javascript add-in?
Gr, Erik
Imagine the following situation.
A javascript client add-in. From the add-in I need to ask NAV to send me some data.
I can add an event handler to my add-in. Let's call it 'OnGetCustomerName'.
c#:
public delegate void GetCustomerNameEventHandler(string customerNo);
[ApplicationVisible]
event GetCustomerNameEventHandler OnGetCustomerName;
JavaScript:
var customerNo = '1000'
Microsoft.Dynamics.NAV.InvokeExtensibilityMethod("OnGetCustomerName", [customerNo]);
This will raise the event in C/AL and I can start getting the customer by its number. But I cannot return any data to the client add-in this way.
How could I return the customer name to the javascript add-in?
Gr, Erik
0
Best Answer
-
You are right: there is no way to get direct results back. That is by design.Jan Veenendaal5
Answers
-
You cannot use return values, but you can create functions in your JavaScript Add-in, call these from NAV and send data to your add-in that way.
You could watch this video (for NAV2013R2, but still valid) https://msdn.microsoft.com/en-us/dynamics/nav/dn848430.aspxJan Veenendaal0 -
That's the way I'm doing it now.
But if I need data right away inside a callback, there is no way to do it that way.
Of course the customer example was fictional and easy. The real task is more complex (a lazy loading request inside a treeview).0 -
You are right: there is no way to get direct results back. That is by design.Jan Veenendaal5
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions