Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We want to change some special characters from the final URL when new articles are created or updated.
For instance "Hello æøå world" would look like "Hello%20%C3%A6%C3%B8%C3%A5%20world", but we want it to instead look like "Hello-aeoa-world".
Keeping the original title is also important.

Update:
Have tried doing this:

public override void ItemUpdated(SPItemEventProperties properties)
{
    base.ItemUpdated(properties);
    SPFile file = properties.ListItem.File;
    String url = file.Url.Replace(“ø”, “o”);
    EventFiringEnabled = false;
    if (file.Exists && !url.Equals(file.Url))
    {
        file.MoveTo(url, true);
        file.Update();
    }
    EventFiringEnabled = true;
}

This will move the file properly. But since this is run after everything is complete there might not be any more updates, and the user is redirected to the old URL, which will result in a 404.

Using ItemAdding does not help since ListItem is not created, and properties.AfterProperties does not work.
At least not any of these (testing with title):

properties.AfterProperties["Title"]= "Test";
properties.AfterProperties["Tittel"]= "Test";
properties.AfterProperties["vti_title"]= "Test";
properties.AfterProperties[SPBuiltInFields.Title.ToString()]= "Test";

And properties.BeforeUrl and properties.AfterUrl can not be assigned to.

If I move the file in ItemAdded there seems to be some lost connection between properties.ListItem and properties.ListItem.File since the file is moved, but page layout is set to nothing (as well as content type and every other property) so it prints an error.

Update 2:
properties.AfterProperties works if I do exactly this:

public override void ItemUpdating(SPItemEventProperties properties)
{
        properties.AfterProperties["vti_title"] = "test";
}

But this changes the title, not the URL. I want to change the URL and keep the title.

share|improve this question
add comment

closed as too localized by Alex Angas Jun 15 '11 at 3:37

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.