I wrote a trigger on the SOP10106 table for update delete. It works perfectly.
Now the requirement is for insert also. I went in the modified the trigger to insert,update,delete and it keeps giving me errors in GP.
As soon I change it to update,delete, it works fine.
Am I missing something here?
*This post is locked for comments
The trigger is on the sop10106 table. Sop10106 table stores extra values for Sales order processing entry. The trigger writes data to a custom table when USRDEF04 field is modified. The code for the trigger is below:
USE
[MCN]GO
/****** Object: Trigger [dbo].[_cb_MFGHRS] Script Date: 09/16/2010 15:14:46 ******/
SET ANSI_NULLS ONGO
SET QUOTED_IDENTIFIER ONGO
ALTER
trigger [dbo].[_cb_MFGHRS] on [dbo].[SOP10106]for insert, update,delete asdeclare
@MFGHRSOld varchar(50)declare
@MFGHRSNew varchar(50)declare
@SOPNmbr varchar(50)declare @SOPTYPE intset
@mfghrsold = (select usrdef04 from deleted )set
@mfghrsnew = (select usrdef04 from inserted )set
@Sopnmbr = (select sopnumbe from deleted)set
@Soptype = (select soptype from deleted)
if
update(usrdef04)Begin
if @mfghrsold <> @mfghrsnew begininsert _cb_SOP10106_Audit values ( @SopNmbr, @Soptype, system_user, getdate(), @mfghrsold, @mfghrsnew, 'Update')endend
if
@mfghrsnew is nullbegin
insert _cb_SOP10106_Audit values ( @SopNmbr, @Soptype, system_user, getdate(), @mfghrsold, @mfghrsold, 'Delete')end
if
@mfghrsold is nullbegin
insert _cb_SOP10106_Audit values ( @SopNmbr, @Soptype, system_user, getdate(), @mfghrsold, @mfghrsold, 'New')end
Refresh my memory - what does the sop10106 store?
And what exactly is your trigger trying to accomplish is it on an external table and trying to modify sop10106 or is it on the sop10106 and trying to..............do what - external table or another GP table?
Posting the code for the trigger might also be helpful.......
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156