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



Business Rules


Explanation of the different “events” available in XOne Platform to define the business rules.


Execution of XOneScript code inside of our application. In this case, it has no attribute, but it has a node where we will put the script to be executed, as shown in the example below.

	<!-- Cogemos el valor del campo MAP_SERIE y concatenamos con "/" y el campo NUMERO y lo ponemos en NUMCOMPLETO -->
	<action name="runscript">
		<script language="VBScript">
			This("NUMCOMPLETO")=This("MAP_SERIE") + "/" + CStr(This("NUMERO"))
		</script>
	</action>
 
	<!-- Podemos llamar a un fichero de scripts cuando lo necesitemos, la funcion EntrarN estara definida en funciones.vbs -->
	<action name="runscript">
		<include file="funciones.vbs" />
		<script language="VBScript">
			EntrarN
		</script>
	</action>



To take a value from a field in the father collection and put it in a field of the daughter collection. Used in the contents.

	<!-- Cogemos el valor del ID de la colección padre y lo ponemos en el campo IDCLIENTE de la colección Contents -->
		<action name="setfldval" targetfld="IDCLIENTE" sourcefld="ID"/>


Attribute Description
name Name of the action to execute
targetfld Field to be updated with the father field.
sourcefld Field of the father collection that will give value to the field of this collection.


We look for a value in another collection and we take back the value from any field.

	<!-- Buscamos en la colección Usuarios el registro cuyo ID sea el el usuario logueado actualmente 
	     y cogemos el valor del campo IDSERIE para ponerlo en el campo IDSERIE de la colección actual, es decir: 
	     IDSERIE = "SELECT IDSERIE FROM gen_usuarios WHERE ID=##USERID##". -->
	<action name="mapval" field="IDSERIE" targetfld="IDSERIE" coll="Usuarios" mapfld="ID" mapvalue="##USERID##" />
 
	<!-- Buscamos en la colección TiposUsuario el registro cuyo CODIGO = 4 
	     y cogemos el valor del campo ID para ponerlo en el campo IDTIPO de la colección actual, es decir: 
	     IDTIPO = "SELECT ID FROM gen_tiposusuario WHERE CODIGO=4"  -->
	<action name="mapval" field="IDTIPO" targetfld="ID" coll="TiposUsuario" mapfld="CODIGO" mapvalue="4" />
 
	<!-- Buscamos en la colección Usuarios el registro cuyo ID sea el el usuario logueado actualmente 
	     y cogemos el valor del campo LOGIN para ponerlo en el campo CODTECNICO de la colección actual, es decir: 
	     CODTECNICO = "SELECT LOGIN FROM gen_usuarios WHERE ID=##USERID##". -->
	     <action name="mapval" field="CODTECNICO" targetfld="LOGIN" coll="Usuarios" mapfld="ID" mapvalue="##USERID##">


Attribute Description
name Name of the action to execute
field Field to be updated
targetfld Field name that has the value assigned to the field field.
coll Collection where the searching of the field which have the required value will be made.
mapfld Field of the collection that is defined in the coll attribute, that is the first key of it.
mapvalue Value of the field of the first key to rescue the log searched.


To execute an SQL, Insert, Update oR Delete sentence. It has no sense to execute a Select, because the action does´t return any value.

Widely used in header collections, when you are deleting a record, delete all of its associated lines.

	<!-- Se pueden utilizar MACROS -->
	<action name="executesql" sql="DELETE FROM ##PREF##DetParte WHERE IDPARTE=##ID##"></action>


Attribute Description
name Name of the action to execute.
sql SQL sentence to be executed. Valid only the execution of Insert, Update orDelete.


To update a link field of a details collection with the ID of the heading.

Used EXCLUSIVELY in the INSERT node of a header collection. To link the detail lines of the CONTENTS collection when registering at the same time the header and the details, because until the header is not saved, the detail lines do not know what the ID of their father is.

<action name="link" coll="Detalles" field="IDDOCUMENTO" value="##ID##"></action>


Attribute Description
name Name of the action to execute
coll Collection searched to update the link field with this Father collection.
field Field name of the collection with the name defined in the coll attribute and that is the link with this Father collection.
value Value assigned to the link field between the Father collection and the daughter collection.

BEFOREACTION NODE


Node to expose the actions to be made in the events defined in our application, being able to be executed each and every one of the types of actions available to the nodo action.
Nevertheless, as a very important point to take in mind, is that this action only is valid for the event Insert event and it is used for validating fields, so that in case of error, the object is not saved, and the user is forced to insert a value for the validated field.