SharePoint社交功能
简介
SharePoint社交功能,使公司组织中的用户社会化协作。如相互提交、博客评论,我们这里实现用户相互提及。通过js代码实现用户间的通信,其中包括信息的类型为文字、超链接以及附件图标。
SharePoint中的操作类
Js编程Sharepoint中社交功能中,系统提供的操作类在SP.Social命名空间下,其下的方法有
1、 SocialFeedManager 创建一个线程用来发送消息,是消息的载体。
2、 SocialDataItem 确定要发送的的地方,可以为文档、超链接,这里只做提及某人。
3、 SocialPostCreationData创建通信的内容。
注意:提及到某人一般同PeoplePicker一起使用,通过用户的key提及到某人,这个的不清楚的可以看上篇博客。
SharePoint社交代码实现
<span style="font-size:18px;">function postToFeed() {
context=new SP.ClientContext.get_current();
var feedManager = new SP.Social.SocialFeedManager(this.context);
//指定要发送给谁
var createUserDataItem = new SP.Social.SocialDataItem();
createUserDataItem.set_itemType(SP.Social.SocialDataItemType.user);
createUserDataItem.set_text(person.DisplayText);
createUserDataItem.set_accountName(person.Key);
//指定超链接
var linkDataItem = newSP.Social.SocialDataItem();
linkDataItem.set_itemType(SP.Social.SocialDataItemType.link);
linkDataItem.set_text('google');
linkDataItem.set_uri('http://www.google.com');
//创建发送的数据
var postData = new SP.Social.SocialPostCreationData();
postData.set_contentText("你好:{0}。这是一个不错的网站:{1}");
postData.set_contentItems([createUserDataItem, linkDataItem]);
// 发送数据
var resultThread = feedManager.createPost(null, postData);
this.context.executeQueryAsync(onPostToFeedSuccess, onFail);
//发送成功执行的函数
function onPostToFeedSuccess(sender, args) {
alert('发送成功')
}
//发送失败执行的函数
function onFail(sender, args) {
alert('发送失败')
}
}</span>
总结
社交功能就这样简单的实现了,SharePoint还是一个不错的软件。你可以到新闻源中查看下是否发送成功。如有写的不妥之处希望之出。