如何以编程方式从工作流中的函数的url字段获取字符串值?

时间:2013-09-27 16:44:55

标签: c# sharepoint-2010 type-conversion sharepoint-workflow

我在运行工作流程时创建了一个文件夹,我想使用当前项目中的“Repository”字段,就像参数(当我想创建文件夹时这是一个位置),当为变量存储库分配一个静态链接时“ https:// site / teamSite /“有效,但在这种情况下失败。

private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
    {
        int item = onWorkflowActivated1.WorkflowProperties.ItemId;          

        SPFieldUrlValue fieldValue = new SPFieldUrlValue(SPContext.Current.Item["Repository"].ToString());
        string linkTitle = fieldValue.Description;
        string linkUrl = fieldValue.Url;          

        string repository = linkUrl;
        string ruta = "Shared Documents/Folder"+item;
        //string respository  = "https: //site/teamSite/"
        using (SPSite site = new SPSite(repository))           
        {
            using (SPWeb web = site.OpenWeb())
            {
                web.Folders.Add(ruta);
                workflowProperties.Item["Folder"] = repository+ruta;                   
                workflowProperties.Item.Update();  
            }
        }

    }

1 个答案:

答案 0 :(得分:0)

 private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
    {
        //Currente item
        int item = onWorkflowActivated1.WorkflowProperties.ItemId;
        SPItem current =  onWorkflowActivated1.WorkflowProperties.Item;    
        //Get url from field
        SPFieldUrlValue fieldValue = new SPFieldUrlValue(current["Repository"].ToString());
        string linkTitle = fieldValue.Description;
        string linkUrl = fieldValue.Url;            
        string ruta = "Shared Documents/Folder"+item;

        using (SPSite site = new SPSite(linkUrl))
        {
            using (SPWeb web = site.OpenWeb())
            {
                web.Folders.Add(ruta);
                workflowProperties.Item["Folder"] = linkUrl + ruta;                   
                workflowProperties.Item.Update();  
            }
        }

    }