SQL Function to Remove Alphanumeric Characters

Microsoft Dynamics GPI created a customisation recently for a client which would generate a Vendor ID based on the name, by removing alphanumeric characters. In order to make it as flexible as possible, I created the function to accept a parameter for type which will cause the function to strip different characters:

  • A – leaves alpha characters only.
  • N – leaves numeric characters only.
  • AN – leaves alphanumeric characters.

The second parameter is the string which should have the characters stripped:

IF OBJECT_ID (N'uv_AZRCRV_StripCharacters', N'FN') IS NOT NULL
	DROP FUNCTION uv_AZRCRV_StripCharacters
GO

CREATE FUNCTION uv_AZRCRV_StripCharacters(@Type VARCHAR(100), @String VARCHAR(MAX))
	RETURNS VARCHAR(MAX)
/*
Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (https://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
BEGIN
	DECLARE @PatIndex VARCHAR(20)
	IF (@Type = 'Alpha' OR @Type = 'A')
		SET @PatIndex = '%[^a-z]%'
	IF (@Type = 'Numeric' OR @Type = 'N')
		SET @PatIndex = '%[^0-9]%'
	IF (@Type = 'AlphaNumeric' OR @Type = 'AN')
		SET @PatIndex = '%[^a-z0-9]%'

	WHILE PATINDEX(@PatIndex, @String) < 0
		SET @String = STUFF(@String, PATINDEX(@PatIndex, @String), 1, '')

	RETURN @String
END

GRANT EXECUTE ON uv_AZRCRV_StripCharacters TO DYNGRP
GO

Using Pi-hole On A Raspberry Pi: Admin Interface

Raspberry PiThis post is part of the series on building my new Raspberry Pi; this series is a sub-series of the Adventures with a Raspberry Pi.

The Pi-hole admin interface is where you maintain your blocklists, whitelists and general settings. You can access it in two ways:

  1. http://{ip address of pi-hole}/
  2. http://pi.hole/

When the admin page interface, you will see basic information for the last 24 hours:

Pi-hole admin interface not logged in

Continue reading “Using Pi-hole On A Raspberry Pi: Admin Interface”

IIS Rewrite Rule for Redirect to Directory

Microsoft Dynamics GPThe web hosat I am currently with allows multiple domains, but only 6 websites; this means I have to be a little creative sometimes when creating additional sites.

I actually have a lot more than six websites being hosted on my account, due to a mix of WordPress MU and redirects to folders.

The redirect is done using an IIS rewrite rule. As I may be moving web host soon, I’m posting this so that I have easy access should I need.

This code goes in the rewrite section of the web.config file:

/*
Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (https://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
<rewrite>
	<rules>
		<rule name="Rewrite subdomain.azurecurve.co.uk subdomain to dir" enabled="true">
			<match url="^(.*)$" />
			<conditions>
				<add input="{HTTP_HOST}" pattern="^subdomain\.azurecurve\.co\.uk$" />
			</conditions>
			<action type="Rewrite" url="_subdomain.azurecurve.co.uk/{R:1}" />
		</rule>
		<rule name="subdomain.azurecurve* wordpress" patternSyntax="Wildcard">
			<match url="*subdomain.azurecurve*" />
			<conditions>
				<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
				<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
			</conditions>
			<action type="Rewrite" url="_subdomain.azurecurve.co.uk/index.php" />
		</rule>
</rewrite>

The second rule is, I believe, required specifically for redirects for WordPress sites, the majority of which my rewrites are for.

Using Pi-hole On A Raspberry Pi: Blocked Adverts

Raspberry PiThis post is part of the series on building my new Raspberry Pi; this series is a sub-series of the Adventures with a Raspberry Pi.

With Pi-hole installed and configured, the main way you will use your Pi-hole is to simply browse the Internet.

With the router directing all DNs queries to the Pi-hole, it will use the loaded block lists to stop adverts from those domains being loaded. I’ve found the experience of surfing the Internet far smooth since I installed the Pi-hole. The amount of data has also noticeably dropped.

I have been white-listing some sites which do not have overly intrusively adverts (no sound, no video or moving images). I’ll cover white-listing later in this series.

Adventures With A Raspberry Pi

Adventures With A Raspberry Pi
Building The Raspberry Pi: CanaKit Raspberry Pi 3 B+ Complete Starter Kit
Building The Raspberry Pi: Raspberry Pi Build
Building The Raspberry Pi: Install Operating System
Building The Raspberry Pi: First Run
Building The Raspberry Pi: System Configuration Tool
Building The Raspberry Pi: Enable SSH For Remote Access
Building The Raspberry Pi: Securing the Raspberry Pi
Building The Raspberry Pi: Conclusion
Installing Pi-hole On A Raspberry Pi: What is Pi-hole?
Installing Pi-hole On A Raspberry Pi: Install Pi-hole
Installing Pi-hole On A Raspberry Pi: Change Pi-hole Admin Password
Installing Pi-hole On A Raspberry Pi: Configure Network to use Pi-hole
Using Pi-hole On A Raspberry Pi: Blocked Adverts
Using Pi-hole On A Raspberry Pi: Admin Interface
Using Pi-hole On A Raspberry Pi: Disabling Pi-hole
Using Pi-hole On A Raspberry Pi: Whitelisting a Site
Using Pi-hole On A Raspberry Pi: Update Blocklists
Using Pi-hole On A Raspberry Pi: Maintain Blocklists
Using Pi-hole On A Raspberry Pi: Change DNS Servers
Using Pi-hole On A Raspberry Pi: Connecting With SSH
Using Pi-hole On A Raspberry Pi: Updating the Pi-hole
Using Pi-hole On A Raspberry Pi: Conclusion
What Else Can I Use It For?
Prepare New SD Card For Raspberry Pi OS: Download SD Card Formatter
Prepare New SD Card For Raspberry Pi OS: Install SD Card Formatter
Prepare New SD Card For Raspberry Pi OS: Format SD Card
Prepare New SD Card For Raspberry Pi OS: Download NOOBS
Prepare New SD Card For Raspberry Pi OS: Copy Files To The SD Card
Prepare New SD Card For Raspberry Pi OS: Conclusion
Installing Pi-hole On A Raspberry Pi: Changing the IP Address
Raspberry PI Update Fails
Check Version of OS on Raspberry Pi
How to Update the OS on a Raspberry Pi

Disable AutoSave OneDrive and SharePoint Online Files by Default on Excel

OneDriveI recently got a new laptop at work which meant getting all applications installed. Previously I’d had Microsoft Office 2016 installed; on the new laptop I got Microsoft Office 365 which came with AutoSave enabled by default in all of the applications, such as Excel and Word, for files opened from SharePoint Online:

Microsoft Excel autosave on

Continue reading “Disable AutoSave OneDrive and SharePoint Online Files by Default on Excel”

Using Pi-hole On A Raspberry Pi: Series Index

Raspberry PiThis series is a sub-series of the Adventures with a Raspberry Pi, in which I am going to show how to use the Pi-hole.

If you’re reading this post on azurecurve, this index will automatically update, otherwise you need to check back to the original post.

Adventures With A Raspberry Pi

Adventures With A Raspberry Pi
Building The Raspberry Pi: CanaKit Raspberry Pi 3 B+ Complete Starter Kit
Building The Raspberry Pi: Raspberry Pi Build
Building The Raspberry Pi: Install Operating System
Building The Raspberry Pi: First Run
Building The Raspberry Pi: System Configuration Tool
Building The Raspberry Pi: Enable SSH For Remote Access
Building The Raspberry Pi: Securing the Raspberry Pi
Building The Raspberry Pi: Conclusion
Installing Pi-hole On A Raspberry Pi: What is Pi-hole?
Installing Pi-hole On A Raspberry Pi: Install Pi-hole
Installing Pi-hole On A Raspberry Pi: Change Pi-hole Admin Password
Installing Pi-hole On A Raspberry Pi: Configure Network to use Pi-hole
Using Pi-hole On A Raspberry Pi: Blocked Adverts
Using Pi-hole On A Raspberry Pi: Admin Interface
Using Pi-hole On A Raspberry Pi: Disabling Pi-hole
Using Pi-hole On A Raspberry Pi: Whitelisting a Site
Using Pi-hole On A Raspberry Pi: Update Blocklists
Using Pi-hole On A Raspberry Pi: Maintain Blocklists
Using Pi-hole On A Raspberry Pi: Change DNS Servers
Using Pi-hole On A Raspberry Pi: Connecting With SSH
Using Pi-hole On A Raspberry Pi: Updating the Pi-hole
Using Pi-hole On A Raspberry Pi: Conclusion
What Else Can I Use It For?
Prepare New SD Card For Raspberry Pi OS: Download SD Card Formatter
Prepare New SD Card For Raspberry Pi OS: Install SD Card Formatter
Prepare New SD Card For Raspberry Pi OS: Format SD Card
Prepare New SD Card For Raspberry Pi OS: Download NOOBS
Prepare New SD Card For Raspberry Pi OS: Copy Files To The SD Card
Prepare New SD Card For Raspberry Pi OS: Conclusion
Installing Pi-hole On A Raspberry Pi: Changing the IP Address
Raspberry PI Update Fails
Check Version of OS on Raspberry Pi
How to Update the OS on a Raspberry Pi
Using Pi-hole On A Raspberry Pi
Disabling Pi-hole
Whitelisting a Site
Update Blocklists
Maintain Blocklists
Change DNS Servers
Connecting With SSH
Updating the Pi-hole
Conclusion
Adventures With A Raspberry Pi: Raspberry PI Update Fails

This Workflow Is Locked By Another User And Cannot Be Edited

Microsoft Dynamics GPI was onsite recently with a client making a Workflow project live and encountered a lock on the workflow we needed to amend. There were no users logged into the company so we knew the lock was an orphaned one.

This workflow is locked by another user and cannot be edited. Please try again later.

"This workflow is locked by another user and cannot be edited. Please try again later."

The locks on Workflow are stored in the Workflow User Security (WF00104) table; when clearing locks, care should be taken to only remove the lock required, so as not to cause additional problems.

The highlighted section should be changed to the Workflow Type for which the lock should be removed:

/*
Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (https://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
DELETE FROM
	WF00104
WHERE
	Workflow_Type_Name = 'Purchase Requisition Approval'
GO

Installing Pi-hole On A Raspberry Pi: Configure Network to use Pi-hole

Raspberry PiThis post is part of the series on building my new Raspberry Pi; this series is a sub-series of the Adventures with a Raspberry Pi.

With Pi-hole installed and configured, the final step is to change the DNS settings on the router to point to the Pi-hole rather than the old DNS servers. In my case, they were pointing to OpenDNS on the router, so it as a case of changing them to look to the IP address configured on the Pi-hole which is set to use OpenDNS.

Every router is different in how DNS servers are configured; if your router doesn’t allow the DNS servers to be changed, you could change the DNS settings on your computers instead; bear in mind this approach takes far more effort.

Adventures With A Raspberry Pi

Adventures With A Raspberry Pi
Building The Raspberry Pi: CanaKit Raspberry Pi 3 B+ Complete Starter Kit
Building The Raspberry Pi: Raspberry Pi Build
Building The Raspberry Pi: Install Operating System
Building The Raspberry Pi: First Run
Building The Raspberry Pi: System Configuration Tool
Building The Raspberry Pi: Enable SSH For Remote Access
Building The Raspberry Pi: Securing the Raspberry Pi
Building The Raspberry Pi: Conclusion
Installing Pi-hole On A Raspberry Pi: What is Pi-hole?
Installing Pi-hole On A Raspberry Pi: Install Pi-hole
Installing Pi-hole On A Raspberry Pi: Change Pi-hole Admin Password
Installing Pi-hole On A Raspberry Pi: Configure Network to use Pi-hole
Using Pi-hole On A Raspberry Pi: Blocked Adverts
Using Pi-hole On A Raspberry Pi: Admin Interface
Using Pi-hole On A Raspberry Pi: Disabling Pi-hole
Using Pi-hole On A Raspberry Pi: Whitelisting a Site
Using Pi-hole On A Raspberry Pi: Update Blocklists
Using Pi-hole On A Raspberry Pi: Maintain Blocklists
Using Pi-hole On A Raspberry Pi: Change DNS Servers
Using Pi-hole On A Raspberry Pi: Connecting With SSH
Using Pi-hole On A Raspberry Pi: Updating the Pi-hole
Using Pi-hole On A Raspberry Pi: Conclusion
What Else Can I Use It For?
Prepare New SD Card For Raspberry Pi OS: Download SD Card Formatter
Prepare New SD Card For Raspberry Pi OS: Install SD Card Formatter
Prepare New SD Card For Raspberry Pi OS: Format SD Card
Prepare New SD Card For Raspberry Pi OS: Download NOOBS
Prepare New SD Card For Raspberry Pi OS: Copy Files To The SD Card
Prepare New SD Card For Raspberry Pi OS: Conclusion
Installing Pi-hole On A Raspberry Pi: Changing the IP Address
Raspberry PI Update Fails
Check Version of OS on Raspberry Pi
How to Update the OS on a Raspberry Pi

SQL Script to Delete Unused Segments

Microsoft Dynamics GPWhile the General Ledger Year-End Close routine can delete unused segments, during implementation, or creation of new companies , we sometimes end up with segments created which are not needed. The below script can be used to remove all segments not assigned to an account (segments which have been used will not be removed).

The script allows the user to define which segment should be removed by changing the highlighted parameter:

/*
Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (https://www.azurecurve.co.uk)
This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int).
*/
DECLARE @SGMTNUMB AS VARCHAR(2) = 3

