AutoCalcField – What’s that?

There are so many properties and functions available in Navision that its impossible to learn them completely in few years. Some of them are complex but most of them are simple and we simply unknowingly use them.

You would have been amazed knowing some of the properties which you use quite regularly but never bothered about knowing them. In this series of posts, we will try to under few of them. Today we will start with ‘AutoCalcField

You all know that if you display a flow field onto a form or a report, the system calculates the flow field value automatically and displays it. Do you know why system behaves like this? Just because of the property ‘AutoCalcField‘.

This simple property is related to any control onto a form or a report which displays a flow field. In other words, you can change this property in those controls whose source expression is a flow field.

Why we don’t really notice them? Because ‘Yes’ is the default value for this property. If you turn it to ‘No’, the control simply will not calculate the flow field value automatically.

To check it out, open the Vendor card (form 26) in design mode and go to the property of the field “Balance (LCY)”. You will find, the AutoCalcField property is set to ‘TRUE’ by default. You can change it to ‘No’ and see whether this field is anymore displaying the Vendor Balances or not.

Good Luck.

See you in Next property 🙂

Sequential Import of Multiple files into Navision Using Dataport

Can you import multiple files sequentially using Navision dataport?

Say you will put all the files to import into Navision in a folder and one navision dataport will import all the files one by one into Navision.

Here is how I have done it –

Created a new form and put a text box where user can mention the folder path from where the files will be imported. Also put a command button which will start the import process clicked.

Took the following variables in C/AL Globals –

WIN Dialog Type -> to display the progress of import
FileRec Record type -> referenced to virtual table ‘File’
CTR Integer type -> to count the number of files imported
TransImport Dataport type -> referenced to a dataport which will be run repeatedly depending on number of files present in the folder
FilePath Code type -> to store the file path of the folder

Also took a text constant for displaying the import progress in the dialog box ‘WIN’

Text50000 Importing File #1#####################Count of File #2#####

Once the definition of variables are done, write the following code in the OnPush trigger of the command button –

ImportButton – OnPush()

WIN.OPEN(Text50000); // opening the dialog box to display the import status FileRec.SETRANGE(Path,FilePath); // Accessing the folder path mentioned by the user and stored in the ‘FilePath’ variable.
FileRec.SETRANGE(“Is a file”, TRUE); // Excluding the sub folders (if any) present in that folder.
IF FileRec.FINDFIRST THEN BEGIN // Ensuring that at least 1 file is present in the folder and pointing the instruction pointer to the first files in the folder.
REPEAT // Starting the loop to read files one by one
CTR += 1; // Capturing the file count
WIN.UPDATE(1,FileRec.Name); // Displaying file name in the dialog box.
WIN.UPDATE(2,CTR); // Displaying file counter in the dialog box.
CLEAR(TransImport); //Clearing the previous instance of the dataport
TransImport.FILENAME := FileRec.Path + ” + FileRec.Name; // Sending the file name with the file path to the dataport.
TransImport.RUNMODAL // Running the dataport.
UNTIL FileRec.NEXT = 0; // Loop condition till all the files in the folder is read.
MESSAGE(‘Import Done’); // Informing user that import is complete
WIN.CLOSE; // Closing the dialog box
Note: Your variable name can be different and you need to adjust your code as per your variable definition.

Now run the form and enter the folder path where your files to be imported are stored and click on the button ‘Import’. This will start the import process and will continue till all the files from the folder is imported into the database.

You can automate the same with the help of timer trigger of the form or using an application server. Will discuss the process of automating it in our future discussion.

All the best. Try it.

Have you migrated your Navision to SQL Server 2005 recently

Very recently Nisheel Poddar – IT head RKHS, migrated his Navision server from SQL Server 2000 to SQL Server 2005. Can you imagine what problem he has faced?
His users are unable to change their own password using Tools > Security > Password.
Checked with few more people who has migrated to SQL Server 2005 and surprised to find that everybody is having the same problem and they are solving the problem simply by assigning the dbowner role to their general users.
Dangerous. Don’t you think?
Nisheel Poddar was not satisfied and searched for solutions. What solutions we found you know?
In SQL Server 2000, we used to give the following roles to users while doing the user mapping to any Navision database:
1. Public (by default this is assigned to all users)
2. db_dataReader
3. db_datawriter
These 3 roles are enough for a generic user to use Navision functionality. Even this gives you the permission to change your own password using Tools > Password.
Here you mention your old password and assign a new password.

