Copied to clipboard

Flag this post as spam?

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


  • Kurniawan Kurniawan 202 posts 225 karma points
    Aug 11, 2010 @ 05:28
    Kurniawan Kurniawan
    0

    Unique ID Data Type

    Is that possible to create a unique id data type in Document Type field ?

     

    For example I want to define a list type of a products.

     

    Thanks

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Aug 11, 2010 @ 10:49
    Ismail Mayat
    0

    Kurniawan,

    I have created one for a page title its same principle, when you publish a page it will check all other published pages to ensure that the page title for the current page is unique.

    I am going to release it at some point when i get 5 minutes

    Regards

    Ismail

  • Kurniawan Kurniawan 202 posts 225 karma points
    Aug 18, 2010 @ 06:01
    Kurniawan Kurniawan
    0

    Is umbraco has a GUID data type like in .NET?

    Can we generate incremental ID (int) in umbraco?

     

    Thanks

     

     

  • David 26 posts 50 karma points
    Feb 24, 2011 @ 18:07
    David
    0

    We often have a requirement to utilise a completely unique ID on a document type. 

    Thinking of the most recent example, we want to generate a unique ID to syndicate content to a remote source.

    We chose to achieve this by creating a label (read only) data type on the document and then using a dcoument event handler to generate a GUID on the first save of the document.

    The unique ID is in the format below and is guaranteed unique to some silly order by Microsoft :)
    500ca0e7-5fea-433b-b3a1-527a315cb1c1

    The document event handler is a file that stis in the app_code directory, here's a quick example of how we achieve this:

    if (sender.ContentType.Alias == "mkNewsItem")
                {

                    string stGuid = sender.getProperty("mkNewsGUID").Value.ToString();


                    if ( String.IsNullOrEmpty(stGuid) ){               
                        sender.getProperty("mkNewsGUID").Value = System.Guid.NewGuid().ToString();
                        Log.Add(LogTypes.Save, sender.Id, "Generated GUID for news item");
                    }
                }

    Hope this helps - if you need more info - get in touch :)

    Good Luck,
    David :)

Please Sign in or register to post replies

Write your reply to:

Draft