Transaction Id

raprohaska
Kilo Guru

Hello all,


I'm betting something already exists and I'm just not searching the correct text. I want every server request to generate a unique id that can be used in logging, that way we can show a standard error when there are processing issues to the user, which includes this generated transaction id. Then the admins can utilize that id to find logging related to the particular transaction.

My first thought was to use a global business rule that would set a session value that can be utilized in our standard logging script. But it seems that global business rules cannot be created anymore as I get an error stating that all code must exist in a function even though the code was all encapsulated in a function. It would only save once I picked a table value other than global.

Thanks for any ideas or suggestions you can give.

5 REPLIES 5

Michael Fry1
Kilo Patron

very server request to generate a unique id - how about using the sys_id? that's unique and would help get you to the ticket faster.


Though unique, it is not unique across multiple transactions.



For example:
User 1 saves a change that causes some newly deployed code to throw an exception, that we have caught, logged, and displayed a standard error message.


User 2 makes a change that causes some other exception, in some other area of the application. Again, we catch, log, and show standard error message.



Both users generate an incident. Depending on the length of time it takes to investigate the issue, there could be more logging done for the same ticket. When we go to look up the logs by Incident sys_id, we have to sift through any logs with that sys_id logged to it.



By having a unique transaction id, we could add that to the standard error message... maybe even give the user a link to auto generate an incident pushing the transaction id into the description. Then we can lookup just the logging associated to the that particular issue.





So that is my base business need, but lets expand. What if it is a transaction not triggered via a standard form. What if it comes from a UI page or a widget in Service Portal or maybe via a integration and is not tied to a single record. Again, if we have a transaction id, then we can include that in our logging and issue responses and can find logging for a specific transaction.



Having read this last bit, it clarifies even more that a business rule isn't the way to go. I need to generate the id at the very start of each process endpoint.


Just like the Number field is unique, what if you create a new field (like number) and use number maintenance to define number of digits, number to start at, then use Get Next Padded Number - that would generate a unique number?



Screen Shot 2017-08-02 at 11.28.46 AM.png


Its a good idea on how to generate a unique number and probably better than generating a GUID like I'm doing so far. The more difficult part is where to generate the number? I really need to intercept the request before any code is invoked so that the id is available no matter where the logger gets invoked. Thus I was hoping someone knew of an OOB id that I could leverage. I'm pretty sure there isn't one but wanted to ask. I'll probably just make it a coding standard that the beginning of each request generates a new id.



I will use the idea for generating a number, I like that. Much more user friendly.