But when you migrate to SQL Server 2005, The same roles assigned to users does not allow them to change to their own password. When your users tries to change it, they will see the following error –

“The following SQL Server error(s) occurred:
15151,”42000”,[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot alter the login ‘nisheel’, because it does not exist or you do not have permission.

SQL:{CALL [sp_password](?, ?)}”

When you change your password from Navision client, the stored procedure ‘sp_password’ is called and the necessary permission to execute this stored procedure was included in ‘Public’ role of SQL Server 2000.

But the same permission is no longer associated with ‘Public’ role in SQL Server 2005. And that’s why you will have the problem in changing the password. And you are taking a dangerous decision of assigning ‘dbowner’ role to your users.

To resolve it without assigning the ‘dbowner’ role, you need to explicitly assign a specific permission to your ‘Public’ Role (the permission having execute power of Sp_password). Follow the instruction below

1. Follow the standard procedure of creating a new users and mapping them to a your Navision database. While User Mapping, assign the normal roles Public, db_datareader, db_datawriter.

2. Now, assign the permission ‘Alter any Login’ to your ‘Public’ role. Select the Server and open its property window.

Select ‘Permission’ page in left hand pane and select ‘Public’ role in the right hand pane. Scroll down and find the ‘Alter Any Login’ permission. Grant this permission to ‘Public’ Role.

Do remember, you need to be System Administrator to do the above setup.

Now try to see whether your users are able to change their own password or not. They will be able to do that.

This may not be the best possible solution and you are welcome to send your suggestion or any other solution to it.

Do send me your comments and suggestions.

Reblog this post [with Zemanta]

Do you want to keep a flow field editable on a form or in a table?

Let’s try it.

Say we will make ‘Balance (LCY)’ field in Customer card editable and test it. In Customer card, the textbox control is already editable and it is inheriting the ‘Editable = No’ property of the field from the customer tables.

Let’s make the ‘Balance (LCY)’ field editable in Customer table.

Select the field > Properties > Editable > Yes

Once this is done, the textbox displaying ‘Balance (LCY)’ in Customer card will become editable and you can put new amount in this field.

Right now, the calculated amount (coming from Detailed Cust. Ledger Entry) is shown as 73,810.00.

Let’s modify it to 80000.00 (an increase of 6,190.00)

So what will happen now. Your customer card is showing a value of 80000.00 whereas your detailed customer ledger entry table have entries of amount 73,810.00 only. is your data customer entries become inconsistent?

Not really. Navision never allows inconsistent data in flow fields. The system will simply will lookout some way to make the data consistent. It simply insert a new entry in ‘Detailed cust. ledger entry’ to adjust the inconsistent data.

Here, look at the detailed cust. ledger entry and you can see a new entry having an amount of 6,190.00. This new entry makes the total 80000.00 (now consistent)

Pretty dangerous! What do you think? To avoid this, you need to keep your flow field always ineditable.

But having seen the above incidence, can you think about any scenario, where this particular feature / rather drawback can be very useful?

Let me know if you find something interesting.

Have you ever put a number in the G/L Journal Batch Name?

This time Mr. Parasuram Reddy is right :).

If you include a number in the journal batch name, the name will change by one number with every posting. Say your batch name is Snehanshu01. This will change by one number after every posting, to Snehanshu02, Snehanshu03, and so on.

In Navision it is possible to set up several journal batches under each journal template. That is, the same window can be used to display several different journals, each with its own name. This particular functionality is provided to facilitate / manage the batch names / registering each posting with unique Journal batch naming. This is particularly useful if every user of Navision is having his or her own journal.

Before Posting:

After Posting:

