Posts

Changing Schema in AL Development

Image
In software development, it is rare that you get it right the first time.  The rules for AL extensions are very unforgiving and if you accidentally create a field with the wrong type, you can find yourself unable to change it.  Fortunately there is a way to handle this.  By inserting a schema SchemaUpdateMode value into your launch.json you can control exactly how deploying your development app handles the data. There are three values: ForceSync: This pushes schema changes through, deleting any incompatible data. Recreate: Completely deletes your tables and data and creates them from scratch.  This is useful if you have a setup routine that creates data. Synchronize: This is the default update mode.  It allows the least flexibility but should not be used unless you know what your changing and don't have prior versions deployed already.  If you choose to use ForceSync or Recreate modes, change the SchemaUpdateMode back to synchronize once you are done...

Troubleshooting SQL Locks

Image
SQL Locking is one of the most frustrating and misunderstood issues you will encounter when dealing with SQL Server.  One good tool for getting a handle on this is SQL Profiler.  There is a blocked process event that it can monitor but it must first be enabled.  To enable SQL blocked process monitoring, use the sp_reconfigure command: sp_configure   'show advanced options ' ,  1    RECONFIGURE GO sp_configure   'blocked process threshold' ,  10 GO RECONFIGURE GO The blocked process threshold needs to be set because blocking happens quite frequently and it's up to you to determine when it becomes a problem.  This is typically going to be right around the time the application times out and the user gets an error message.  Once this is enabled, you can use the SQL Profiler tool to collect locking events. I will typically take out the SQL statement and procedure events, since these tend to bloat the file and generate a l...

Chrome, CORS and .NET CORE

Image
Most of this information came from  https://stackoverflow.com/questions/53479946/how-to-handle-option-header-in-dot-net-core-web-api Getting a cross-origin resource working with Javascript and .NET core should be a simple task but if you're hosting it on IIS, there's an extra step. Instructions for setting up CORS in .NET CORE are all over the place so I'm just going to post an image of what it should look like. The real trick is with IIS.  You need to add a Request Filter to allow the OPTIONS verb. 

Changing Passwords in Powershell

Image
Our current network policy requires a password change ever three months.  Unfortunately, my Docker containers aren't connected to the domain so they don't recognize the change.  That means, if I still want to use Windows authentication when connecting to their services, I have to update the containers.  It's simple but I don't do it enough to keep it in my brain so I'm putting it here. It's just a matter of capturing your password as a secure string and using the Set-LocalUser command to set it.

Business Central Report Extensions with No Output

I did a Dynamics Business Central report with an RDLC layout using the txt2nav tool and I have a couple of notes. First, the txt2nav tool uses delta files to generate it's output but if you don't want to compare anything, just export the objects as described in the documentation and rename them to .delta files. Second and most importantly, if you're doing extensions with RDLC files, VS Code will want the layouts in the root folder of your project.  If they're not there, it will create them for you and leave you with reports that have no output.  If this happens to you, you will notice that the copied file is much smaller than the original.  The solution is to either copy or move your RDLC layout to the root folder so that VS Code doesn't try to do it for you.

Log Shipping Across FTP

Image
I had a situation where I needed to create a replica database for reporting using log shipping with two servers that aren't on the same network.  There is an excellent article describing the process on Niall Best's blog .  The instructions got me the setup that I needed on my remote SQL server but when I went to run the restore process, nothing happened. Running the sqllogship.exe command from a command prompt gave me a "Could not find a log backup file that could be applied to secondary database" message in the results.  After confirming that my path settings were correct in the log_shipping_secondary table, I ran the sqllogship command with Process Monitor going.  Process Monitor showed that sqllogship was looking for files named "MyDatabase_*.trn".  Because my primary and secondary database names are the same, I'm not sure if the MyDatabase value is the primary or the secondary.  I would start with the primary and if that doesn't work, try the s...

Filtering Lookups

Image
A coworker sent me an email today asking about a SQL query for returning results based on the value in a setup table.  I sent him the correct syntax and then inquired as to the purpose of this.  His response was that he had a request from a customer to filter the item lookup on the sales line table based on a setting in Sales & Receivables Setup.  He was going to use a table linked to a view, which among other things would be rather messy.  I then proceeded to show him the following method for creating a filtered lookup. It is a little known fact that code in the OnOpenPage trigger of a lookup page is executed when the lookup dropdown is displayed. Here is a lookup to the item table in a Cronus database. Now, let's say we want to filter to just items beginning with "11".  We could add this code to the OnOpenPage trigger of the Item List. Now the lookup returns this. Now, what if we want to make it conditional?  In this case, the fi...