I need to update ORDER.CustomOrderName  only if there are certain items (belonging to 2 categories) in the order.

The template ORDER configured is ORD_{id}
The custom template should be PREORD_{id}

I  have create a TRIGGER  to Update ORDER.CustomOrderName  ON INSERT Order, BUT the UPDATE ORDER NOT WORK.
The INSERT INTO OrderNote insted works

What can be the reason?

I tried to insert this script in Order , OrderItem , OrderNote;
but the update NOT WORKS !
I tried to utilize also the OrderGuid, BUT the update NOT WORKS!


GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER TRIGGER [dbo].[order_insert_check_preorder]
ON [dbo].[Order]
FOR INSERT
AS
BEGIN
SET NOCOUNT ON;

DECLARE @categoryid int
DECLARE @orderid int
SELECT TOP 1 @orderid = id   FROM INSERTED;

--IF EXISTS (
--    SELECT pcm.CategoryId
--    FROM [dbo].[OrderItem] oi
--    Inner JOIN
--    Product_Category_Mapping pcm
--    ON oi.ProductId = pcm.ProductId
--    AND pcm.CategoryId in (32,33)
--    )

  BEGIN  
    UPDATE [order] SET CustomOrderNumber = 'PREORD_' + Cast(@orderid as varchar(10))  WHERE Id = @orderid ;
    INSERT INTO [dbo].[OrderNote]
         ([Note]
         ,[OrderId]
         ,[DownloadId]
         ,[DisplayToCustomer]
         ,[CreatedOnUtc])
     VALUES
         ('PREORD_'  + Cast(@orderid as varchar(10))
         ,@orderid
         ,0
         ,1
         ,getdate());
  END
END