There are two parts to it.

1. Create a trigger after INSERT/UPDATE/DELETE. Triggers can work for both sql and object access:

Trigger NewTrigger1 [ Event = INSERT/UPDATE/DELETE, Foreach = row/object, Language = objectscript, Time = AFTER ]
{
    set ^dbg={fieldname*N}
}

2. In the trigger code send an SMS. You can either use an API (a lot of them available) or talk to a GSM modem.

First you need to create corresponding classed. You can do that by either importing the XSD or manually.

Here's a manual approach:

Class test.mensajeWS Extends (%RegisteredObject, %XML.Adaptor) {

Parameter NAMESPACE = "https://wslexnet.webservices.lexnet/3.22";

Property respuestaEnvioMensaje As respuestaEnvioMensaje;
}


Class test.respuestaEnvioMensaje Extends (%RegisteredObject, %XML.Adaptor) {

Property idEnvio As %Integer;

Property tamBloque As %Integer;

Property bytesMIME As %VarString;
}

After that in your BS convert incoming XML string like this:

set reader = ##class(%XML.Reader).%New()
set sc = reader.OpenString(pRequest.EnviarIniciadoresGeneralOut)
quit:$$$ISERR(sc) sc

do reader.Correlate("mensajeWS","test.mensajeWS")

do reader.Next(.mensajeWSObj,.sc)
quit:$$$ISERR(sc) sc

// Process mensajeWSObj

Great article.

Some comments on formatting:

  1. Move large code blocks under spoiler to improve readability using button.
  2. There are a lot of empty lines in code blocks, they can be safely removed.

On the article itself my only issue is you create 5 methods per class:

  • GET /class
  • POST /class
  • GET /class/object
  • PUT /class/object
  • DELETE /class/object

That's a lot of code even for 4 classes, but what about a case where there are 10 classes? 50? 100? Generally I would recommend writing 5 methods which would process objects of any allowed class (see RESTForms2).

For the case where only a new OnResponse method is added the workaround is executing these update queries:

UPDATE process.Context__ResponseHandlers
SET  "_ResponseHandlers" = 'OnResponseXYZ'
WHERE "_ResponseHandlers" = 'OnResponseABC'

Where ABC is an old method name, XYZ is a new method name.

In a case of several new methods they should be executed from the largest number first.

Datatype classes are used to define object properties, they allow to:

  • Validate values both generic (for example any defined %Integer property by default checks that it's value is an integer) and based on datatype parameters (for example you can have an %Integer(MINVAL=0, MAXVAL=9) property which in addition to checking that it's value is an integer would check that integer value is between 0 and 9)
  • Provide different representations based on context, specifically:
    • Logical (what's stored in globals)
    • Display (what's shown in object)
    • XSD (for XML export/import)
    • ODBC (returned in SQL)
  • Provide generators for utility methods. Article on some examples.

Docs.

Here's an example:

Class User.Assert Extends Ens.BusinessProcess [ ClassType = persistent, Language = objectscript ]
{

Method OnRequest(pRequest As Ens.Request, Output pResponse As Ens.Response) As %Status
{
    Set pResponse = ##class(Ens.Response).%New()
    
    $$$LOGINFO("$$$ASSERT(1)")
    $$$ASSERT(1) // skipped
    
    $$$LOGINFO("$$$LOGASSERT(1)")
    $$$LOGASSERT(1)
    
    $$$LOGINFO("$$$ASSERT(0)")
    $$$ASSERT(0)
    
    $$$LOGINFO("$$$LOGASSERT(0)")
    $$$LOGASSERT(0)

    Quit $$$OK
}
}