This translation is older than the original page and might be outdated.

Node in which the rules and actions for the elimination of collections will be described.

The format is the following one:

     <!-- Condición para que se efectue el borrado -->
     <rule atributos>...</rule>
     <!-- Acciones a efectuar si la condición anterior se cumple -->
     <action atributos>...</action>

Node where the delete validation rules are defined.

  • These rules are evaluated in the same order that they appear in the collection definition.
  • If any of these rules fails, the object cannot be deleted,and the DeleteObject method will return an error code that can be customized in this same definition.

  • value=“eof, neof o false” : In the first case, the rule will succeed if its associated SQL sentence doesn´t return any log. In case the SQL return some log, the rule will fail. In the second case, the rule behaviour is reversed. In the third case, the rule always fails. This kind of rules are defined for objects that cannot be never deleted, they can be consulted, but no deleted.
  • sql: This attribute provides the SQL sentence that will be executed to evaluate the rule. The rule behaviour (succeed or failure) is defined by the “value” attribute described before.
  • errormsg: This attribute defines the message that the DeleteObject method will return when is executed and this rule fails. This message may be shown by the app to inform to the user why this object cannot be deleted.

     <rule value="eof" sql="SELECT ID FROM ##PREF##DetDocumento WHERE IDARTICULO=##ID##" errormsg="Se han efectuado movimientos con este articulo."></rule>
     <!-- Comprueba que no exista ningún movimiento de este artículo, en caso de existir mostraría un mensaje de error y no nos permitiría continuar con el borrado -->

If all the rules have been favorable, the object can be deleted, so if the deleting actions are executed (those elements inside the delete definition which are of type “action”.

  • name=“value” : Name of the action to be made.
    • executesql: Executes the SQL sentence that defines in the “sql” attribute which follows in the declaration of the action. The data layer is responsible of replacing the following macros:
    • - ##PREF## Prefix of the application. It is defined at data application level.
      - ##ID## ID of the object which is being processed.
    • - ##FLD_nombrecampo## value of the field which name is “nombrecampo”, for instance, if the ##FLD_IDARTICULO## macro is placed in the SQL, the data layer is responsible for searching the value of the IDARTIVULO field and place its value at the SQL, including possible separators (for instance, in the case of strings, the data layer will generate the value in quotes necessary for the SQL sintax to be correct.
  • sql: This attribute has an SQL sentence, which macros will be evaluated from the data layer.

     <!-- Ejecuta un delete de la tabla stock en la que el IDARTICULO sea el ID del artículo que se está eliminando -->
     <action name="executesql" sql="DELETE FROM ##PREF##Stock WHERE IDARTICULO=##ID##"></action>