Tips Tricks Samples

Convert Domino UniversalID into a GUID

Just about the simplest bit of LotusScript ever but one I use again and again. It converts a UNID (32 character hex string) into a GUID (for use in SQL Server in my case but pretty universal).

Function convertUNIDToGUID(strUNID) As String
  Dim strGuid As String
  If Instr(strUNID, "-") = 0 Then
    strGuid = Mid$(strUNID, 1, 8) & "-"
    strGuid = strGuid & Mid$(strUNID, 9, 4) & "-"
    strGuid = strGuid & Mid$(strUNID, 13, 4) & "-"
    strGuid = strGuid & Mid$(strUNID, 17, 4) & "-"
    strGuid = strGuid & Mid$(strUNID, 21)
  End If
  convertXRDominoIDToGUID = strGuid
End Function