当前位置:主页 > Office办公 > SharePoint列表视图

SharePoint列表视图

SharePoint 列表视图修改多行文本字段显示长度
SharePoint 列表视图修改多行文本字段显示长度

最近有这么个需求,用户希望在所有项目视图显示多行文本字段,然后,又不希望显示的过场,也就是处理一下长度。  一开始就想到用js的方式去处理,偶然间发现还可以用jslink,尝试了一下,非常好用,分享给大家。  完整代码// List View - Substring Long String Sample // Muawiyah Shannak , @MuShannak (function () { // Create object that have the context information about the field that we want to change it's output render var bodyFiledContext = {}; bodyFiledContext.Templates = {}; bodyFiledContext.Templates.Fields = { // Apply the new rendering for Body field on list view "Body": { "View": bodyFiledTemplate } }; SPClientTemplates.TemplateManager.RegisterTemplateOverrides(bodyFiledContext); })(); // This function provides the rendering logic function bodyFiledTemplate(ctx) { var bodyValue = ctx.CurrentItem[ctx.CurrentFieldSchema.Name]; //This regex expression use to delete html tags from the Body field var regex = /(<([^>]+)>)/ig; bodyValue = bodyValue.replace(regex, ""); var newBodyValue = bodyValue; if (bodyValue && bodyValue.length >= 100) { newBodyValue = bodyValue.substring(0, 100) + " ..."; } return "<span title='" + bodyValue + "'>" + newBodyValue + "</span>"; }   后来,用户又希望鼠标点击缩略文档的时候,能显示所有内容,天啊,满足客户需求,毕竟,客户就是上帝!!!  简单的改了一下默认脚本的return的值,如下:return "<div onclick='changeShow(this)'><span style='display:none;'>" + bodyValue + "</span><span style='display:block;'>" + newBodyValue + "</span></div>"; 然后,再加一个切换效果的脚本,如下:function changeShow(obj) { var spans = $(obj).find("span"); if(spans[0].style.display == "none") { spans[0].style.display = "block"; spans[1].style.display = "none"; } else { spans[0].style.display = "none"; spans[1].style.display = "block"; } }   这样,就满足用户单击可以切换缩略文本和完整文本的功了。  运行效果

300 次浏览
SharePoint Set-SPUser 命令拒绝访问 问题解决
SharePoint Set-SPUser 命令拒绝访问 问题解决

最近碰到一个问题,由于User Profile Service服务有问题,用户信息无法更新。所以,想到Set-SPUser命令可以更新,于是乎找到这个命令,但是更新的时候发现拒绝访问的错误。找了很久原因,发现需要设置一下权限,不知道是否还会有人遇到类似的问题,记录一下分享给大家。  参考链接可能需要梯子,如果无法访问的同学了解一下。· Solution:  Add a web application user policy with Full control for the Farm Administrator who runs the Script! 

293 次浏览
How to Limit NodeRunner.exe High Memory, CPU Usage
How to Limit NodeRunner.exe High Memory, CPU Usage

roblem: NodeRunner.exe is consuming a lot of memory and CPU resulted in performance issues on SharePoint 2013 server.Solution: NodeRunner.exe is a SharePoint 2013 Search service component and it is resource hungry. To reduce the CPU and Memory impact of this process, follow below steps:Step 1: Reduce the CPU impact of the search service By default SharePoint search uses "maximum" to speed up its search crawling process. To reduce the CPU usage of the search service, run this PowerShell script from any one of your SharePoint 2013 server:Set-SPEnterpriseSearchService -PerformanceLevel Reduced This sets Search Service Application crawl component to use less number of threads.Step 2: Limit the NodeRunner.exe's Memory usage: Step 3: Restart Search Service For the above steps to take effect, You have to restart SharePoint 2013 search service. Go to Services console, restart SharePoint Search Host Controller process. Or use the PowerShell cmdlet to restart Search host controller process:Restart-Service SPSearchHostController The downside of the above changes: Since you are restricting resources to SharePoint search service, it increases search crawl time! PowerShell to Set NodeRunner config:

327 次浏览
SharePoint  workflows stop working (Failed on started.)
SharePoint workflows stop working (Failed on started.)

最近,使用工作流的时候碰到了一个问题,突然间所有工作流都无法启动,报错Failed on started. 同时,工作流内部报错,工作流被系统账号取消了。  查了很久,发现系统打了windows server security patches造成的,有两种方法可以解决。  原因  问题的原因就是我们工作流的很多依赖项,在安装了这个安全补丁以后,需要在web.config中进行授权信任。  方法一   很简单,卸载打的补丁。KB4457916/4457035  方法二  修改每一个前端服务器中,每个web application下的配置文件。  配置文件路径一般在:C:\inetpub\wwwroot\wss\VirtualDirectories\Port  SharePoint 默认工作流需要添加:

287 次浏览
Fix "Drives are running out of free space" Error in SharePoint Health Analyzer
Fix "Drives are running out of free space" Error in SharePoint Health Analyzer

