Hi, Just trying to replicate your issue, I used the following code
var doc = DocumentHelper.GetDocument(nodeId, treeProvider());
if (doc != null)
{
doc.DocumentUrlPath = "ROUTE:lovely-route";
doc.Update();
}
This seemd to work and set the checkbox as expected. But only the first time. If I reset the URL in CMS desck and then call it again, I get the results you're experiencing.
I modified my code as follows:
var doc = DocumentHelper.GetDocument(nodeId, new TreeProvider());
if (doc != null)
{
doc.DocumentUrlPath = "ROUTE:lovely-route";
doc.DocumentUseNamePathForUrlPath = false;
doc.Update();
}
This now sets the Use custom URL path checkbox corectly. It seems that combination of DocumentUrlPath and DocumentUseNamePathForUrlPath determine how this checkbox works. Hope the helps you!