How to convert Notes document link to HTML link - lotus-notes

I am charged with maintaining some old code, in which we are extracting a Notes link from a message, and turning it into a link that can be called from HTML on a local machine (on which Notes is installed). We have a situation where one link works, and another one does not.
I am struggling to understand what exactly this code is doing, and why it even works in the first place. Basically, we are looking at the property "$Links" in an email message. The value of this property, for example, when viewed in Notes, is something like:
RFC2257F23:004852B9
VFA5208C4C:6552DA01-VN422569FB:003AAC2D
NF6D24A297:6579B8E3-NNC225805D:004D8678
What our code does is get the binary value of this property, using NSFItemInfo and OSLockBlock. It then starts at offset 11, and works backwards 8 bytes, converting each byte to a 2 digit hex value. Then it does the same thing 3 more times, but moving the offset 8 bytes forward from the original 11. A '/' character is inserted after the 1st and 3rd of these 8 byte segments. Then the whole thing is appended to "notes:///". At the end, the link generated looks like this:
Notes:///C2257F23004852B9/A5208C4C6552DA01422569FB003AAC2D/6D24A2976579B8E3C225805D004D8678
I'm guessing that this value represents the Notes UNID of the document link, and that when clicked on, Notes
starts up, and goes directly to the document. So does anyone have an idea as to why one link would work, and
the other fail? Our customer claims that the Notes links database is intact, and can be viewed successfully
from within Notes itself.

Notes- Links consist of the protocol, a server part, a database part and the element within the database.
A normal example would be:
notes://server/path/database.nsf/view/keytodocumentinview
Every part (except the server) can be replaced by an internal ID.
path/database.nsf --> Replica ID (C2257F23004852B9 in your example)
view --> Universal ID of the design element of the view (A5208C4C6552DA01422569FB003AAC2D)
keytodocumentinview --> Universal ID of the document (6D24A2976579B8E3C225805D004D8678)
If there is no server in the link, then the notes client tries to "guess" the right server. It checks:
Is there an icon in the desktop for the Replica- ID requested. If yes: take the server of the last used replica (on the top if replicas are stacked)
Can I find a catalog.nsf (either on catalog- server from location document or on mail- home- server. If yes: Is the replica- id in there? If yes: Take the server from there...
Ask user for server (not sure about that part, as it not always seems to happen)
So the answer to your question is:
If the client can not find any reference to the server the link will not work.
So it is always better to add the right server to the link (if you know it).
Just to explain, how to get from one form to the other, here is some more explanation:
Some times these IDs are represented differently as found in the $Links- Item:
The first letter stands for the "Type" of ID:
R = Replica ID
V = View Universal ID
N = Note Universal ID
All 32Bit values are separated in 2 halfs of 16 bit, prepended by another Character telling "First" (F) or "Second" (=Next, N) value.
The rest is divided in chunks of 8 letters, the first and third octet separated with colons, and the first half and second half split by a minus sign.
Like that you can easily see:
RFC2257F23:004852B9 translates into FC2257F23004852B9
VFA5208C4C:6552DA01-VN422569FB:003AAC2D translates into A5208C4C 6552DA01 422569FB 003AAC2D
and
NF6D24A297:6579B8E3-NNC225805D:004D8678 translates into 6D24A297 6579B8E3 C225805D 004D8678

Related

"Query is not understandable (4000)" error on view refresh

I have the following two lines of code:
Set customerView = db.GetView ("(Lookup - Customers by Reference)")
Call customerView.refresh()
Very occasionally, the 2nd line will give users an Error 4000, Query is not understandable
Restarting Notes gets rid of it, but it sometimes comes back for a couple of users.
This has only recently started happening, and I've not made any changes to the view.
EDIT
To explain further, nowhere in the function that is throwing the error is there any code relating to a FT Search, which makes me think that this may be an error that IBM have stuffed up in R9.0.1
Check Forms and Fields (especialy fields!) you use in search formula of the view.
Maybe you search text value in non-text fields.
Fields are shared between forms, i.e field is unique not within form, field is unique within NSF. So, first time you create field - NSF writes it's properties (field type included) in NSF structure. And if you have two forms containing field with same name, but with different types (text and non-text) - you'll get this error.
I saw this error several times, and every time it was caused by FT-queries or search formulas what tries to search some text value in field, that initialy was created as non-text (date or numbers field).
If this is the case... Well, it's hard to get rid of this error. Basically you'll have to delete this field from every form and every document in nsf, then compact it using copy-style, then recreate field in right type and restore it's values in docs using right type - it helps usually.

Removing hotspots from body using Lotus notes C API

I am trying to remove hotspots from Note body using C API.
I know one way to do this:
1) NSFNoteOpen(hDb, noteId, 0 /*NO FLAGS*/, &hNote);
2) Enumerate allTYPE_COMPOSITE items, Keep appending all CD records in separate buffer except records between SIG_CD_HOTSPOTBEGIN and SIG_CD_HOTSPOTEND
3) remove this item and append newly created item.
4) NSFNoteUpdate(hNote, UPDATE_FORCE);
But problem is that, all Rich text infomations is lost
Is it possible to achieve the same when note is opened with
OPEN_RAW_MIME flag? There are no TYPE_COMPOSITE items in the note in this case.
Thanks
You need to determine the type of the Body field and act accordingly. I.e., if the Body is stored as TYPE_COMPOSITE, you already know what to do. But if the Body is stored as TYPE_MIME_PART, you need to use the Notes C API calls whose names all start with "MIME". You can find these functions listed in the Notes C API Reference. Here are a couple of blog posts that talk a bit about some related subjects.

