First, create the following folder
📂BP
└📄manifest.json
└📚pack_icon.png
└📂functions
└📄target_acquired.mcfunction
Enter your command in target_acquired.mcfunction
example: summon ender_crystal
Then enable the addon you created and use the block with target_acquired.mcfunction.
And if you perform a certain action, you can execute the target_acquired.mcfunction.