Update DocumentMenuRedirectUrl through API, changes not showing in live site

bert limerkens asked on March 6, 2017 12:07

Hey guys,

I need to set a redirect url for some nodes. These url's are generated through code so I have to update the nodes through the API.

 node.DocumentMenuRedirectUrl = url;
 node.Update(true);

 node.Publish();

this is my code. As you can see I set the DocumentMenuRedirectUrl, update the node & then publish it. After I've run this code I can see the changes in the Navigation tab of these nodes. These are correct.

My problem however is when I want to verify these changes on the live site. If I click on a url that refers to one of these nodes, it still gives me the real url instead of the redirect url. When I switch to preview mode, the correct url is used.

My nodes are published, the url is correctly filled in but it doesn't show on the live site. Anyone has an idea on why it's not showing correctly?

Correct Answer

Zach Perry answered on March 6, 2017 16:06

Something like this might work:

            WorkflowManager workflowManager = WorkflowManager.GetInstance(new TreeProvider());
            WorkflowInfo workflow = workflowManager.GetNodeWorkflow(node);
            // Checks if the page uses workflow
            if (workflow != null)
            {
                if (!node.IsCheckedOut)
                {
                    node.CheckOut();
                }

                node.DocumentMenuRedirectUrl = url;
                node.Update(true);
                node.CheckIn();
                if (!workflow.WorkflowAutoPublishChanges)
                {
                    node.Publish();
                }
            }
1 votesVote for this answer Unmark Correct answer

Recent Answers


Roman Hutnyk answered on March 6, 2017 14:53

Are you using content locking and/or versioning? - You might need to checkin/checkout a document.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.