cancel
Showing results for 
Search instead for 
Did you mean: 

Tip for how to get the new documents DocNumber in UI

rasmuswulff_jensen
Active Contributor
0 Kudos

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?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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 ??????????

rasmuswulff_jensen
Active Contributor
0 Kudos

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
  }
}
Former Member
0 Kudos

yeah!

Can we reward points for this very good ideas?

way to go Rasmus!

Harold

Former Member
0 Kudos

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