Subscribe to this thread
Home - General / All posts - Getting a value from a query into a textbox on layout
djmcbell24 post(s)
#07-Oct-18 22:59

I've got a bunch of maps that some people want changes done to. Basically, the maps are populated by a query which gets the correct geometry.

Now, people are wanting the address. This is easy to get in the query - we're only returning one record so the address was easy to tag onto the end. The difficult part is that they'd like it as part of the layout (i.e. the title). Not as a label on the map, but in what I would assume would be a textbox (using the "Insert Text" control on Manifold 8) outside the map element.

Would anyone know if there's an easy way to do this (something like an expression, such as [MyQuery].[Address] - which I've tried and doesn't work, unless something needs exposing)?

Dimitri

5,045 post(s)
#08-Oct-18 06:35

Use your query to update the mfd_meta table. What's in a layout is exposed in records in the mfd_meta table.

Do this to learn more:

1. Create a layout called MyLayout.

2. Drag and drop a drawing of some kind into it, say, a drawing showing some country.

3. Create a text box in the layout and for that text box enter the text CountryNameHere.

4. Open the mfd_meta table.

You'll see a record in the mfd_meta table where the Name field will have the value MyLayout (because that is the name of the component), the Property field will have the value Item.1 (because the text box is the second frame you added to the layout, the first being the drawing which is Item.0), and the Value field for that record will have a JSON string that has this:

"Text":"CountryNameHere",

You can manipulate the values in the mfd_meta table if you like. For example, you could double-click into that Value cell and change "CountryNameHere" to "Mexico" if you like, and the text box will change in the layout as well. Just like you can manipulate those JSON values manually, you can do so with a query.

djmcbell24 post(s)
#08-Oct-18 22:58

Odd. Trying to see the mfd_meta table but can't. Using some simple syntax to just try to see it:

select * from [mfd_meta]

But getting an "unknown table" error. I'm using Manifold 8, and the pdf I've got (from 2011!) details it, though it does list it alongside the Administrator Console (which I've got access to - need to figure out how to use it).

Will keep digging, as I really don't want to go down the "long" way my manager says (creating a new branch in VS, writing something to connect to a view, writing a new view which will expose the address, feeding in parameters, and trying to feed that into Manifold to use). This way, if I can get it to work, sounds ideal.

Should also add that I can't see [mfd_meta] if I just start writing the query and all the data sources drop down.

djmcbell24 post(s)
#08-Oct-18 23:37

Alright, found the [mfd_meta] table. It seems as if it's been taken out of Manifold. There's one in our PostGres database, one in our main SQL database and one in our dev SQL database. And maybe others elsewhere. Now I just need to find which one has this value in (created a textbox with the text "AddressHere" in it - so far, not found one match using

/****** Script for SelectTopNRows command from SSMS  ******/

SELECT [OBJ]

      ,[PROP]

      ,[VAL]

  FROM [dbo].[MFD_META]

  where val like '%address%' or prop like '%address%' or obj like '%address%'

in SQL (or its equivalent in PostGres).

Edit - have also searched for [mfd_root] - no matches.

tjhb

8,280 post(s)
#09-Oct-18 00:36

I'm using Manifold 8

That's it there. Manifold 8 uses mfd_meta only for external databases.

Dimitri assumed 9 (as would I from what you said).

So back to the start. Can you post sample data?

djmcbell24 post(s)
#09-Oct-18 01:10

Unfortunately not.

I've managed to suss out what mfd_meta is doing - the one in our SQL database is used to store things like formatting. Have been tweaking some values through SQL server and seeing them reflected in Manifold.

The layout I want to alter is contained in a map (so you've got myMap, and then underneath it, myLayout). From a quick script I ran, the text is item 12. So I've tried adding this to the mfd_data:

OBJ PROP VAL

myMap Item.12 { "Text":"MyAddress" }

I should also point out that the text box is bound to myMap, when I right-click on it.

However, the value does not update from "AddressHere" (which is what it currently is). I think I'm nearly there, just can't quite get the last bit ironed out.

I found the textbox using the following quick script:

Sub Main

 Set components = Application.ActiveDocument.ComponentSet

 for i = 0 to components.Count-1

 if components(i).name="myLayout" Then

 for j = 0 to components(i).EntrySet.Count-1

 application.messagebox j

 application.messagebox components(i).EntrySet.Item(j).text

 next

 end if

 next

End Sub

As an aside, I can foresee an issue with the query which gets the value. When the map file runs, the query that is run is a simple select query which a layer is subsequently based off. I imagine I can't put a query in here to update the mfd_meta, so I assume I would have to turn this into an update query to update BOTH the mfd_meta and a new table from which we'll create the layer. Which shouldn't be much of an issue, just a bit of a pain.

Mind you, can mfd_data even do this for Manifold 8? Or am I best going through the VS route? Judging from the manual, I don't think it can.

adamw


8,139 post(s)
#09-Oct-18 14:23

Since you are using Manifold 8, alter the text of the relevant layout entry using a script (not through mfd_meta - it doesn't contain much in Manifold 8 and it isn't always there in Manifold 8 either).

To make things easier, you can set the text of the layout entry to '[Layout Description]' and change the Description property of the Layout object - this way you won't have to search for the right entry to modify, the script is basically just: determine what text you want to use, and then Document.ComponentSet("<layout name>").Description = <text>.

Manifold User Community Use Agreement Copyright (C) 2007-2017 Manifold Software Limited. All rights reserved.