RE: Agent - Doc opens several tabs and Code Made Easier Javier Alvarez 28.Apr.04 12:36 PM a Web browser Domino Designer -- LotusScript 5.0.1aWindows NT
First of all, I don't understand why do you have to refresh sysuidoc2 every time. If you change the backend document (sysdestdoc) it will be enough, since it is the only document you are using afterwards. In any case, you would have to refresh it only once at the end of the agent, and it will show the last values stored in the backend doc.
About your repetitive code, you could write a function passing it the parts marked XXXXXX below, since they are the ones that change from one piece of code to another, and call that function with the corresponding values each time:
Set item1 = doc2.GetFirstItem( "XXXXXX" )
GroupName2 = XXXXXX
For y = 0 To Ubound(XXXXXX)
For x = 0 To Ubound(GroupName2)
Set ChangeCDoc2 = UnicornDb.createdocument
ChangeCDoc2.Form = "ChangeControlD"
ChangeCDoc2.ChangeType = "Add"
ChangeCDoc2.ChangeStaff = XXXXXX
ChangeCDoc2.ChangeMailGroup = GroupName2(x)
ChangeCDoc2.ChangeDraft = "Yes"