最近帮助用户做健康检查,用户发现事件查看器(EventView)里面有很多错误,有一个就是"Drives are running out of free space",而且每小时就会出现一次。  其实,这些系统的警告,是可以在管理中心禁用的。  1.进入SharePoint管理中心,点击Monitoring - Review rule definitions;  2.找到我们这个错误,选中,在Ribbon菜单上点击编辑;  3.编辑的时候,把Enabled去掉,保存就可以了。  结束语  经过这样的修改,SharePoint的Timer Job就不会再检查这个错误,并且将错误写到事件查看器了。

287 次浏览
SharePoint JavaScript 更新用户和组字段
SharePoint JavaScript 更新用户和组字段

最近,需要更新列表字段,字段的类型是用户和组,so写了这么一段代码 复制代码 function updateUserField(){ var ctx = new SP.ClientContext.get_current(); var list = ctx.get_web().get_lists().getByTitle('My List'); var item = list.getItemById(1);//Item Idvar assignedToVal = new SP.FieldUserValue(); assignedToVal.set_lookupId(12);//User Id in the site collection item.set_item("AssignedTo",assignedToVal);//AssignedTo is a column name item.update(); ctx.executeQueryAsync( function() { console.log('Updated'); }, function(sender,args) { console.log('An error occurred:' + args.get_message()); } ); } ExecuteOrDelayUntilScriptLoaded(updateUserField, "sp.js");

285 次浏览
SharePoint 读取内容的插件之SharepointPlus
SharePoint 读取内容的插件之SharepointPlus

最近,一直在前端和SharePoint进行交互,然后,发现一个好用的插件,分享给大家。  首先,需要添加一个引用,如下图:  当然,我这里只是举个例子,亲们一定要去下载这个库,然后传到服务器或者文档库中进行引用,而不是添加下面一行代码就行的【新手必读,老手忽略之】;<script type="text/javascript" src="sharepointplus-5.1.min.js"></script>  然后,添加JQuery库,因为很多时候和DOM进行交互,会比原生的JavaScript方便很多。  最后,就可以使用SharePoint Plus插件了。  举个简单的例子,如何获取数据: 复制代码 // with some fields and an orderby command $SP().list("ListName","http://www.mysharepoint.com/mydir/").get({ fields:"Title,Organization", orderby:"Title DESC,Test_x0020_Date ASC" }).then(function(data) { for (var i=0; i<data.length; i++) console.log(data[i].getAttribute("Title")); });复制代码  插件还有很多其他的功能,大家可以参考下面的链接,里面有例子;

327 次浏览
SharePoint REST 上传文件请求403错误
SharePoint REST 上传文件请求403错误

最近,需要在SharePoint上传文件到文档库,但是,上传的过程报错了。错误代码 { "error": { "code": "-2130575251, Microsoft.SharePoint.SPException", "message": { "lang": "en-US", "value": "The security validation for this page is invalid and might be corrupted. Please use your web browser's Back button to try your operation again." } } }操作就是调用SharePoint Plus 添加文档https://aymkdn.github.io/SharepointPlus/files.html#createFile有兴趣的可以看一下这个插件,本来以为是插件的问题,后来发现并不是。发现插件在执行这个方法的时候,其实是Call REST Service。然后,调用了REST API上传,也是报一样的错误。后来发现,是Request Digest token需要刷新一下: 复制代码 $.ajax({ url: _spPageContextInfo.webAbsoluteUrl + "/_api/contextinfo", method: "POST", headers: { "Accept": "application/json; odata=verbose"}, success: function (data) { $('#__REQUESTDIGEST').val(data.d.GetContextWebInformation.FormDigestValue) }, error: function (data, errorCode, errorMessage) { alert(errorMessage) } });复制代码

310 次浏览
SharePoint PowerShell SendEmail
SharePoint PowerShell SendEmail

最近碰到这样一个需求,用户需要个简单的定时邮件提醒,就是抓取SharePoint某个列表里的值,然后作为邮件地址/邮件主题/邮件内容发送出去。  自己想了想,既然用户要求每天定时发送,那么肯定是任务计划,这样使用PowerShell是最方便不过的。  SharePoint 发送邮件的方法很简单,就是利用自带的SendEmail()方法就可以了,这里,我们用PowerShell调用Net方法SendEmail()来发送邮件。  首先就是邮件头部信息,包括邮件地址 主题和内容,如下:  //这是我的网易邮箱,有SharePoint项目或者机会,都欢迎联系我,哈哈   $email = "linyu_s@163.com"      $subject = "XXX Application Approval Notification"   $body = "balabalabala...."  然后,就是打开SharePoint站点:  $site = New-Object Microsoft.SharePoint.SPSite "http://workflow-platform/sites/xxx"   $web = $site.OpenWeb()  最后,就是去发送邮件了:  [Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($web,0,0,$email,$subject,$body)  结束语

315 次浏览