Add Function on a Report

Hi,

I create a report and i have a field (textbox) to do the amount (sum of others fields). Now i want to put the same value (amount) on another textbox but convert it into words. I search and search and i found that i need to use the function on report 1401 FormatNoText. I copy the function and all things that it needs to run to my report. Now i need to know how i call/add the function on the report textbox that I want.

Sorry, but i´m new at this.

Please Help and thank you for your time.

Well, when you’re starting out in learning NAV development, start small. By that I mean that you can isolate the specific question you have, work on it in a clean and safe environment until you know the answer.

In this case, if I were you, I’d build a very simple form object to use to test the use of this function that you’ve copied from report 1401. This form would not have a source table. I’d create two global variables, one decimal to set the amount you want to test, and one text to store the return value of your function. I’d add a command button that calls the amount formatting function, passing in the value of your global decimal variable, and capturing the return in your global text variable. Obviously you’ll create a control on the form for each of these two variables so you can see what’s going on.

Then, copy the formatting function from report 1401 to this form object, along with all that it needs. Once you have your test form put together, then study the code in report 1401 to see how the formatting function is called and how the results are captured. Keep testing and adjusting your code on this test form until you can make the function product the output you’re looking for.

Once you’ve finished testing and modifying code in your test form, it’s a simple matter to copy it all over to your subject report and tie it all it. This approach is much easier than trying to learn, code and test within the target report object.

Just a thought, I hope it’s helpful.

HI David…

George is right. Try to learn this way. But why to copy function from report. You can directly call the function from report. You can use like

checkReport.InitTextVariable;
checkReport.FormatNoText(NoText,ABS(Amount),currencycode);

where NoText is a Text variable of length 100 and Dimensions 2. and show Notext[] variable anywhere that contains amount in words.

Hope this wll help you. :slight_smile:

I have been talking with people who works with nav, and they said to me that i need to create a variable to do the calcs. In witch trigger i put and do the calcs for the sum of the fields that i want?

After that they said to me that i need to do this:

Variable := function (number to text) that i copy from report check 1401.

After i put the function on variable, i think i just need to go to my report layout and go to textbox expression and associate the variable…

When i run the report 1401 it gives me a blank page… i canot see anything there.

I start using nav 1 mounth ago, so im a little newbie… sorry if i explain something wrong.

Hi David,

Bheem makes a good point, and that is that in professional production environments, we try not to replicate code where it’s not necessary. I suggested it just for the simplicity in a learning environment. Depending on the version of NAV you’re on, you may find the FormatNoText function in report 1401, or in later versions, in report 10400. There’s nothing magic about defining one of these reports as a variable in your code and calling the function from your code.

Obviously, it’s your responsibility to come up with the right amount to pass to this function. Without knowing your business objective or seeing your program object, I can’t really offer any advice as to how to go about doing that. After you’ve made your calculations and you’ve passed the amount to the format function, you’re right, your next step is to create controls on the page or report to display the output of the function, and that’s done by setting the Source Expression property of the control to the text variable that contains the formatted number text. Remember to account for the point that Bheem also mentioned … the text argument in the function call is a 2-element array of Text80.

If your company is current on their support/maintenance contract, you may also have access to some training materials on Customer Source. You might benefit from reading through some of the programming documents available there, just to get an idea of how it all fits together. And, rely heavily on your peers and colleagues and seniors for advice.