Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • andles 44 posts 64 karma points
    Nov 26, 2010 @ 09:26
    andles
    0

    Change 'Link to document' programattically

    I create a node dynamically, and it is created withe name of a member:

    Document.MakeNew("Freddy Smith"...)

    Thats all good, easy enough. But a business rule is that once this member has answered a feedback question she is to be de-identified (certain strings / fields to be encrypted). So I need to knwo how to change the url that appears in 'Link to document' (as this contains the member name).

    Other fields are easy enough, just use getProperty("propName") and change its value to an encrypted version of the original value - can't figure out how to do likewise for the 'Link to document' / urlName.

    Thanks in advance.

    Andles...

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Nov 26, 2010 @ 11:05
    Lee Kelleher
    0

    Hi Andles,

    You could add the property "umbracoUrlName" ... that will override the auto-generated URL for the content node/page.

    Cheers, Lee.

  • andles 44 posts 64 karma points
    Nov 27, 2010 @ 01:02
    andles
    0

    This doesn't work Lee - all I see is a new property 'umbracoUrlName' below the original 'Link to Docuement' field. It doesn't seem to have overridden anything - definitely spelled it correctly.

    Never heard of or used these override properties before, is there something special I need to do to enable them??

    Cheers,
    Andles...

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 27, 2010 @ 01:05
    Dirk De Grave
    1

    And why not change the .Text property (using the Document API) and publish again, that'll change the url because you're changing the name of the node?

     

    Hope this helps.

    Regards,

    /Dirk

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Nov 27, 2010 @ 01:06
    Lee Kelleher
    0

    Hi Andles,

    That is strange, it should work. Hmmm... just checking, the property alias is case-sensitive - but guessing that you've already checked that?

    Usually once the "umbracoUrlName" property has been added, you would need to Save & Republish the page to see the URL change.

    Which version of Umbraco are you using? (not that it matters too much, as the special "umbracoUrlName" has been in there since v3)

    Cheers, Lee.

  • andles 44 posts 64 karma points
    Nov 27, 2010 @ 01:47
    andles
    0

    I'm adding the property dynamically, and using proper case. And it dooes indeed change the URL. And I then see a Link To Document Property AND an umbracoUrlName proerty in the UI (which I didn't expect, thought I'd just see the overridden value in the Link To Docuement text field).

    Then, at some later stage, I use:

     memberResponseDoc.getProperty("umbracoUrlName").Value
                        = crypto.EncryptToString(memberResponseDoc.getProperty("umbracoUrlName").Value.ToString());

     

    But whatI end up with is the UI showing me the encrypted value in the umbracoUrlName field, but no change at all to the 'Link To Document Field'. Is this wrong??

    Dirk, the Text rename and republish is something I'm about to to try  - I did try this earlier but didn't think to do a publish, and mistakenly ruled it out as solution. Thsi will work, just manually republished a node and it did indeed haev teh desired result. Thanks!!

    Lee, still keen to know more about your solution as this is applicable in a related scenario. Keen to know if I'm having an issue or just misuderstanding it?

    Thanks to you both for your speedy assistance!

    Cheers,
    Andles...

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Nov 27, 2010 @ 01:53
    Lee Kelleher
    0

    Hi Andles,

    Since you are doing this programmatically, how are you doing the Save & Publish? Are you making a call to "umbraco.library.UpdateDocumentCache(int nodeId)" also? If not - then try that ... as the NiceUrl is generated via the XML cache.

    Cheers, Lee.

  • andles 44 posts 64 karma points
    Nov 27, 2010 @ 02:00
    andles
    1

    Maybe I need to do some reading up not really sure where updateCache and publish are required - that is, I see certain changes (to my custom doc typeproperties) without taking any steps in this regard.

    Ok - both these solutions work - will try and tick both as correct, not sure if I can do that. Thanks again...

Please Sign in or register to post replies

Write your reply to:

Draft