3

I have 2 templates, Location and Provider. Provider has Locations associated in a Multilist field.

At times, I need to mark the Location non-publishable. But when I do this and publish it (ultimately deleting non-publishable Location item from WEB), Provider's Location field shows a broken link. This causes problem while indexing data as it indexes broken links as well.

But is this really expected? This seems Sitecore's default behavior. Shouldn't it be cleared automatically?

Note: I tried rebuilding the link database but that did not clear that broken link.

2
  • 1
    Yes, it is the expected behavior. The item is marked as unpublishable and not deleted. If an item is deleted then it removes all links to that item. You can solve this by 1) manually removing the location from the multilist on the provider or 2) write a custom handler to remove the unpublishable location from the dropdown. Please note that Option #2 is not preferred as it means that the custom code should be maintained and may cause other issues in future. Aug 2, 2023 at 16:52
  • You could add a computed field to represent your drop down in the index. That could check to see if the item exists in the targeted DB and return default if it doesn't. Alternatively, because it would be classed as a 'broken link' in the target DB, you could create a scheduled task that runs periodically to find and remove broken links from the web DB.(confirm this by running broken link report and checking to see if your expected drop down is shown I'm Web db) Aug 2, 2023 at 20:35

3 Answers 3

2

Yes, it is expected. In the Content Editor and the Experience Editor, you can restrict the publication of items using publishing restrictions. Publishing restrictions let you specify that a specific item or a version of an item is publishable or unpublishable, either within a specific date range or indefinitely. In this way, you can control which items and pages are available for publishing at any given time.

If you clear the Publishable check box, this affects all the item versions listed on the Versions tab. This means that if you specify an item as not publishable, you cannot make a version of that item publishable. When you publish, the item and all its versions are removed from the target database.

Below are the ways to handle it.

  1. Delete the Location item using Breaking Link's dialog with the appropriate action.

    • Remove Links
    • Link to another item.

    enter image description here

  2. Provide the content author with such an ability so it could be prevented in the future using Powershell or custom development.

References:

Hope it helps!

2

Yes, it is the expected behavior and there are many ways that you can use to remove broken links. So if you want to create a code in C# or use a Powershell script.

To get these broken links, you can query the Sitecore LinkDatabase. If there are not many items then would prefer to remove them manually.

Reference: How to Remove Dependable Links when deleting item using item.Delete()

And another way is through PowerShell. Refer to this script that will give you an additional report about all the broken links.

Hope this helps.

1

As chandra mentioned in comments, i believe this is intended behaviour.

In additon to his suggestions, you could add a computed field to represent your drop down in the index. Then during indexing check to see if the item exists in the targeted DB and return default if it doesn't.

Alternatively, because it would be classed as a 'broken link' in the target DB, you could create a scheduled task that runs periodically to find and remove broken links from the web DB.

There are many sources on web that can provide the code you need to find and remove broken links programmatically.

(To confirm its a broken link, run the broken link report and check to see if your expected drop down is shown in Web db.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.