Issue with UIN Script Service

I need some help with this extension
image

I am able to make a unique number in each pages, but the UID increment everytime i refreshes , edit or just preview alone. Is there anyway to stop it from incrementing after the first increment?

Hello @Toot,

no, not when using the SimpleUINManager strategy, you may be able to get different results with the gapless manager.
However, your question shows that you may be using it wrongly: the UIN Script Service is not a storage tool for Unique numbers, it’s a tool to generate a number and give it to you. Thus, whenever your script is executed and the .next() function is called the next unique number will be provided. And yes, a script in a page will be executed anytime you view the page, preview it, edit it in wysiwyg, etc.
If you need to have one such unique number per page (for example) and then display that unique number without refreshing or changing it, then you need to modify your script to store it on your side, once for each page, and then display it from storage for that page and modify it / generate a new one only if you don’t have one already stored or something.

Generating the UIN and storing one UIN per page to retrieve it later are 2 different concerns, UIN Script Service only handles the generation part.

For information, probably the easiest way to store custom data in XWiki are XWiki classes & objects: https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/DataModel/ , but it’s not the only one. Depending on your need and the amount of code you’re ready to write, you can choose something else.

Hope this helps,
Anca

Oh okay , i will take a look at it.