分享
 
 
 

使用LotusScript获得群组中的用户列表

王朝other·作者佚名  2008-05-30
窄屏简体版  字體: |||超大  

Declarations Dim count As Integer

Dim persons List As String

Dim groups List

Dim tg As Integer

Dim xy As Integer

Sub Initialize

'The advantate of this code is that we can process any nested groups without any size limitaions.

Dim session As New notessession

Dim ws As New notesuiworkspace

Dim uidoc As NotesUIDocument

Dim db As notesdatabase

Dim namesdb As notesdatabase

Dim groupdoc As notesdocument

Dim groupview As notesview

Dim insidegroupdoc As notesdocument

Dim insidegroups As notesview

Dim doc As notesdocument

Dim curview As notesview

Dim newlist List

Set db=session.CurrentDatabase

Set namesdb=session.GetDatabase(db.Server,"names.nsf")

Set groupview=namesdb.GetView("($Users)")

Set insidegroups=namesdb.getview("($VIMGroups)")

Set curview=db.getview("second")

Set uidoc=ws.CurrentDocument

Set doc=curview.getfirstdocument 'you can set your own doc here. This the backend document for the currently opened uidoc. You can find other alternatives to run this agent.

groupName$ =uidoc.FieldGetText("names") ' Here we are entering the group or person names.

Dim ritem As Variant

Set ritem = doc.GetFirstItem( "all" ) ' Here we are going to store the group extracted people's name

'Call uidoc.FieldSetText("saveoptions","1")

Call uidoc.FieldSetText("Total","") ' Here we will list the total participant list.

Call uidoc.FieldSetText("all","") ' making the field null to print a new value.

Call uidoc.Save

Call uidoc.reload

Call uidoc.save

Forall entry In doc.names

gtype=group(entry) 'Checking whether the entry is a group or People.

If gtype="Group" Then

tg=tg+1

groups(tg)=entry

Else

Call addtolist(entry) ' If entry is a person, then adding to a list called People.

End If

End Forall

'now we have got two lists one is person and another one is group

'This loop will returns you a list in the people's view. and remove the each group entry after processing.

xy=0

Do Until xy = tg

xy=xy+1

et=groupget(groupview,groups(xy))

Erase groups(xy)

Loop

If ( ritem.Type RICHTEXT ) Then

Exit Sub

End If

'Iam adding the list to another array, because iam not getting the list with unique values. You can try some other code if you can retruns the list as unique

Dim nar() As String

Forall nvals In Persons

newcount=newcount+1

Redim Preserve nar(newcount)

nar(newcount)=Persons(newcount)

End Forall

'Then make the array as unique

finarray=Arrayunique(nar,0)

'Now print the values one by one in an array. See if you want to process the contents of this rtfield.

' Use the item.values and split the values using newline. So you will get an array.

Forall fins In finarray

If fins "" Then

fin=fin+1

Call ritem.Appendtext(fins)

Call ritem.addnewline(1)

End If

End Forall

'This code will close the doc without saving and re-open it.

Call doc.ReplaceItemValue("Total",Cstr(fin))

Call doc.save(True,True)

doc.saveoptions="0"

Call uidoc.close

Call ws.EditDocument(False,doc)

'You can use the notesname class to format the contents and use the evaluate to sort the contents. The code you can get it from my 'Other agent in the same db.

End Sub

Function group(entry As Variant) As String

'Getting first 3 characters will give u an idea whether it is a group or person. In our case every user will have a heirarhical name. In your case you can use ur own code to get this info.

If Left(entry,3)="CN=" Then

group="Person"

Else

group="Group"

End If

End Function

Function addtolist(entry As Variant)

count=count+1

If Isarray(entry) Then ' In some rare cases by mistake or so we have two entries in a document. So run this check before proceed.

Forall ad In entry

persons(count)=ad

End Forall

Else

persons(count)=entry

End If

End Function

Function groupget(gview As notesview,entry As Variant) As String

'here first we are getting group name. Then get the group document and get the members for the group. Then add the person entries to Person array.

'Rest group entries will add to group list.

Set groupdoc=gview.GetDocumentByKey(entry,True)

If Not groupdoc Is Nothing Then

allentries=groupdoc.GetItemValue("members")

Forall ent In allentries

'Set pdoc=gview.GetDocumentByKey(entry,True)

If Left(ent,3)="CN=" Then

count=count+1

persons(count)=ent

Else

tg=tg+1

groups(tg)=ent

ab=ab+1

End If

End Forall

End If

End Function

,

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有