How to build a facebook-like fast search by starting of words?

I have to build a search textbox in a web page similar to facebook search box. Client side there will be ajax calls. The user need to search into around 300.000 elements that have a description of a few words or an alphanumeric code. When user enters the beginning of a word, a call is made to the server which return best match based on the starting of any word or code but also suggest first the elements most recently by the user, then by the group the user belongs to and finally from the entire set. Result can be limited to 10-20 items.
How can I build a fast search by key with the value just the description of the element? We use SQL server but any other DB could be OK.
The implementation at the time was very complex to summarise here but I came across recently to UI-select that solve the front end problem nicely and it's very good component if you are using Angular
https://github.com/angular-ui/ui-select
then backend you can put whatever you have (I did with Redis)

Convert a alpha-numeric string into a gibberish barcode?

A container is identified with the label JA1234. This container should always go to destination A.
Another container is identified with the label 1234. The vast majority of containers are labeled this way and these always go to destination B.
(Note: The pool of containers constantly fluctates so we can't maintain a master list.)
The users can either scan/key in the container identifier. Many of the containers aren't barcoded so they need to type in the number. When it gets typed in the prefix 'JA' gets ignored and suddenly the programs error checks fail (allowing wrong destinations).
To prevent entry and to force barcoding I would like to require the program to scan a barcode. The only way to get the users to scan the barcode consistently is the provide a barcode in a gibberish (ie hexadecimal) format.
Is there a any built-in .NET framework feature that would convert the readable string into something unreadable that would require scanning? It would need to be reversible.
It sounds like you want the users to input the whole string always and you users are ignoring part of the string. To solve this you want the users to just use the barcode scanner.
But you really have three choices.
Only print out the barcode. They can't type what they can't see. However this is bad because if a barcode is damaged you won't be able to fallback to user entry
Encode it using something like System.Convert.ToBase64String. This is bad because then you'll have to print values like SkExMjM0 and MTIzNA== for JA1234 and 1234 which is easy to mistype when the users needs to type.
Use a check digit and append it to the string. You can then reject codes incorrectly entered or incorrectly read by the barcode scanner. The downside is there's nothing built in that can directly convert "JA2134" and you have to create your own check digit function.

NameLookup does not pull Phone number

I have 2 fields that looks for username, the gets the email address and phone number from user's person document.
Creator_Email: #NameLookup([NoUpdate]; #UserName; "OfficePhoneNumber")
Creator_Ext: #NameLookup([NoUpdate]; #UserName; "OfficePhoneNumber")
The problem is there is one user reported that the extension did not pull out. It came out blank
I have checked on the person document and the phone number is there
the email address pull out correctly, but when I tested changing the first letter of first and last name to lower case (ie. Test.User#domain.com to test.user#domain.com), the field that pulls the email address still show up with Upper case.
I have tried to take the user.id and test it on a different PC and the problem persists.
Any idea why this happens? I know there are 2 address books set up in the company and that is not ideal but I have checked the 2 address books and make sure all the needed information are there.
The #NameLookup formula does a look up to a hidden view on the database, and sometimes you run into a situation where the index for that view isn't up-to-date. You can go to the database and press CTRL+SHIFT+F9 to rebuild all the views, or you can try to use the FORCEUPDATE flag in your formula.
I think you'll find that the #NameLookup call is finding people who have created entries for themselves in their personal address books. If those entries are incomplete, the lookups will fail to find the missing fields.
The #NameLookup will use the parameter...
Go to /File/Preferences/Location then is the current location find the Server Tab and check that you defined Domino Directory server (if empty user search on local)
Check also in the Mail tab, Recipient Name lookup that could "stop after first march" or exhaustively search ALL the names known on the client.
In #NameLookup you can also use [NoUpdate]:[Exhaustive]
be aware as mention before that view may be not up to date, that caching can occurs in the #NameLookup.
In place of this, I suggest to use:
#DbLookup("":"";YourServer:"names.nsf" ; "($VIMPeople)" ; #Name([ABBREVIATE] ;#UserName) ; "OfficePhoneNumber");

Resources