Set a field to have like..all the values in my loop

I have some code, it copies the SendTo field into INetSendTo.Then, we do some processing, ending with a prompt which contains the Internet mail address…

The field INetSendTo needs to be set to all the values that are returned by the Prompt, e.g. the prompt appears once for each email address: and I want to put these email address’s into a field…this doesn’t work:

@If(INetSendTo!=“.”;“”;

@Do(

@SetField(“INetSendTo”; SendTo)));

FIELD SendTo:=SendTo;

n := 1;

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

database := @Subset(@DbName; -1);

server := @Name([CN]; @Subset(@DbName; 1));

noteslookup:=@If(server=“”;

@DbLookup(“Notes”:“”; “”:NAMES.nsf;“People”;@Name([CN];SendTo[n]);“InternetAddress”);

@DbLookup(“Notes”:“”;“85255F7E:006775B0”;“($NamesFieldLookup)”; @Name([CN];SendTo[n]);“InternetAddress”));

Addr821:=@If(@Contains(SendTo[n];“CN=”);

noteslookup;

@Name([Address821];SendTo[n]));

ABSendTo:=@If(@Contains(Addr821;"@companyname.com");Addr821;INetSendTo[n]);

FIELD INetSendTo := INetSendTo : INetSendto[n];

@Prompt([Ok];“Email” + @Text(n); "The external email is " + ABSendTo + “.”);

n := n + 1)

Its this line thats not working:

FIELD INetSendTo := INetSendTo : INetSendto[n];

But how to fix, almost need to append to a field using formula?

Subject: Set a field to have like…all the values in my loop

What do you mean it’s not working? Are you getting an error? What are you expecting to see given a before and after case?

Are you trying to REPLACE the value in the array with the values you looked up?

Then you could just do a InetSendTo[n] := AbsentTo;

Alternatively I would have guess you wanted:

FIELD INetSendTo := INetSendTo : ABSendTo;

You sure you want to keep append INetSendTo to iteself?

If INetSendTo was

“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”

After each loop you look them up you list is going to grow exponetially

First Pass

“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:(1st new value)

Second Pass:

“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:(1st new value):“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:(1st new value):(2nd new value)

Third Pass

“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:(1st new value):“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:(1st new value):(2nd new value):“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:(1st new value):“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:“Bob/DIV/ORG”:“Jane/DIV/ORG”:“Tom/DIV/ORG”:(1st new value):(2nd new value):(3rd Value)

Oh and maybe move the database and server lookup outside your loop to save some time:

@If(INetSendTo!=“.”;“”;

@Do(

	database := @Subset(@DbName; -1);

	server := @Name([CN]; @Subset(@DbName; 1));

	@SetField("INetSendTo"; SendTo)));

	FIELD SendTo:=SendTo;

	n := 1;

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

		noteslookup:=@If(server="";

			@DbLookup("Notes":""; "":NAMES.nsf;

			"People";@Name([CN];SendTo[n]);"InternetAddress");

			@DbLookup("Notes":"";"85255F7E:006775B0";"

			($NamesFieldLookup)"; @Name([CN];SendTo[n]);"InternetAddress")

		);



		Addr821:=@If(@Contains(SendTo[n];"CN=");

				noteslookup;

				@Name([Address821];SendTo[n])

		);



		ABSendTo:=@If(@Contains(Addr821;"@companyname.com");

					Addr821; INetSendTo[n]);

		FIELD INetSendTo := INetSendTo : INetSendto[n];



		@Prompt([Ok];"Email"  + @Text(n); "The external email is " + ABSendTo + ".");

		n := n + 1

	)

)

Subject: RE: Set a field to have like…all the values in my loop

Steve,Thanks for your response.

Apologies if I wasn’t clear, posted after a long day at work…

What I want is a list of names, like this:

someone@company.com, someoneelse@company.com, athirdperson@company.com.

I’ll take your advice re: the database and server thing, not sure it will make much difference as the command is based on the database you have open…

Anyway, I fixed the problem, sorry I don’t have the code, (at home now), but essentially,

I included a @Set command to set a temporary variable within the loop, something like:

@Set(“VariableName”;VariableName + @Newline + AbSendTo)

Then, outside the loop,

e.g after the while finishes,

I set the field I think it was something like:

@SetField(“INetSendTo”,@Explode(VariableName)

This seems to acheive my desired result (I wont say “work”!!) e.g. then the field gets set to:

someone@company.com, someoneelse@company.com, athirdperson@company.com.

With each entry being a seperate element in a list (just like it does sometimes when sending an email, though not other times, even IBM cannot really explain it to me!!!)

Thanks any

GND