Skip to Content

Tip for how to get the new documents DocNumber in UI

Hi... Know that a topic of much debate is when a user press add on a document and you need the new add number. I would be easy to read i SBO was a simple sigle-user application, but it's not.. Many have tried different technics (Check which was last added, catche the text of the statusbar message ect.) but none of them was really great. When faced with the problem myself I found the following approach, and since all these version, I thoght someone might get an insight to this approach which I would say is bulletproof (Until some of you shoots i down perhaps :-)... Her goes...

Step 1.

Add a userdefined field to the ducument that can hold a temporary Unique identifier (50-100 chars)

Step 2.

On Add-button click (Before action) genereate a unique ID and place it in the UDF. Save this uid globally in memory (A UID can be created using .NET's GUID class)

Step 3.

On the action-success use the UID stored in memory and a recordset to retrieve the DocNum.

Step 4.

Get the DI-version of the Document

Step 5.

Clear the UID from the Document (to avoide that generated UID appears two times in the db (You can never be too sure))

Any flaws in this approach?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • author's profile photo
    Former Member
    Sep 28, 2005 at 02:02 PM

    Hi Rasmus,

    Thanks for sharing this with us. I really like this approach. Much simpler than all the others getting dates, users, max records, etc. I really like it - that is until someone (as you say) shoots you down 😊

    Thanks again!

    Adele

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 30, 2005 at 02:31 AM

    yeah!

    Can we reward points for this very good ideas?

    way to go Rasmus!

    Harold

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Oct 05, 2005 at 10:15 PM

    Hi.. I tried yout solution, but my code didn´t work properly, because Action_Success is always TRUE so my code execute step 3 before the document are saved in the database.

    My code is entering in Before_Action = FALSE BEFORE SBO Event Handler save the document, but Action_Success is set to TRUE.

    What I'm doing wrong ??????????

    Add comment
    10|10000 characters needed characters exceeded

    • if(pVal.FormTypeEx == "THEFORM") {
        if(pVal.BeforeAction && pVal.ItemUID="1" && pVal.FormMode == (int)BoformMode.fm_ADD_MODE) {
          //Set the GUID
        }
      
        if(pVal.ActionSuccess && pVal.ItemUID="1" && pVal.FormMode == (int)BoformMode.fm_ADD_MODE) {
          //Use the GUID to get the DI-version of the object
        }
      }