zoukankan      html  css  js  c++  java
  • SharePoint 2013 Sandbox Solution

    昨天在写SharePoint EventReceiver的时候遇到一个问题,创建了一个local farm SharePoint solution,添加了一个ItemAdded(SPItemEventProperties properties)事件,更新field name为Workflow的value。

    public override void ItemAdded(SPItemEventProperties properties)
            {
                base.ItemAdded(properties);
                if (properties.AfterProperties["Workflow"] != null)
                {
                    string value = properties.AfterProperties["Workflow"].ToString();
                    if (!string.IsNullOrEmpty(value))
                    {
                        properties.ListItem["Workflow"] = string.Empty;
                        properties.ListItem.SystemUpdate();
                    }
                }
            }
    

    上传已包含custom field为Workflow的office file,发现properties.AfterProperties["Workflow"]这个field value一直是空。百思不得其解,向大神求教。

    大神还是很热心的,下面是回复的内容:

    I did a test and found that the property will be added when the file saved to the document library, here is our steps and some codes, please point out if we have some settings different from your enviroment:

      1、Create 2 Document libraries(LibA and LibB),both of  them contain one column field name "SyncType"

      2、Create a Document in office Client, upload it to LibA ,and set the SyncType to 1

      3、Now web download the file, open it in office client, click File->Show All Properties in the right bottom, we can see this property

      4、Now we created a project, I used sandboxed solution, add an Event Receiver,and I used the following codes to proceed the action(get value and reset it):

     

    public override void ItemAdded(SPItemEventProperties properties)
            {
                base.ItemAdded(properties);
                try
                {
                    var value = properties.AfterProperties["SyncType"].ToString();
                    if (!string.IsNullOrEmpty(value))
                    {
                        properties.ListItem["SyncType"] = string.Empty;
                        properties.ListItem.SystemUpdate();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
    

      5、Then I click the document I uploaded to LibA, then select open it in office client, then File->Save As, save it to the LibB,and seems everything works fine.

      please let us know if we missed something.

    以上是大神回复的大部分内容,瞬间被大脸,怎么回事,为什么在我这里不好用,大神确认证成功。经过昨天一下午不懈努力,终于发现了问题所在,原来是solution type的原因,sandbox solution确实可以,但是local farm solution 存在这个问题。

    下面是我重现的步骤,本人也是第一次创建sandbox solution,记录了一下过程

    1、创建一个sandbox solution,添加如上代码 

    2、Deployee solution,Site Setting->Web Designer Galleries ->Solution, check the Status is Actived

    3、Attach process,if the solution endpoint is not trigger, please End process SPUCWorkerProcess.exe then retry.

    果然,验证成功!

  • 相关阅读:
    联合索引和多个单列索引选择
    CentOS6.5 一台服务器同时安装多个Mysql数据库
    一次CentOS的服务器被攻击教训
    java版本的memcache静态化
    mysql存储空间满的处理方式
    MariaDB 10.0 和 MariaDB 10.1 存储过程中 PREPARE FROM EXECUTE 区别
    CentOS6.x 优化脚本
    Mysql 使用 “LOAD DATA INFILE”需要注意的问题
    Mysql 日期类型比较 TIMESTAMPDIFF
    CentOS6.x 源码安装Nginx
  • 原文地址:https://www.cnblogs.com/qindy/p/6427511.html
Copyright © 2011-2022 走看看