Hexagon Geospatial
MENU

M.App Enterprise

Discuss topics with other M.App Enterprise Product pioneers and experts to get the most out of it.
Showing results for 
Search instead for 
Do you mean 
Reply
Frequent Contributor
Posts: 114
Registered: ‎05-25-2016

Fill data from sql query in mobile app

Hi guys, I´m working on a mobile app and I´ll like to populate some fields based on the intersection of the captured point and the polygons on a table. I do not need to show the populated fields to the user, I only need the fields to be calculated and added to the corresponding registry when the report gets saved to the database. Can you help me with this?

Staff
Posts: 1,033
Registered: ‎10-18-2015

Re: Fill data from sql query in mobile app

I think you should be able to do this by using a trigger.

Stefano Turcato
Presale Engineer
Hexagon Geospatial
Frequent Contributor
Posts: 114
Registered: ‎05-25-2016

Re: Fill data from sql query in mobile app

Ok, so.. Ive tried to deal with trigers and failed...

I have a form with a <SaveShellAction /> that, of course, saves the fields into the database. I supose that I should use an AfterSave trigger to run a sql query, but I do not get how I must implement the <SqlTrigger Sql="" />.

 

any chance you could give me an example or code snipet to show me how to implement the AfterSave sql trigger Stefano? 

Staff
Posts: 1,033
Registered: ‎10-18-2015

Re: Fill data from sql query in mobile app

here is a sample:

 

<Entity.Triggers>
	<SqlTrigger Id="UpdateStatusTrigger" Method="BeforeSave,BeforeUpdate" Sql="UPDATE jm_job SET jobstatus = 'In Progress' where id=@{job_id}" />
</Entity.Triggers>	
Stefano Turcato
Presale Engineer
Hexagon Geospatial
Highlighted
Frequent Contributor
Posts: 114
Registered: ‎05-25-2016

Re: Fill data from sql query in mobile app

[ Edited ]

Hi Stefano...

 

First of all, thx for the fast response, unfortunately I´m still unable to make it work.

 

 

So far I´ve placed the trigger in the shell file, within the entity definition as follows :

 

 

<Entity Id="Locations" Table="reportes_3857" Key="id" SyncType="Automatic" RevisionField="lastupdatetime">
			<Field Name="id" Type="Guid" IsRequired="True" />
			<Field Name="status" Type="String" />
			<Field Name="nomloc" Type="String" />
			<Field Name="lastupdatetime" Type="Timestamp" />
			<Field Name="geom" Type="Geometry" IsRequired="True"/>
... <Entity.Filters> <Filter Id="idSearch" Sql="id_reporte LIKE @{idSearch}"/> <Filter Id="IniciadaFilter" Sql="status = 'Iniciada'" IsDefault="False" /> <Filter Id="EnprocesoFilter" Sql="status = 'En proceso'" IsDefault="False" /> <Filter Id="ConcluidaFilter" Sql="status = 'Concluida'" IsDefault="False" /> </Entity.Filters> <Entity.Triggers> <SqlTrigger Id="UpdateTrigger" Method="AfterSave,AfterUpdate" Sql="UPDATE reportes_3857 SET nomloc = 'trigger test text' where id=@{id} "/> </Entity.Triggers> </Entity>

Using this code the form saves the captured data correctly and trigger actually sends the update request to the database, but, It sends hte request "literally", I mean it is not substituting @{id} with the corresponding value, it sends the request as “ UPDATE reportes_3857 SET nomloc = 'trigger test text' where id=@{id} “. As a result, the condition ( id=@{id} ) is not fulfilled and there is “nothing” to update.

 

What am I missing ?

 

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Development Ticket through our Development Ticket Portal.