How can i compile the table through coding in navision 2013 r2
You have to run finsql.exe with some parameters to do that:
In previous versions this can be done using SHELL command, but this command is obsolete in RTC client... you can create a DotNet variable (runonclient=true), System.Diagnostics.Process, this DotNet can run a command line. In Saurav Blog, you have an example on how to use it:
Can you execute the command directly in windows command prompt (CMD), and observe if some error is displayed?
In Command prompt How ??
Please, remove the first double quote, the one previous finsql.exe, and run command again.
No Error is showing.
If no error is showing, then seems that table has been compiled... can you check if table has been compiled? I have to say that if the table has never been compiled, I don't know why, but the table not compile that way.
FinSQLPath := '"C:\Program Files (x86)\Microsoft Dynamics NAV\71\RoleTailored Client\finsql.exe"';ServerName := '"newserver.newdomain.com:5097/test_live_150218"';DatabaseName := 'TEST_LIVE_150218';Filter := '"Type=Table;ID=5406"';
Command := FinSQLPath + ' command=compileobjects,servername=' + ServerName + ',database=' + DatabaseName + ',filter=' + Filter;
ExecuteBat := ExecuteBat.ProcessStartInfo('cmd', '/c "' + Command + '"'); //Provide Details of the Process that need to be Executed.ExecuteBat.RedirectStandardError := TRUE; // In Case of Error the Error Should be Redirected.ExecuteBat.RedirectStandardOutput := TRUE; // In Case of Sucess the Error Should be Redirected.ExecuteBat.UseShellExecute := FALSE;ExecuteBat.CreateNoWindow := TRUE; // In case we want to see the window set it to False.Process := Process.Process; // ConstructorProcess.StartInfo(ExecuteBat);Process.Start;ErrorMsg := Process.StandardError.ReadToEnd(); // Check Error Exist or NotIF ErrorMsg <> '' THEN ERROR('%1',ErrorMsg)ELSE BEGIN Result := Process.StandardOutput.ReadToEnd();// Display the Query in the Batch File. MESSAGE('%1',Result);END;
Look if have written something wrong.
Servername is wrong... it must be database server name, in this case "NEWSERVER". Additionally, you can remove the result message, it never will show anything.
I have tried by changing the database name but no error occurs.