How to loop through multiple shared Hyperlink destinations and turn off "sharing"
Hi there,
I've been using this other forum post as a guide : Shared Hyperlink Destination (thread/791822) but unfortunately I can't quite get the behaviour i need.
Essentially I have documents that contain lots of shared destination URL hyperlinks. So there are multiple shared destinations and there are multiple hyperlinks using each shared destination.
I need to give each hyperlink their own destination URL and remove all shared urls. This then allows me to loop through all the hyperlinks and individually adjust their destination URL based on some other criteria (which I do later in the script).
My understanding is that to remove shared destinations I need to change the "hidden" property from "false" to "true" for shared destinations. It also seems that the only way to do this is to delete and recreate the hyperlink URL destination.
The problem with my current approach is that it removes the shared destination correctly, but it only adds an unshared location back to one of the hyperlinks that was using that shared destination. All the other hyperlinks that were using that shared destination now have NO destination value.
This has been my approach :
- Loop through all hyperlinks that contain a HyperlinkURLDestination and have the destination.hidden value set to 'false'
- For the current hyperlink, capture the destinationURL into a variable.
- Now remove the destination from that hyperlink.
- Add a new destination URL to the current hyperlink using the value stored in the variable (which is the same as what it was originally) and set 'hidden' to true (so destination is not shared).
The above works perfectly for the current hyperlink, but all other hyperlinks that used that shared Destination URL now have no value.
To solve the problem I'm thinking the following approach might work but I'm having trouble working out the correct code:
- Instead of looping through hyperlinks, loop through hyperlinkURLDestinations (whose hidden value is set to 'false')
- For the current hyperlinkURLDestination, capture the destinationURL into a variable
- Now get a 'list' of all the hyperlinks that use the current hyperlinkURLDestination
- Delete the hyperlinkURLDestination
- Loop thru each hyperlink in the list created at step 3 and add a new destination URL to the current hyperlink using the value stored in the variable (which is the same as what it was originally) and set 'hidden' to true (so destinations aren't shared).
- Now proceed to next hyperlinkURLDestination and repeat steps
My key problem is I don't know what javascript I need to write to for Step 3 - how do I get that list of hyperlinks that use the current hyperlinkURLDestination??? Any help to work out how to do that (or any suggestions on a better approach) would be greatly appreciated!
Many thanks, HJ
