I ignore where do you have found your code, but in vanilla to cancel Shadowform buff you need to use lua code like:
for i=0,15,1 do
local currBuffTex = GetPlayerBuffTexture(i);
if (currBuffTex and string.find(string.lower(currBuffTex), "spell_shadow_shadowform")) then CancelPlayerBuff(i); end
end
(and not "CastSpellByName('Shadowform',1)")
In one line:
for i=0,15,1 do local currBuffTex = GetPlayerBuffTexture(i); if (currBuffTex and string.find(string.lower(currBuffTex), "spell_shadow_shadowform")) then CancelPlayerBuff(i); end end