TradePoint - customizing the NAV integration
Modifying NAV callsTerminologyAction Word - When communicating with NAV from TradePoint, an action word is passed along to identify which action to perform. NAV - Dynamics NAV, previously known as Navision NAS - Navision Application Server - a service which in TradePoint's case polls a specified Message Queue for messages to handle. Scriptlet - A ScriptServer concept. A scriptlet is an object with methods, all defined in script code inside ScriptServer. Scriptlets are modified using the Scriptlet Manager. TradePoint MQ Form - An alternate solution to using the NAS. Should only be used for debugging and testing purposes. Calls to NAVWhen calling NAV to either perform an action or to retrieve a value, TradePoint does this through a scriplet method: TradePoint.InvokeTP(). This method has a couple of parameters which are explained below:
TradePoint.InvokeTP(actiontype, convertToRecordSet, paramNames, paramValues, customerNo, cacheMode, cacheMinutes)
The returned result is returned as a record set (if the 2nd parameter is set to true) from which the values can be picked out, row by row. Example: var rs = TradePoint.InvokeTP("GETITEM", true, nameArr, valueArr); var itemNumber = rs("No.").value;
The names of the parameters are specified in the code unit executing the NAV call. Knowing which NAV code is being executedTo find out which NAV code is being executed at a certain time you can go about in 2 ways - review the ScriptServer template in use or monitor the calls coming to your NAS. Method 1 - Review the ScriptServer template in useTo find the template in use for a certain page, you either click the Properties icon to see the properties dialog for the current page which will tell you the template it uses or you can also use the System Editor to open the page that's being displayed by looking at the current URL. In the template code you should most likely find a TradePoint.InvokeTP() call. You might also find it inside one of the Scriptlet calls being made in the template code. Once you find the InvokeTP-call write down the actionWord parameter and proceed. Method 2 - Monitor the NAS callsSince all TradePoint NAV calls are passed through the TradePoint NAS TC code unit, you should monitor this code unit to find out which action words are being passed on. Simply add a MESSAGE() call on the top of the code unit to display which action word was sent in. if you are running the NAS your message will end up in the event log, if you are using the TradePoint MQ Form, you message will be shown as an alert in your NAV client. If you are running the TradePoint MQ Form you can also use the NAV Debugger to step through the code nice and easily. Finding the NAV code unit being executedOnce you have the action word, just locate it in the TradePoint NAS TC code unit to find out which code unit and method it invokes. Adding incoming parametersOnce you have determined which code unit and method is being called, modifying the NAV code to accept new parameters is a simple procedure which should pose no big obstacle to any one comfortable working with C/SIDE. Remember that you always get the customer no. passed on automatically, so no need to add anything on the ScriptServer end to get that information. Adding outgoing parametersTo add an outgoing parameter you need to make at least 2 modifications - add the column and add the actual value. Browsing through the response code you will quickly find that there are 2 major sections in the code - first there is the section where all the column names are specified and then the section where the actual data is being added, line by line.
Once you have added a new column, compiled the code unit and restarted the NAS, your new data is available to be retrieved in the TradePoint templates. Adding a new NAV callYou can add as many action words as you like to expand the functionality of TradePoint. Guidelines for this process are described in a separate help article.
NAV errorsIdentifying a NAV errorNAV errors are usually being displayed as a Windows alert box, showing the NAV error message just the way it would have been displayed inside the NAV client. Debugging NAV errorsUtilizing the methods described above you should be able to find out which part of your NAV code is being executed at a particular time. The best way to find the exact line of code is of course to turn of the NAS and instead use the TradePoint MQ Form. This allows you to use the debugger and set break points and step through your code line by line. |
Published by: Henrik Weimenhög / scriptserver.com
