Call stored procedure using a button on Customer Maintenance

SOLVED

We're looking to build a function to push newly entered customer data (for new account setups) out to an external database for one of our in-house programs (both Sage and external are on SQL 2016). What our developer is suggesting is using a stored procedure passing all the fields as parameters, we can then do validation, update vs. add new, etc. so we could have this integration happen live.

Before I give the ok on this I wanted to confirm that Sage allows for calling a stored procedure off of a custom button in the Customer Maintenance panel.

Parents Reply Children
  • FormerMember
    0 FormerMember in reply to Yung_Grasshopper

    Is this being done externally and not through customizer?

  • 0 in reply to FormerMember

    I'm fairly new to Sage (peep the username) and I'm not exactly sure what you mean by that. I was planning on putting a script set to the event of the "Accept" button in Customer Maintenance, that would then somehow trigger this SQLCMD utility, and call a stored procedure that would pull the data from our Sage db and pass the results in as parameters into our custom program's db. Connecting those steps together is where I'm getting stuck.

  • 0 in reply to Yung_Grasshopper

    Google can show you how to call a command line (%COMSPEC% ...?) from a VBScript. 

    The actual command you construct by referencing guidance from: "SQLCMD /?"  entered at a command prompt (after installing the program, free from Microsoft). 

    Example:

    sqlcmd -S SQLServer\Instance -d MAS_ABC -E -Q "exec spYourProcedureNameHere;" -o %TempLogFile%

    Be very careful with this when running such a thing for Advanced / Premium to ensure you understand where it  is running based on how it's triggered from Sage, and the security context used.  I have never used this technique directly from within Sage, so I can't provide insights for that.  A manually clicked button script would be much safer than trying to set up an event trigger.