Is it possible to store hidden metadata information that is tied to a specific Table or Cell within a Word document? - ms-word

I am trying to store metadata (basically a unique id) along with each cell of a table in a Word document. Currently, for the add-in I'm developing, I am querying the database, and building a table inside the Word document using the data that is retrieved.
I want to be able to save any of the user's edits to the document, and persist it back to the database. My initial thought was to store a unique id along with each cell in the table so that I would be able to tell which records to update. I would also like to store some sort of "isChanged" flag within each cell so that I could tell which cells were changed. I found that I could add the needed information into the "ID" property of the cell - however, that information was not retained if the user saved the document, closed it, and re-opened it. I then tried storing the data by adding a data to the "Fields" collection - but that did not work and threw a runtime error. Here is the code that I tried:
object t1 = Word.WdFieldType.wdFieldEmpty;
object val = "myValue: " + counter;
object preserveFormatting = true;
tbl.Cell(i, j).Range.Fields.Add(tbl.Cell(i, j).Range, ref t1, ref val, ref preserveFormatting);
This compiles fine, but throws this runtime error "This command is not available".
So, is this possible at all? Or am I headed in the wrong direction?
Thanks in advance.

Wound up using "ContentControls" to store the information I needed. I used the "Title" field to store the unique id, and the "tag" field to track whether the field had been changed or not. See this link for more info: http://blogs.technet.com/gray_knowlton/archive/2010/01/15/associating-data-with-content-controls.aspx

Since a "Word 2007 Document" is XML, you can add a namespace to the document then adore the elements with attributes from your namespace. Word should ignore your namespace when loading and saving. Moreover, you can add new elments to store any information (metadata) needed.
With that said, I have not used this technique with Word, but I have done it successfully using Excel 2003.
First thing to try, is create a bare "Word 2007 Document". In your case, add a simple two by two table. Open it with a text or XML editor and add your namespace, and adore an attribute and add an element. Open with Word make a change then save it. Open with editor and make sure your namespace attribute and element have not been changed.

Related

Change the name of an item in a custom field using API

I am looking for a way to change the names of the items in a custom field I created in studio, without changing their display labels.
I used the field editor (still in studio) to change the associations between names and labels, but despite my modifications, I am still getting the former names (those that were defined before my modifications) when I'm using the API.
How can I make the new names be effective?
Thank you for your help.
When you change the keys in a dropdown list (you called them 'names'), it will change the language file in SugarCRM, but will not change the existing values in your database. So a query to existing records that used the old keys will still return those old key values.
You will need to perform UPDATE queries in your database similar to:
UPDATE contacts_cstm SET mydropdownvalue_c='NewValue' where mydropdownvalue_c = 'OldValue';

Word 2013 pageref fields set to update on document open results in incorrect values

I have a document in word that has a pageref field pointing to a bookmark on another page. When I create the field, it shows the correct value (let's say page 4). I then enter content before page 4, pushing the content to page 5. I then try an automated way to update fields (a macro run on document open, or the updateFields tag entered into the document's settings file) and in both cases, the field is updated to an incorrect value. I have not been able to get correct values into the field except by updating the field after the document is already open.
Is this a known issue? Do I have some weird issues with my installation of Word 2013? Does anyone have an idea on how I can update the fields (preferrably without a macro) without needing the user to take an action?
edit:
To clarify how I am generating this document: It was originally an openxml generated document, but this behavior is repeatable with a new word document created via word
the pageref fields update to incorrect values whether the update is done via macro, or word settings. See below for the macro I tried. Also note, that If I manually run this macro AFTER the document has opened, the fields update with correct values
Sub AutoOpen()
With Options
.UpdateFieldsAtPrint = True
.UpdateLinksAtPrint = True
End With
ActiveDocument.Fields.Update
End Sub

Filemaker Pro 14 History tables

With a few solutions Ive worked with I've created temp table's or history tables. Normally I script it to take a handful of fields needed from a main table and copy it over to the other table by
Setting a variable then setting field to the variable for each field in the new table / new record.
I have a situation now, where Im building a history table that needs to copy the current record as is. A snapshot where all fields from that instance of the record are copied to the history table.
Rather then setting a variable then set field to the variable, Id like to get some input on a quicker way to get this done where I can do this on a record level and not type out field by field to get it done. Also if fields are added to both tables then I have to make sure my script gets updated.
Ill keep hunting around.. appreciate any help.
-Rich
Do you have a sample of copying a record from 1 table to another
including all fields and setting some fields?
As I suggested in comments, use the Import Records[] script step, and select the same file as the source. If you choose Arrange by: [ matching names ] in the Import Field Mapping dialog, it will automatically map all source fields to their similarly named counterparts.
Note that you must establish a found set in the source table before importing.
For "setting some fields", you can define auto-enter options and activate them during the import, or run Replace Field Contents[] immediately after the import.

