FIELD MAPPED TO ANOTHER COLLECTION


Property of MAPPED-type

    <prop name="MAP_SOCIO" visible="1" group="1" type="T" title="SOCIO" linkedto="IDSOCIO" linkedfield="NOMBRE"/>
 
 


Property of type IDLINK to another collection.

    <prop name="IDSOCIO" visible="0" group="1" type="N" mapcol="Socios" mapfld="ID"/>


	<prop name="IDCLIENTE" group="1" type="N" visible="0" mapcol="Clientes" mapfld="ID"/>
	<!-- 
		Este campo es el que realmente SE GRABARÁ en la BD, normalmente no está visible.
		Enlaza con la colección "Clientes" y nos guardaremos el valor del campo "ID" seleccionado.
	-->
 
	<prop name="MAP_CLIENTE" ... linkedto="IDCLIENTE" linkedfield="NOMBRE" onchange="Refresh" value="##ID##">Cliente</prop>
	<prop name="MAP_CONTACTO" ... linkedto="IDCLIENTE" linkedfield="CONTACTO" locked="true" onchange="Refresh">Contacto</prop>
	<!-- 
		Estos campos están asociados con el campo "IDCLIENTE". Al llevar el prefijo "MAP_" NO se graban en BD.
		Para obtener sus valores utilizan el campo "IDCLIENTE" (linkedto) como enlace a la otra colección.
		El linkedfield es el campo que mostraremos por pantalla, el cual nos traemos de la otra colección.
		La lupa aparece en el campo que no está locked="true", para poder buscar directamente desde él.
		Los demás campos podemos ponerlos con el locked="true" para que NO se pueda editar su contenido NI TAMPOCO salga la lupa.
	-->



mapcol: It indicates that this property is linked to another collection, that is, this is a key field in the relation of many to one.


Example of code:

  <group name="General" id="1"></group>
  <prop name="IDTIPO" group="1" visible="0" type="N" mapcol="TiposUsuario" mapfld="ID"></prop>


In this example is indicated that the property which name is IDTIPO is numerci and is linked to a collection named “tiposusuario”.

The field used to link this property to the external collection is indicated through the 'mapfld' attribute.

This attribute value must be the name of a collection valid within the application. If the collection is not defined, the user interface may cause an error when attempting to link this property with any other.

For this value, the macro ##OWNERCOLL## can be used by indicating we are referring to the collection in which the object owner of this object is defined in.

If the property is declared in a collection of details of documents, the owner collection would be the collection of documents from which the contents is in.

The data layer replaces the name of this macro when it is being asked the value of this property, so the collection must be used as contents.

In case the collection is got directly from the application and do not as a content collection, this macro result will be got from the default-mapcol attribute, in case this attribute is defined, on the contrary it will be an empty string.

default-mapcol: This attribute is used to complete the previous one when the collection that has this property is used as base collection and do not as content collection.


In this case the mapcol attribute will return the value this attribute will have.

In the following example we show this behaviour:

  <coll name="Recibos" .... >
  <prop name="IDDOCUMENTO" mapcol="##OWNERCOLL##" default-mapcol="Facturas" mapfld="ID"></prop>
  </coll> 
 
  <coll name="Documentos" .... >
  <contents name="Recibos" src="Recibos" filter="IDDOCUMENTO=##ID##"></contents>
  </coll> 


In this example, the “Recibos” collection has been declared to be used as content collection in the “Documentos” collection. When this is done this way, the mapcol attribute returns the “Documentos” name, because this is its owner collection.

In case the “Recibos” collection is got directly from the application and do not as content of “Documentos”, the mapcol attribute will return the “Facturas” value, which is the value by default.

mapfld: It indicates which field of the external collection is the one used to be linked to this property. In the previous example, the IDTIPO property is linked to the “TiposUsuario” collection through the ID field.


The properties that this couple has usually are properties of link only, so they usually are invisible in the edition (visible=”0”).


These attributes indicate that the property has been got through a link to an external collection. It is defined for those properties starting with the MAP_ prefix to indicate that they come from a link among tables.

The linkedto value must be the field used to be linked to the external collection, such as it is indicated in the following example:


<coll name='Usuarios' title='el usuario' sql='SELECT u.*,t.ETIQUETA AS MAP_TIPOUSER,t.DERECHOS AS MAP_DERECHOS FROM ##PREF##Usuarios u LEFT JOIN ##PREF##TipoUsuario t ON u.IDTIPO=t.ID' objname='Usuarios' updateobj='Usuarios' progid='ASGestion.CASUser' dropdown='true' filter='IDEMPRESA=##ENTID##'>
   <prop name='IDTIPO' group='1' visible='0' type='N' mapcol='TiposUsuario' mapfld=’ID’></prop>
   <prop name='MAP_TIPOUSER' group='1' type='T' fieldsize='15' size='15' showmap='2' linkedto='IDTIPO' linkedfield='ETIQUETA'> </prop> 
</coll>


This attribute is used together with the linkedfield attribute to indicate the link to another collection. In this case, it is indicated that the MAP_TIPOUSER field is linked through the IDTIPO field with the “TiposUsuario” collection. The field that corresponds to the MAP_TIPOUSER property is the one of the ETIQUETA property of the destination collection. The program does not use this relation for reading the data, since this is done by the SQL sentence, to make updates in cascade, as described later on.


Another use of the linkedto attribute is to define the name of the property to which a property of type “bitmapped” is linked to, as described below.


The Controls by Type section 3.-controles-por-tipo has a detailed explanation about how to build links by using the attributes explained before.


It showns the collection linked through the mapcol attribute as a drop-down menu.