Copy a column to another OO document

I am trying to copy a column from one document to another using this OO script. The script failed with the error:

Error Number: -1700
OmniOutliner got an error: Can’t make value of cell “Test” of item 1 of every row of document id “gnzqlI_eSIF” into type text, date, number, enumeration, constant or missing value.

Can someone help with updating the script.

The error occurs at this line:

--set the cell data
set value of cell colName of childRow to value of cell colName of theRow

I guess the command requires more segmentation. Replace it with this:

set value of cell colName of childRow to (get value of cell colName of theRow)

Basically, its two parts need to be clarified, e.g.

set xy to value of cell colName of theRow -- get data from sourceDoc
set value of cell colName of childRow to xy -- apply data into destDoc

Using (get… ) manages to combine that into a single line.

The edited script adds the first line. And then failed with error:

Error Number: -10000
OmniOutliner got an error: AppleEvent handler failed.

Do you have the selections correct in your documents? The source doc must be the frontmost, and you must have column(s) selected. The destination doc must be window 2 and must have suitable row(s) selected (i.e. probably the top row must be at least one of the selected rows).

If any of these conditions are not met (especially the last), then the -10000 error is possible. My guess (from this and other cases) is that this error results when attempting to mesh two disparate structures. In this case, a column is not just a collection of vertically-aligned cells, rather, it is the entirety of them. Since the source material is an entire column, then the destination must also be and that requires that the reference encompass the top row. That’s just me speculating though. FWIW, I got that error countless times while testing this.

Of course, once you get it working, you can probably edit the script to manage these requirements.

The script works on test documents. I will look for an error in my data.
Thank you!

1 Like

An error occurs when the source and destination documents have a different structure.

It is easy to check when the structure at the beginning of the documents is the same. The error occurs in a row where the differences begin.

That’s unfortunate but it doesn’t surprise me. It’s too bad though as I thought that was a pretty solid script.

Out of curiosity, does that mean that your needs would be more likely to be met if the script was section-based rather than document-based? i.e. required to replicate the columns of a given top-level row and its subordinate rows….

I’ve been playing around with replicating the columns of a section (e.g. if an outline had 100 rows and 5 columns, and the objective was to move column 4 of a group of 40 rows to a document with 50 rows and 4 columns – and each doc had a top-level row with the same topic). In such a scenario, if the receiving section had only 10 rows, then 30 would be added so the sections would match. Or if instead, the receiving section had extra rows, then rows would be removed until they matched. If the column’s name exists, then its cells would be overwritten but no new column would be added. For rows outside the section, of course the added column would exist but none of the intersecting cells would have content.

It’s not complete yet and I’ve only tested it with ‘styled text’ and ‘checkbox’ column types, and it ignores styles, but the moving part seems to work well enough and it now gets the levels to match. In some scenarios it might be useful. I wouldn’t mind posting it even though it’s still rough.

See also this discussion:

For the (inevitably common, in fact overwhelming majority) case where outline structures differ between two documents, there’s no obvious or unique definition of what it would actually mean to:

“copy a column from one document to another”

The simplest option would be to define it as uncomputable, and return a message display to the user (some translation of undefined) when structural difference is detected.

If you were aiming for some kind of partial copy (when outline structures differ), then you would need to make a number of essentially arbitrary choices about:

  • what you would want to discard,
  • what you would want to transfer across,
  • and where the copied values would go.

I am using one task management app along with several outliners and note management apps. My goal is to arrange items across different apps as described in PARA Method. The elements are grouped into projects by branches, tags, prefixes in the title.

I chose OmniOutliner for this job, hoping that in the future I can automate the process. But I am not ready to formulate an algorithm.

At this stage, I just had to:

  • export Evernote tags as an outliner,
  • get the full path for a tag through concatenation with parent tags in a spreadsheet editor,
  • add the column with the full path in the original outliner.

This work is done. Perhaps it could be made easier if I could generate the path to the outliner element directly in OmniOutliner column.