error on release sales order

Hi All,

i have a requirement of customizing the sales order, if the items in the order are not sufficient or available(if the remaining quantity is zero) then it should not allow us to release and post.

i have tried this

IF ((ItemLedgEntry.“Remaining Quantity” < 0)) THEN

ERROR(Text030,ItemLedgEntry.“Item No.”);

in CU 22 and working fine not allowing me to post, but now i need to get an error while releasing the order, please help me where to write the logic

thanks

You can write above code on Release button/menu by putting condition i,.e If above condition satisifies then it will execute the release codeunit.