0

NAV - Quit - Break - Skip - Exit

Posted by Nantharupan on 7:01 AM in , , ,
When i was searching for the difference of these function, i found the answer from the following blog, i just copied that again for the quick reference. 
http://www.navisioncanbefun.com/2010/quit-break-skip-exit/

1. Quit 
Quit can only be used in Report, Dataport or XMLport. (Like Currreport.quit). It quits (come out from) the report or dataport or XMLPORT. If some processing of data happened before the quit statement, all of those data manipulations will be reversed (rolled back).
2. Break
Break can be used in 2 places –
a. in any loop (repeat..until) – This statement will break the loop and come out of the loop without further processing. All the data manipulation before this statement will remain intact.
b. In a report or dataport or XMLport. This statement will take you out from any trigger (like on prereport, Onpresection etc)
3. SKIP 
SKIP is only used in Report / Dataport / XMLPORT. This statement skips the iteration of a dataitem.
4. EXIT
EXIT normally used in functions / triggers to return a value. (say a function returns a numeric value –
Myfunction(integer A, Integer B) Integer—
EXIT(A+B);

0

VALIDATE() - NAV

Posted by Nantharupan on 5:21 AM
VALIDATE() function is call the triggers function for the field. 

When we add, delete or modify a record or filed of a record, we tend to do some validation for the fileds. This validations are put in the On validate trigger of the field. However if you just change the field without calling the VALIDATE function, this trigger will not be called. So if we want to call the VALIDATE function before changing the field, its better to call the VALIDATE function.

We can use the following syntax to validate the GeneralLedgerEntry record field "G/L AccountNo". 

GeneralLedgerEntry."G/L AccountNo" := '100';
GeneralLedgerEntry.VALIDATE("G/L AccountNo"); 

The above two lines can be written into a single line as follows. 


GeneralLedgerEntry.VALIDATE("G/L AccountNo", '100');


0

Regec - Find the Image src,width, height in HTML

Posted by Nantharupan on 3:26 AM
            string regexImgSrc = @"<img[^>]*?src\s*=\s*[""']?([^'"" >]+?)[ '""][^>]*?>";
            string widthpattern = @"(?<=WIDTH:?)[0-9A-Za-z\s]+(?=;)";
            string heightpattern = @"(?<=HEIGHT:?)[0-9A-Za-z\s]+(?=;)";



0

GET - NAV

Posted by Nantharupan on 10:06 PM in , , ,
Its just a tip.

When ever we wanted to filter the record, we tend to use SETRANGE() or SETFILTER() and FINDFIRST()... However, we should keep in mind that, if we are filtering based on the Primary Key, then we can use GET(), it does all the work, we do by writing some lines of code with one life of code.

CustomerRec.RESET();
CustomerRec.SETRANGE("No.", 1291);
CustomerRec.FINDFIRT();


This can be done by using following code,

CustomerRec.GER(1291);

Hope this tip helped some one.!

0

Difference between SETRANGE and SETFILTER

Posted by Nantharupan on 12:15 PM in , , ,
We often face situation to filter record in NAV. There are two function can be used most of the time interchangeable for simple filters. However there might be performance consequences. 

  • SETFILTER()
       It can be assign a filter on a record to a filed we specify. It often used to do the complex filtering. 

  • SETRANGE()
       It is a simple filter, where single value or single range can be set on a field. 

SETRANGE give us a quick way to set up the Filer. 

CustomerRec.SETRANGE("No.", 100, 200); 

Above line simple filter the customer record with customer number from 100 to 200. 

The same functionality can be achieved by using SETFILTER() as follows

CustomerRec.SETFILTER("No.", '>=100&<=200');

We can see the difference. When using the SETFILTER() we should construct the filter statement. However we can not achieve complex filters using SETRANGE().

It is an incomplete post.....





0

NAV FIND() VS FINDFIRST(), VS FINDLAST()

Posted by Nantharupan on 1:26 PM in , , ,
FIND() is used with parameters. Based on the parameters passed in FIND()  different results set. 

  • FIND('-') : To search the first record in the table
  • FIND('+') : TO search the last record in the table.

However FIND is an old function. Instead of FIND('-') FINDFIRST() function can be used, FINDLAST() function can be used instead of FIND('+'). 

After searching in the internet, it seems FINDFIRST(), FINDLAST() functions are efficient and faster compared to the FIND('-'), FIND('+').

However when it comes to REPEAT,UNTIL function, We shouldn't use FINDFIRST().





0

How to Import Excel into MS SQL database table.

Posted by Nantharupan on 1:00 PM in , ,
I was asked to import the data from the Excel to MSSQL database. I wasn't aware of how to do that. However i found the way to do that. I hope this would help some one. 

So Steps,

1. Save the sheet/file as .csv, (Save the file with the same name of the data table would make your life easy )
2. Make sure the column name matches with the data base column names. 
3. Right click on the data base  and select task and import
4. Choose a Data Source -- Choose the Flat File as Type and Particular File,
5. Choose a Destination -- Choose the Destination as SQL Native Client, 
6. Select the data base and Authentication 
7. Make sure all the columns are mapped correctly, 
8. Finish and see are there any errors, (keep in mind there can be data loses, so make sure the whole process fails or success on such occasion by setting the right fails)

Key Points to note

  • Make sure there are no data could loss
  • Make sure the right local
  • Make sure the right column mapping 

0

SQL Bulk Copy

Posted by Nantharupan on 1:00 PM in , ,
Some times we faced situation when we need to insert single row for each millions of iterations. For example, we read from an Excel file which contains millions of students records and we want to add the details to the data base.  This can be done using the Entity Framework as follows,

                foreach (var student in students)
                {
                        using (var ctx = new dbContext())
                        {
                            ctx.Students.AddObject(student);
                            ctx.SaveChanges();
                        }              
                }

However this is inefficient. We can make use of SqlBulkCopy class to do the trick.

          string connString = "";
            // connect to SQL
            using (SqlConnection connection =  new SqlConnection(connString))
            {
                // make sure to enable triggers
                // more on triggers in next post
                SqlBulkCopy bulkCopy = new SqlBulkCopy(
                    connection,
                    SqlBulkCopyOptions.TableLock |
                    SqlBulkCopyOptions.FireTriggers |
                    SqlBulkCopyOptions.UseInternalTransaction,
                    null
                    );

                // set the destination table name
                bulkCopy.DestinationTableName = "tableName";
                connection.Open();

                // write the data in the "dataTable"
                bulkCopy.WriteToServer(dataTable);
                connection.Close();
            }
This would help to reduce the over head.

Visual Studio 2015 - Some useful Short Cuts

Posted by Nantharupan on 12:00 PM in , ,
I have started to working in Visual Studio again after a some time. I have noticed there are some new and useful short cuts, which would make developers life easier. So i listed down some of them. 


  • Alt+Up/Down - Move the code up or down
  • Clt+M+H - Clt+M+U to create a collapsible region
  • Clt+K+C - Clt+K+U to create a comment or un comment
  • Alt F12 to peek a definition from the code
  • Shift + F12 to find all references
  • Clt + Shift + F find in all files
  • Clt + G to go to a particular line number
  • F12 go to definition
  • Ctl \ + E to error list
  • Ctl + F4 close the window
  • Ctl + M + X expand all outline
  • Ctl+M + A Collapse all outline
  • ctrl + k, ctrl + d – Format Document

Find all ports being used by processes - Command Line Commands

Posted by Nantharupan on 11:30 AM in ,
Recently i faced a problem, when i try to deploy one service in my windows pc, it was throwing an error that the port is being used by some other process. I had to find which is the program running in that port, and i finally found the following set's of commands are useful on finding the processes running in each port

Go to 
C:\Windows\System32 and run the following command to get 

To display both the Ethernet statistics and the statistics for all protocols, type the following command:
netstat -e -s
To display the statistics for only the TCP and UDP protocols, type the following command:
netstat -s -p tcp udp
To display active TCP connections and the process IDs every 5 seconds, type the following command:
nbtstat -o 5
To display active TCP connections and the process IDs using numerical form, type the following command:
nbtstat -n -o


Popular posts

Copyright © 2009 On the way All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive.