Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Cross Dictionary - Database Trigger

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

I am trying to delete the record from my custom table once the record got deleted from FA00905 (FA_GL_Interface_WORK) table for a particular Batch No.

Code,

Startup:

result = Trigger_RegisterDatabaseByName(309, "FA_GL_Interface_WORK", "", TRIGGER_ON_DB_DELETE, script TSS_DBDELETE);
if result <> SY_NOERR then
 warning "Database trigger registration failed.";
 warning str(result);
end if;

TSS_DBDELETE:

inout anonymous table 'TS_Table';
warning "delete trigger.";

release table TSS_OBS_DistUserCntrl;
'Batch Number' of table TSS_OBS_DistUserCntrl = column("GL Interface Batch Number") of table 'TS_Table';
change table TSS_OBS_DistUserCntrl by number 1;
if err() = OKAY then
 remove table TSS_OBS_DistUserCntrl;
end if;

The Trigger is registered successfully. It Looks like the script is not getting fired. I didn't get that warning message. 

Can anyone help me on this?

Thanks,

Islam

 

*This post is locked for comments

  • soma Profile Picture
    soma 24,408 on at
    RE: Cross Dictionary - Database Trigger

    Yes. Almas suggested a another way to delete the record from third party table.

    But i am wondering why the database delete operation trigger for 3rd party table is not working.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Cross Dictionary - Database Trigger

    Thank you so much for the reply:-)

  • Almas Mahfooz Profile Picture
    Almas Mahfooz 11,004 User Group Leader on at
    RE: Cross Dictionary - Database Trigger

    I don't know why code is showing 5. (before execute and result) in my pasted script, so just remove it when copying to dictionary. :)

  • Verified answer
    Almas Mahfooz Profile Picture
    Almas Mahfooz 11,004 User Group Leader on at
    RE: Cross Dictionary - Database Trigger

    Your trigger get registered, but script not firing because event don't get triggered. getting quick profile of Delete button functionality don't show me any operation on table FA_GL_Interface_WORK.

    So if database trigger is not working for any reason why don't you try some other trigger? Like some focus trigger on Delete button, to get batch number in global value and then on some delete procedure call your script to delete the record from your table.

    I am pasting code here for your quick understanding, but you can make it a GOOD code by fine tuning it. :)

    STARTUP
    
    local integer result;
    result = Trigger_RegisterFocusByName(309,"'Delete Button' of window FA_GL_Posting of form FA_GL_Posting",TRIGGER_FOCUS_CHANGE,1, script delete_button_pre);
    result = Trigger_RegisterProcedureByName(309,"Remove_Reference_to_Deleted_Batch_Number of form FA_GL_Posting",TRIGGER_AFTER_ORIGINAL, script delete_script);
    


    DELETE BUTTON PRE

    local string b,c1,c2,ret_val,anymessage;
    
    c1="inout anonymous ret_val.";
    c2="ret_val='GL Interface Batch Number' of window FA_GL_Posting of form FA_GL_Posting.";
    execute (309,c1+c2, anymessage, ret_val);
    warning "batch no on window "+str(ret_val);
    faglbatch of globals=ret_val;


    SCRIP CALLED WHEN DELETE OPERATION OCCURED

    warning faglbatch of globals;

     

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Cross Dictionary - Database Trigger

    Cool. Yeah its got deleted from the table FA_GL_Interface_WORK(FA00905) when i delete the record from Tools - Routines - Fixed Asset - GL Posting.

    Thanks,

    Islam

  • soma Profile Picture
    soma 24,408 on at
    RE: Cross Dictionary - Database Trigger

    Have you checked whether the data is properly deleted from the table FA_GL_Interface_WORK?

  • soma Profile Picture
    soma 24,408 on at
    RE: Cross Dictionary - Database Trigger

    Sorry I misunderstanding the table reference between ID and count.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Cross Dictionary - Database Trigger

    The 54 is table count in FA module. The Product ID of the FA is 309. Please refer the Dynamics.SET file or below link.

    dynamicsgp.wordpress.com/.../dynamics-set-list-of-dynamics-gp-products

    Thanks,

    Islam

  • Suggested answer
    soma Profile Picture
    soma 24,408 on at
    RE: Cross Dictionary - Database Trigger

    I hope you have wrote the code for one of the Fixed Asset table. If so, please use the product code as 54 for Fixed Asset module.

    Note: For your reference, please have a look on the below link for product and module references.

    dyndeveloper.com/DynModule.aspx

    Hope this helps!!!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Cross Dictionary - Database Trigger

    Tried out. No luck.

    Thanks,

    Isalm

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans