<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: right custom ID generation in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/right-custom-id-generation/m-p/143380#M38103</link>
    <description>&lt;P&gt;You can try db-afts instead of full text query.&lt;/P&gt;&lt;P&gt;db-afts is using db instead of solr so it will give result immediately.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Mar 2024 09:41:12 GMT</pubDate>
    <dc:creator>sp2</dc:creator>
    <dc:date>2024-03-12T09:41:12Z</dc:date>
    <item>
      <title>right custom ID generation</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/right-custom-id-generation/m-p/143379#M38102</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;I need advice how to properly generate my own unique ID in Alfresco. My ID is created unique for every site, some prefix (created by date and some property) + incremental suffix. I store this values in datalists in every site. I have this already working code as behavior onCreateNode():&lt;/P&gt;&lt;PRE&gt;public String getInvoiceNextValue(String siteShortName, String prefix) {
       // Find generator for given projectType
       String query = "PATH:\"/app:company_home/st:sites/cm:" + siteShortName + "//*\" AND TYPE:\"test:myDatalist\" AND @test:prefix:\"" + prefix + "\"";
       ResultSet resultSet = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_FTS_ALFRESCO, query);
       // If doesn't exist, creates one, otherwise return next value
       if (resultSet.length() &amp;lt; 1) {
           return createDocumentCounter(siteShortName, prefix);
       } else if (resultSet.length() == 1) {
           NodeRef counterRef = resultSet.getNodeRef(0);
           String newCounterValue = (String) nodeService.getProperty(counterRef, MyDatalistModel.PROP_SUFFIX);
           int newIntValue = Integer.parseInt(newCounterValue) + 1;
           newCounterValue = String.format("%04d", newIntValue);

           nodeService.setProperty(counterRef,  MyDatalistModel.PROP_SUFFIX, newCounterValue);
           return newCounterValue;
       } else {
           throw new AlfrescoRuntimeException("resultSet.length() &amp;gt;= 2!!! Please Fix it!");
       }
   }&lt;/PRE&gt;&lt;P&gt;But i have problem when more documents are created at one time. Specially when no row with my test&lt;img id="smileytongue" class="emoticon emoticon-smileytongue" src="https://connect.hyland.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;refix exist and then function createDocumentCounter() is called. It takes some time that Alfresco FTS query return my new created row. So it happens that more documents create own row with same values.&lt;/P&gt;&lt;P&gt;I thing that problem is in indexing of solr which take few seconds. So... Is my approach right? Can i somehow configure solr better? Or should i use some another approach? How you are dealing with creating customers ID?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 05 Mar 2024 12:51:06 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/right-custom-id-generation/m-p/143379#M38102</guid>
      <dc:creator>Dagoo</dc:creator>
      <dc:date>2024-03-05T12:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: right custom ID generation</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/right-custom-id-generation/m-p/143380#M38103</link>
      <description>&lt;P&gt;You can try db-afts instead of full text query.&lt;/P&gt;&lt;P&gt;db-afts is using db instead of solr so it will give result immediately.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2024 09:41:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/right-custom-id-generation/m-p/143380#M38103</guid>
      <dc:creator>sp2</dc:creator>
      <dc:date>2024-03-12T09:41:12Z</dc:date>
    </item>
  </channel>
</rss>

