It is easy to appreciate that this question is extremely complicated and heavily dependent on the individual case. However, there are some relatively simple things to consider which can help you decide what direction is probably best.
Analyse influencing factors
The first thing to do is to really analyse what primary influencing factors are. Price is an easy one and off-the-shelf application should always beat bespoke application on this one, but price is often NOT the major factor.
If the function of the software has anything to do with your USP, off-the-shelf software may now be dangerous territory. For example, you have grown a successful business using a process that has been developed over time that satisfies you and your customers’ requirements.
All set for growth?
If you are looking to implement a piece of software to enable you to scale up that process bespoke is probably the way to go. Off-the-shelf software often requires you to change your processes to the way the software works - this may destroy the very process that made you stand out from your competitors.
Off-the-shelf software can be quick and cheap to implement, but it can’t compete to the flexibility of bespoke software.