I’ve used a comparable formula in other databases for ‘normal’ text or numbers. Trying to use this for replacing Notes names in name fields, it failed. Could you tell me why?
FIELD N_Country:=@Replace(N_Country; “NameX”; “NameY”) ;
SELECT @All
Thank you very much in advance
Leini
Subject: @replace and names field does not work?
Code looks okay to me. I suspect the reason may be that N_Country does not equal “NameX”!
One gotcha to be aware of is that whilst Name fields display names in the abbreviated name format, they store them in the canonicalized format.
i.e.
Displayed as → joe bloggs/myOrg
Stored as → cn=joe bloggs/o=myOrg
Might be worth adding some prompts to your code to help debug it i.e.
@prompt([ok];“N_Country”;N_Country);
@prompt([ok];“Matches?”;@text(“NameX”=N_Country));
HTH - Rufus.
Subject: that’s it
Because it is a names field, it contains the full Notes name CN=…, but displayed is only the name without the CN=…If you want to replace the field values, you need to enter the full name text CN=…
Thank you for this solution, Rufus.
Leini
Subject: @replace and names field does not work?
@Replace replaces an entire element of a list which matches, and you want to replace just a substring. In addition, the name is stored in canonical format. I would suggest something closer to:
FIELD N_Country:=@ReplaceSubstring(N_Country; “C=NameX”; “C=NameY”) ;
SELECT @All
Subject: @replace and names field does not work?
Are you entering just the common name, the fully-distinguished abbreviated syntax, or fully-distinguished canonical syntax?
Subject: more details
In the field I use the address dialog box for entering the names, thus, they are entered not as full names (I mean starting with CN…), but in the form as if I would have used [Abbreviate]:first name last name/CWID/…
In the view I use this formula:
n:= @Name([CN];N_Spain);
@If(N_Spain =“”; “- ? -”; @Right(n;" “)+”, “+ @Left(n;” "))
in order to display only last name, first name.
In the Agent I uses the spelling like it is entered in the field - not as it is displayed in the view.
Thank you for your help
(and sorry for my late response)
Leini