Run Stored Procedure after Synchronisation

This is an example of how to use Project Automation to run a Stored Procedure against your SQL Database after a Synchronisation

This is an example of how to use Project Automation to run a Stored Procedure against your SQL Database after a Synchronisation, only when the data was changed.

Setup your Project with a SQL Server connection as the Target then enable Project Automation and use the Helper function ExecuteNonQuery on the Data source Object to execute your procedure. Using the Helper function uses the connection details on the Data Source to connect to the database.

This code runs at the end of the synchronisation and ensures that we had changes to apply and that the result was successful, then we call a Stored Procedure named ProductPriceReCalculate passing in a Parameter called Ratio a Value of 1. Passing parameters is optional you can simply just call the procedure.

public override void End(ProjectAutomationResult result)
    {
        if(result.HasChanges && result.Success)
        {
            DataSourceB.ExecuteNonQuery("EXEC dbo.ProductPriceReCalculate @Ratio=?", 1);                
        }
    }

Project Automation


Can't find the answers you're looking for? Contact our support team and we'll personally get back to you as quickly as we can.