Skip to Content

How to run a custom c# script / action when a User Field value is updated?

I am looking for a way to automatically run some code when a user field is updated. Basically, I want to insert current Order details into another database and send an email/sms when a user field called U_Approved is changed from 0 to 1. Any idea how to make that in dotNet c# without the use of SQL listeners?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Nov 01, 2017 at 12:51 PM

    Hi Waseem,

    I recommend a console application, that you run in a scheduled task on the server. You could use the following steps:

    1. In the other database, create a table with the field DocNum, and a time stamp
    2. With a simple query get the approved orders' DocNums, that are not already in the table on the other database, and insert them into the table.
    3. Check the orders that were already in the table, against B1 to see if the approval was revoked.
    4. Copy newly approved orders' data from B1 to the other database, and update the time stamp in the DocNum table (see step two).
    5. Remove orders' data for which the approval was revoked (see step three).

    If the other database is not a SAP Business One database, you do not even need the DI API.

    Regards,

    Johan

    Add comment
    10|10000 characters needed characters exceeded

    • Good observation. It may have something to do with the fact that B1 is very much a database driven application.

      When you add a document, the client really only runs one or more stored procedures. Also SAP generally advises against adding triggers to the database.

      Implementing an event listener on one machine to listen to events on possibly another machine, and then on a third party database software, may be a challenge.