This code below asks the user to select an advert by the advert ID using a picklist.
The UNID of the picked document is then retrieved using [ReturnDocumentUniqueID] .
Example code:
r:=@PickList([Custom]:[Single];"";"Adverts By ID";"Pick Advert";"Pick";1);
FIELD AdvertID:=@If(@IsError(r);"";r);
unid:=@DbLookup("";"";"Adverts By ID";AdvertID;1;[ReturnDocumentUniqueID]);
FIELD AdvertUnid:=@If(@IsError(unid);"";unid);
FIELD AuditTrail:=AuditTrail:(@Text(@Now;"T1")+" "+@Name([CN];@UserName)+" Advert="+r+")");
@Command([ViewRefreshFields]);
""
NB We are not actually requesting a column to be returned, so I pick the column 1.
In fact if you also use the other new option [FailSilent] you can reduce the code:
r:=@PickList([Custom]:[Single];"""Adverts By ID""Pick Advert""Pick"1);
FIELD AdvertID:=@If(@IsError(r);""r);
unid:=@DbLookup("";"";"Adverts By ID"AdvertID;1;[ReturnDocumentUniqueID]:[FailSilent]);
FIELD AdvertUnid:=unid;
FIELD AuditTrail:=AuditTrail:(@Text(@Now;"T1")+" "+@Name([CN];@UserName)+" Advert="+r+")");
@Command([ViewRefreshFields]);
""
The third @Dblookup option is [PartialMatch].
Using this in some operations may be dodgy, as it could return something unexpected or wrong, but I have thought of one use:
If you are searching for first name in a list, you could search for first few letters if the original search fails:
So if your user was searcing for "dave" and the only optin was david, after getting no results you could search for partial match and first 3 characters.