Options

Requesting NAV data from JS client add-in

EvREvR 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

Best Answer

Answers

  • Options
    Jan_VeenendaalJan_Veenendaal Member Posts: 206
    edited 2016-07-04
    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.aspx
    Jan Veenendaal
  • Options
    EvREvR Member Posts: 178
    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).
Sign In or Register to comment.