Hi,

I would see a couple of options of doing it yourself:

1) Add an ID property to your class and write a java event listener that
assigns it when a new entry of your class is created.
1.1) Also make sure you customize your sheet to not allow users to modify
that new property (i.e. remove any form element about it or set it hidden).

2) Add an ID property to your class and customize your sheet to add a
hidden form element whose value you prefill with a random value (if one is
not already set).

3) Customize the creation of new entries in your application so that you
can generate a random document name for your entry which you can then use
as ID

etc.

In all cases, you need to make sure that the random ID generated is
sufficiently large to avoid collisions... and an existence check would also
be good before using the generated ID.

Whatever you do, you will still have a theoretical possibility of
collision, since XWiki`s web APIs don`t really allow for transactional
operations. You would have to get down and dirty to make it right, by
having a script service that generates and creates, at the same time,
inside the same transaction the document corresponding to your unique new
entry, which you could then edit. However, if you do the basic checks and
have a large enough random ID, you should be pretty safe in practice.

Hope this helps,
Eduard

On Thu, Sep 22, 2016 at 4:16 PM, Vincent Massol <vinc...@massol.net> wrote:

> FTR someone had published this extension a long time ago:
> http://extensions.xwiki.org/xwiki/bin/view/Extension/
> Unique+Identification+Number+Module
>
> I don’t know its state and I’ve never used it though.
>
> Thanks
> -Vincent
>
> > On 22 Sep 2016, at 14:29, Chitnis, Xavier <xavier.chit...@rmh.nhs.uk>
> wrote:
> >
> > Hello,
> >
> > I work in a hospital information department, and we provide data to many
> people within the organisation. I would like to create a list of requests
> from users for data. Ideally, it would be very helpful if we could assign
> each record a number or ID that we can use elsewhere, e.g. in the SQL
> queries that we write, so that it is easy to go back to the details of a
> request. We could do this manually, but that is obviously prone to error.
> >
> > The example in the issue Marius linked to would be ideal, if that were
> possible in future.
> >
> > Kind regards,
> >
> > Xavier
> >
> > -----Original Message-----
> > From: users [mailto:users-boun...@xwiki.org] On Behalf Of Vincent Massol
> > Sent: 22 September 2016 12:00
> > To: XWiki Users
> > Subject: Re: [xwiki-users] Livetable counter or unique id?
> >
> >
> >> On 21 Sep 2016, at 20:41, Chitnis, Xavier <xavier.chit...@rmh.nhs.uk>
> wrote:
> >>
> >> Hello,
> >>
> >> I am a new user of XWiki and am just starting to explore its
> functionality. I've searched for an answer this question but haven't found
> anything yet.
> >>
> >> I have created an application (which allows me to record details of
> requests received from other parts of my organisation), and have entries
> displayed in a livetable. Is there a way of adding a counter or unique ID
> field to the application and livetable display? This would make it much
> easier to refer back and find entries. I can't see a "doc." property that
> would enable me to do this.
> >>
> >> Many thanks in advance for any assistance.
> >
> > As Marius said, there’s no counter. However you could use the page full
> name as the unique id (don’t know what your needs are though).
> >
> > Thanks
> > -Vincent
> >
> >> Xavier
> > ________________________
> _______________________________________________
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to