Org Chart Shape Data Bug/Feature

Started by rjk1974, August 05, 2021, 10:30:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

rjk1974

Question: I'm responsible for developing an org chart for a team of ~1,000 people and I'm currently trying to use Visio 2019 but am being frustrated by a bug/feature that seems to be in the source code and is not user customisable. I'm wondering if anyone here has found a fix for this problem?

Background: The bug/feature is within the org chart add-on and is related to the shape data of org chart tiles. I've found in Visio 2016 and 2019 that adding a new shape data field to any org chart shape and entering data in that field causes that new data field to become a default field for all new org chart shapes I put on my chart. My problem is if I make a mistake and subsequently want to change or delete that default field, I can do that for the shapes that are already on the page, but the mistake will still be there for all new shapes I put on the page.

This seems to only be a problem with org chart shapes - it doesn't happen with other shapes (e.g. a PC shape with its own default data fields). I note that when I try and change the document stencil shape data, those bogus shape data fields still keep appearing, but only for org chart shapes (that process to change the default data fields works fine for non-Org Chart shapes).

My problem manifests because in our organisation many people will be responsible for updating the org chart as people move into/out our program. Sometimes when people do that they copy/paste an org chart tile from another Visio file and if it has different shape data fields from my org chart it will add those bogus data fields to the file and thereafter all new org data shapes we put into the file will have that bogus data fields. We rely on the exported data from the org chart to manage our org baseline, but these bogus fields add extra redundant information to the Excel output which corrupts our process. All it takes is one bogus org tile to be pasted into the document to corrupt the whole thing and the only way that I've found to fix it is to rebuild the entire org chart from the original source data (a painful process).

Replicating the bug/feature: Open a blank org chart template, put a new org chart shape on the page. Open Shape Data then Define > Shape Data. Add a new field and put data in it. Thereafter all new org chart shapes you put on the page will have that new data field and there is no way to remove the bogus field if I subsequently want to except by starting again in a clean file.

I searched your forums and only found this post from 2015 with zero replies, so not very hopeful there is a fix but thought I'd ask... Very much appreciate any insights/advice you can provide about working around or fixing this bug!

Croc

The fact is that, by default, org chart master shapes contain only 3 data fields.
But in the process, they adapt to external data or to changes introduced by the user. The new set of fields is stored in the document as XML and subsequently applied to all new shapes.
If garbage accumulates in your document, then it is enough to remove unnecessary elements from the "Position" node in the "Solution1.xml" file.
You can do it manually using WinRAR and a text editor.
You can also write a script to automatically open the Visio drawing batch file and edit the Solution1.xml file.
You can write a more complex program that will display the properties available in the document and receive an indication from the user which of them should be removed.
Unfortunately, all three solutions are difficult enough for a novice user.

Nikolay

#2
It seems that Org Chart has a "feature" that automatically adds property to new shapes, if you define one.
I think it could even make some sense. You can see this property in the "org chart" data, and can control where it should be displayed:



With this dialog, at least you can check if there are "bogus" properties or not.

Maybe there is an option in OrgChart to remove the bogus properties somewhere.
I mean, you can see them in that dialog above on the screenshot. Maybe there is some dialog where you can manage them with UI.
That would be an easy solution. But I haven't found the "remove" button.

If this was my problem, I'd probably write a macro to clean up the diagram (option "2" from Croc).
It looks a bit complicated, but perfectly possible. Maybe somebody will volunteer to do that.

The plan could be:

1. Get a list of "valid" property names.
These can be all that actually exist, for example (you can get the list by iterating the shapes and getting their shape data lists).
Alternatively, you could get the list of properties from the original masters, or just use a fixed list.

2. Read Org Chart addin's settings (SolutionXml element),
3. Remove from the SolutionXml all properties that are not in the list from point (1) - a bit of pain to do with VBA
4. Save the SolutionXml back to the document.

This will probably work unless the OrgChart add-in overwrites the SolutionXml element on save.

If this plan fails, you could use an external script to patch the file directly (check the screenshot from Croc)
I.e. a script that reads Visio file directly without Visio, patches the "SolutionXml" element.

rjk1974

Thanks so much Croc! Frustratingly difficult process but I guess that's what you get with 20 year old code in the Org Chart add-on!
Interestingly your process works for all pre-defined and new fields that might be added to the chart except for the 'Calendar' data field, which seems to be hard coded in the file elsewhere. I've deleted all references to the 'Calendar data field from the solution1.xml and solution2.xml files but it still keeps reappearing! However if that's the only bogus data field I can live with that.

For everyone else, the specific procedure I used to change the org chart data fields to be what I wanted was:

  • Update the data fields in the doc stencil for all the org chart shapes to be what I wanted (shape data sets make it easy to replicate, and don't forget the 'staff' shape)
  • Save the file
  • Shut down Visio
  • (assuming you're using Windows) rename the file from *.vsdx to *.zip
  • Right Click > Extract All
  • Open the new folder. Within it navigate to and open visio > solutions > solution1.xml using a text editor (or xml editor if you're fancy)
  • Within the 'Position' node of the xml, you'll see all of the data fields per Croc's post
  • Delete all the bogus data fields from the <xs: to the >
  • save the file and close
  • In Windows explorer navigate back up to the root directory of your folder (should see folders: _rels, docProps, visio and file:[Content_Types].xml
  • Highlight all those folders & files and right click Send To > Compressed (zipped) folder
  • Rename the new zip file you just created from *.zip to *.vsdx
  • Open the new visio file and your bogus data fields should be gone from your new shapes. You'll have to delete them from shapes that are already on the page.

If anyone can think of an easier way to do this let me know! I've also flicked Microsoft an email suggesting they do better than this in their Visio Plan 2 Data Visualiser.

Thanks again..

Croc

I tried to make an application to automate the removal of unnecessary properties from the document (from the "Solution1.xml" part).
You can see how it works (file OrgChartProject1.mp4) and download the installer (publish.rar) from Google Drive - https://drive.google.com/drive/folders/1Z9unlOJo4rtuLM4yDWZb1Qzs790FIa-F?usp=sharing
I named the application "OrgChartDataCorrector".
The video also shows "PackHelper", but it is not needed to work. I only use it for quick XML viewing.
If such work is useful, I can upload the source code. The code is raw. It requires testing, optimization, etc. I probably won't be doing this anytime soon.