DELETE FROM
	GL40200
WHERE
	SGMTNUMB = @SGMTNUMB
AND
	SGMNTID NOT IN (
			SELECT
				CASE @SGMTNUMB 
				WHEN 1 THEN GL100.ACTNUMBR_1
				WHEN 2 THEN GL100.ACTNUMBR_2
				WHEN 3 THEN GL100.ACTNUMBR_3
				WHEN 4 THEN GL100.ACTNUMBR_4
				WHEN 5 THEN GL100.ACTNUMBR_5
				WHEN 6 THEN GL100.ACTNUMBR_6
				WHEN 7 THEN GL100.ACTNUMBR_7
				WHEN 8 THEN GL100.ACTNUMBR_8
				WHEN 9 THEN GL100.ACTNUMBR_9
				WHEN 10 THEN GL100.ACTNUMBR_10
				END
			FROM
				GL00105 AS GL105
			INNER JOIN
				GL00100 AS GL100
					ON
						GL100.ACTINDX = GL105.ACTINDX
			)
GO

Installing Pi-hole On A Raspberry Pi: Change Pi-hole Admin Password

Raspberry PiThis post is part of the series on building my new Raspberry Pi; this series is a sub-series of the Adventures with a Raspberry Pi.

In the last post, I stepped through the installation of the Pi-hole software on a Raspberry Pi. It will install with a admin password provided which you can change (and I would recommend you do so).