Embedded view ( subform ) and form - LOTUS NOTES

I have a main form called fm_Main. This fm_Main contains an embedded view which has 2 actions: Add & Delete. When I click Add is opening another form called fm_Second and here I can add some fields which will be displayed on the embedded_view on fm_Main.
The problem is: Let say I have 3 documents. All of them contains an empty embedded view. If I add some value fields in one document into the embedded view and then I save that document, all the 3 documents contains that values into the embedded. It should be: just one of them should cotain because I modified only one, the 2 of them shoudn't have that values displayed in the embedded view. Thank you!
PS: Also if I saved one document with an entry into the embedded view. When I want to create another new document, in the embedded view there exists the last entry from the last document. I want to be empty!
You must filter the embedded view to only show the entries related to the currently open main document.
Most programmers would use the UniversalID of the main document, it can be automatically populated into the entries you create.
One thing to think about is that you may want to store the Universal ID in a computed when composed field on teh main document. If you get a replication error in the future, the Universal ID may change, and you will not be able to get to the entries in the embedded view.
I been doing exactly this in several large Notes databases, works perfectly fine.
Expanding on Karl-Henry's suggestion, you should make into a categorized view and use the Show Single Category feature of the embedded view. I might suggest using the #Unique function instead of the UNID to relate the Main and Second documents, but that's a matter of preference. In either case, you have to make sure that the value inherits down into a field in the Second docs, and you can use that field as the category for the view.

How can I (partially) automate the transfer of a FileMaker database structure and field contents to a second database?

I'm trying to copy some field values to a duplicate database. One record at a time. This is used for history and so I can delete some records in the original database to keep it fast.
I don't want to manually save the values in a variable because there are hundreds of fields. So I want to go to the first field, save the field name and value and then go over to the other database and save the data. Then run a 'Go to Next Field' and loop through all the fields.
This works perfectly, but here is the problem: When a field is a calculation you cannot tab into it and therefore 'Go to Next Field' doesn't work. It skips it.
I though of doing a 'Go to Object' but then I need to name all the objects and I can't find a script to name objects.
Can anyone out there think of a solution?
Thanks!
This is one of those problems where I always found it easier to do an export/import.
Export all the data you want from the one database, and then import it into the other database. All you need to do is:
Manually specify which fields you want to copy
Map the data from the export to the right fields in the new database/table
You can even write a script to do these things for you.
There are several ways to achieve this.
To make a "history file", I have found there are several cases out there, so lets take a look.
CASE ONE
Single file I just want to "keep" a very large file with historical data, because I need to erease all data in my Main file.
In this case, you should create a "clone" table (in the same file ore in other file, is the same). Then change any calculation field to the type of the calculation result (number, text, date, an so on...). Remove any "auto entered value or calculation from any field, like auto number, auto creation date, etc..). You will have a "Plain Table" with no calculations or auto entered data.
Then add a field to control duplicate data. If you have lets say an invoice number (unique) for each record, you can do this to achieve this task. But if you do not have a unique field that identifies the record as unique, then you have to create one...
To create such a field, I recommed to add a new field on the clone table and set as an aunto entered calculation and make a field combination that is unique... somthing like this: invoiceNumber & "-" & lineNumber & "-" " & date.
On the clone table make shure that validation is set up for "always", and no empty values allowed and that this value is unique.
Once you setup the clone table... then you can import your records, making sure that the auto enty option is on. Yo can do it as many times as you like, new records will be added and no duplicates.
If you want, can make a Script to do the move to historical table all the current records before deleting them.
NOTE:
This technique works fine when the data you try to keep do not have changes over time. This means, once the record is created is has no changes.
CASE TWO
A historical table must be created but some fields are updated.
In the beginnig I thougth a historical data, never changes. In some cases I found this is not the case, like the case I want to track historical invoices but at the same time, keep track if they are paid or not...
In this case you may use the same technique above, but instead of importing data... you must update data based on the "unique" fields that identifiy the record.
Hope this technique helps
FileMaker's FieldNames() function, along with GetField() can give you a list of field names and then their values