Do you know what Happens if you assign same no. series to both unposted as well as posted document?

Let us simulate the same scenario.
I have created a new no. series named ‘Test’ with a starting document no. ‘TEXT0001’ and assigned it to both ‘Unposted Sales Invoice’ as well as the ‘Posted Sales Invoice’ in sales & Receivables Setup window.
Afterwards, we have created 2 unposted sales invoices with the document no ‘TEST0001’ and ‘TEST0002’ (generated by the no. series Test).
The first sales invoice has the external document no ‘ABC’ and the second one has ‘ABC1’ as external document no.
Now what will happen if I post these documents? One of the comments in this discussion says that it will create a document no after the last no created by the no. series. So the first posted document will be ‘TEST0003’? What do you think? Let me post the invoices.
To make it more interesting, I have posted the second document (‘TEST0002’) first and the first document (‘TEST001’) second. Here is the screen shots of the posted documents. You can identify the documents with their respective external document no.

This is the first document posted second identified by the external document no ‘ABC’.
This is the second document posted first identified by the external document no ‘ABC1’.
You got the answers?
In this scenario, the posted documents are taking the same document no assigned in their unposted state. And as no new no is generated by the no. series, the posting process does not update the ‘Last no used’ field of the no. series line.
Have you tried this ever? Try it and I believe you will also find application of this functionality in real life implementation scenario also.
Best of luck

Do things differently

To start our discussion, let’s take a simple topic –

Few months back, in one of Orkut forum somebody had posted a problem as follows:

‘I have to pick out a digit from a code field. E.g. Code is ‘50123AD786′ n I have to select 7th character from this field How can this be done…’

You all know it’s simple and the common way to achieve this is:

Copystr([ur code variable],[position, say 7 for 7th position],[length, here for u its 1])

We have designed a new form here. Taken a new global variable called ‘Name’ of data type Text and inserted a text box to display the variable.

We also have written a single line code as per the above syntax to display the 7th character of the ‘Name’ in a message box.

Now, can we do it in not so common way?

Yes, we can if we know that a text string in Navision is nothing but an array of characters (literally). So here ‘Name’ variable is nothing but an array of its length and we can fetch out the 7th character of it by simply referring it as Name[7]. To validate it, let us change the code in the ‘OnPush’ trigger of the Button as below:

Message (FORMAT (Name [7]));

Why we needed a FORMAT command? Just because the message box can only display text not character.

Here I entered ‘Snehanshu Mandal’ in the text box and clicked on the button ‘Click me’. It’s displaying the 7th character of my name ‘s’.

Don’t you think it’s interesting?

How can we make working on Navision a FUN?

Hi friends! How are you doing?

Last month, I completed 6 ½ years working in Navision and was stumped by one of my junior’s question – Don’t you get bored while working with Navision after so many years? Big question.

People are getting bored very fast nowadays. But why? You get bored when –

1. Work is monotonous
2. Work can be monotonous when you know everything and there is nothing new left to learn
3. ‘Hey, I am doing the same form designing, report designing and data port designing’

Besides the above points, you will find plenty of reasons of why people are getting bored in Navision.

I think the answer lies in the approach you have towards Navision. Whether we are trying to solve a problem too technically or we are having a holistic approach to solve a problem? Again to have a holistic approach towards a problem, you need to be little experienced on Navision or you have a fair idea about Navision functional things. So the whole issue is little paradoxical.
Whatever may be the reason, here we are not to discuss the problem. Rather we are here to try & make working on Navision a little more enjoyable. And to make it enjoyable, the best thing is to do something new in Navision every day. Mind it, you can do something new only when you do not know everything but you know something of Navision to start with.

I am not here to teach you something new in Navision rather together we will search new things in Navision. Every day, we will discuss about one topic and if you feel interested, you are welcome to suggest me the future topic or contribute a new discussion. You are welcome to send the problem you are having in your implementation and together we will try to evolve most reasonable solution of it. When so many brains will work on the problem, definitely we will be able to achieve most suitable solution for the problem
So let’s wish ourselves happy learning of Navision.