You can change the password by logging into your Raspberry Pi and typing the following command (where the highlighted section is replaced with your password of choice):

sudo pihole -a -p password

There are two issues with this.

The first is, as you’re typing this command, anyone looking over your shoulder will see the new password.

The other issue, is if you use special characters in your password, you will need to escape them. For example, a password of P!hole would need to be entered as P\!hole.

Adventures With A Raspberry Pi

Adventures With A Raspberry Pi
Building The Raspberry Pi: CanaKit Raspberry Pi 3 B+ Complete Starter Kit
Building The Raspberry Pi: Raspberry Pi Build
Building The Raspberry Pi: Install Operating System
Building The Raspberry Pi: First Run
Building The Raspberry Pi: System Configuration Tool
Building The Raspberry Pi: Enable SSH For Remote Access
Building The Raspberry Pi: Securing the Raspberry Pi
Building The Raspberry Pi: Conclusion
Installing Pi-hole On A Raspberry Pi: What is Pi-hole?
Installing Pi-hole On A Raspberry Pi: Install Pi-hole
Installing Pi-hole On A Raspberry Pi: Change Pi-hole Admin Password
Installing Pi-hole On A Raspberry Pi: Configure Network to use Pi-hole
Using Pi-hole On A Raspberry Pi: Blocked Adverts
Using Pi-hole On A Raspberry Pi: Admin Interface
Using Pi-hole On A Raspberry Pi: Disabling Pi-hole
Using Pi-hole On A Raspberry Pi: Whitelisting a Site
Using Pi-hole On A Raspberry Pi: Update Blocklists
Using Pi-hole On A Raspberry Pi: Maintain Blocklists
Using Pi-hole On A Raspberry Pi: Change DNS Servers
Using Pi-hole On A Raspberry Pi: Connecting With SSH
Using Pi-hole On A Raspberry Pi: Updating the Pi-hole
Using Pi-hole On A Raspberry Pi: Conclusion
What Else Can I Use It For?
Prepare New SD Card For Raspberry Pi OS: Download SD Card Formatter
Prepare New SD Card For Raspberry Pi OS: Install SD Card Formatter
Prepare New SD Card For Raspberry Pi OS: Format SD Card
Prepare New SD Card For Raspberry Pi OS: Download NOOBS
Prepare New SD Card For Raspberry Pi OS: Copy Files To The SD Card
Prepare New SD Card For Raspberry Pi OS: Conclusion
Installing Pi-hole On A Raspberry Pi: Changing the IP Address
Raspberry PI Update Fails
Check Version of OS on Raspberry Pi
How to Update the OS on a Raspberry Pi