Whil loop, names and setting a field value

Hi,I have an authors field on my document, unfortunately, I programmed it wrong, using:

@Name([Canonicalize];Person + “/”)

Its doing what it says in the help, meaning that, it gets set wrongly for people in different countries.

So. I am trying to create an agent to create this in some documents. The person field is a field containing someones name, with a CN formula to make it look nicer. I don’t want to change this field. You can select more than one name in it, in case someone was on holiday.

The problem I am having is with this code:

n := 1;

@While(n <= @Elements(Person);

t1:= Person[n];

t3:=@DbLookup( “Notes” : “Nocache” ; “85255F7E:006405B0”;“($NamesFieldLookup)”; t1 ; 3) ;

@Prompt([Ok];“”;t3);

@SetField(“gtAuthor”; @Text(t3));

n := n + 1);

SELECT @All

It is using a While loop, to look through the people in the Person field, one by one, looking up a field on the CAB which is containing there CN= name (full notes name for authors field).

But…the Prompt is getting set each time correctly:

Like:

“CN=Generic Notes Developer/OU=RG-Region/O=Company/C=CC”

But, the setfield is setting the field to a load of rubbish, like:

“CN=Generic Notes Developer/OU=RG-Region/O=Company/C=CC”

“Generic Notes Developer”

“Employee Number”

Why is this?

Subject: Forget it solution found click if want to see it!

There was a number of problems with the above:1) Although it looked like the value returned by @Dblookup was right (inside the prompt box), in fact the column contained extra information not displayed in the @Prompt, presumably because of either a length restriction or because of a seperator or some such.

Thus, I was returning the wrong value anyway, hence it was getting set;

  1. It seems its better to set the field outside of the loop, using temporary variable and @Explode. I am setting a field that has comma as multivalue seperator.

Here is the finished code if anyone is interested, I guess it might be useful if someone else makes the same mistake with cannnoncalize as me!

n := 1;

@While(n <= @Elements(Person);

t1:= Person[n];

t3:=@DbLookup( “Notes” : “Nocache” ; “85255F7E:006405B0”;“($NamesFieldLookup)”; t1 ; “Owner”);

@Prompt([Ok];“”;t3);

@Set(“TempVar”;

@If(TempVar=“”;t3;TempVar + “,” + t3));

n := n + 1);

@SetField(“gtAuthor”; @Explode(TempVar; “,”));

SELECT @All