6

Trong trình soạn thảo quy trình làm việc của nhà thiết kế Sharepoint, tôi muốn lấy tên người dùng/tên của người khởi tạo luồng công việc (tức là người đã khởi động nó hoặc kích hoạt luồng công việc) - điều này tương đối dễ sử dụng các sản phẩm của bên thứ ba như Nintex Workflow 2007 (nơi tôi sẽ sử dụng một cái gì đó như {chung: Initiator}) - nhưng tôi dường như không thể tìm thấy bất kỳ cách nào ra khỏi hộp để làm điều này sử dụng thiết kế điểm chia sẻ và MOSS 2007.Trong trình soạn thảo quy trình làm việc của nhà thiết kế của người chia sẻ hơn, làm thế nào để tôi nhận được tên người dùng của trình khởi tạo công việc?

cập nhật

Nó không trông giống như tính năng khá rõ ràng này được hỗ trợ OOTB, vì vậy tôi đã kết thúc bằng cách viết một hoạt động tùy chỉnh (như được đề xuất bởi một trong các câu trả lời). Tôi đã liệt kê các mã hoạt động ở đây để tham khảo mặc dù tôi nghi ngờ có thể là một vài trường hợp này nổi xung quanh ra có trên blog vì nó là một giải pháp khá tầm thường:

public partial class LookupInitiatorInfo : Activity 
{ 
    public static DependencyProperty __ActivationPropertiesProperty = 
     DependencyProperty.Register("__ActivationProperties", 
     typeof(Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties), 
     typeof(LookupInitiatorInfo)); 

    public static DependencyProperty __ContextProperty = 
     DependencyProperty.Register("__Context", typeof (WorkflowContext), 
     typeof (LookupInitiatorInfo)); 

    public static DependencyProperty PropertyValueVariableProperty = 
     DependencyProperty.Register("PropertyValueVariable", typeof (string),  
     typeof(LookupInitiatorInfo)); 

    public static DependencyProperty UserPropertyProperty = 
     DependencyProperty.Register("UserProperty", typeof (string), 
     typeof (LookupInitiatorInfo)); 

    public LookupInitiatorInfo() 
    { 
     InitializeComponent(); 
    } 

    [Description("ActivationProperties")] 
    [ValidationOption(ValidationOption.Required)] 
    [Browsable(true)] 
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] 
    public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties __ActivationProperties 
    { 
     get { return ((Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties)(base.GetValue(__ActivationPropertiesProperty))); } 
     set { base.SetValue(__ActivationPropertiesProperty, value); } 
    } 

    [Description("Context")] 
    [ValidationOption(ValidationOption.Required)] 
    [Browsable(true)] 
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] 
    public WorkflowContext __Context 
    { 
     get { return ((WorkflowContext)(base.GetValue(__ContextProperty))); } 
     set { base.SetValue(__ContextProperty, value); } 
    } 

    [Description("UserProperty")] 
    [ValidationOption(ValidationOption.Required)] 
    [Browsable(true)] 
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] 
    public string UserProperty 
    { 
     get { return ((string) (base.GetValue(UserPropertyProperty))); } 
     set { base.SetValue(UserPropertyProperty, value); } 
    } 

    [Description("PropertyValueVariable")] 
    [ValidationOption(ValidationOption.Required)] 
    [Browsable(true)] 
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] 
    public string PropertyValueVariable 
    { 
     get { return ((string) (base.GetValue(PropertyValueVariableProperty))); } 
     set { base.SetValue(PropertyValueVariableProperty, value); } 
    } 

    protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) 
    { 
     // value values for the UserProperty (in most cases you 
     // would use LoginName or Name) 

     //Sid 
     //ID 
     //LoginName 
     //Name 
     //IsDomainGroup 
     //Email 
     //RawSid 
     //Notes 

     try 
     { 
      string err = string.Empty; 

      if (__ActivationProperties == null) 
      { 
       err = "__ActivationProperties was null"; 
      } 
      else 
      { 
       SPUser user = __ActivationProperties.OriginatorUser; 

       if (user != null && UserProperty != null) 
       { 
        PropertyInfo property = typeof (SPUser).GetProperty(UserProperty); 
        if (property != null) 
        { 
         object value = property.GetValue(user, null); 
         PropertyValueVariable = (value != null) ? value.ToString() : ""; 
        } 
        else 
        { 
         err = string.Format("no property found with the name \"{0}\"", UserProperty); 
        } 
       } 
       else 
       { 
        err = "__ActivationProperties.OriginatorUser was null"; 
       } 
      } 
      if (!string.IsNullOrEmpty(err)) 
       Common.LogExceptionToWorkflowHistory(new ArgumentOutOfRangeException(err), executionContext, 
                WorkflowInstanceId); 
     } 
     catch (Exception e) 
     { 
      Common.LogExceptionToWorkflowHistory(e, executionContext, WorkflowInstanceId); 
     } 

     return ActivityExecutionStatus.Closed; 
    } 
} 

Và sau đó dây nó lên với .action sau xml tệp:

<?xml version="1.0" encoding="utf-8"?> 
<WorkflowInfo Language="en-us"> 
<Actions> 
    <Action Name="Lookup initiator user property" 
ClassName="XXX.ActivityLibrary.LookupInitiatorInfo" 
Assembly="XXX.ActivityLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XXX" 
AppliesTo="all" 
Category="WormaldWorkflow Custom Actions"> 
     <RuleDesigner Sentence="Lookup initating users property named %1 and store in %2"> 
      <FieldBind Field="UserProperty" DesignerType="TextArea" Id="1" Text="LoginName" />    
      <FieldBind Field="PropertyValueVariable" DesignerType="ParameterNames" Text="variable" Id="2"/> 
     </RuleDesigner> 
     <Parameters> 
      <Parameter Name="__Context" Type="Microsoft.Sharepoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions" Direction="In"/> 
      <Parameter Name="__ActivationProperties" Type="Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties, Microsoft.SharePoint" Direction="In"/> 
      <Parameter Name="UserProperty" Type="System.String, mscorlib" Direction="In" /> 
      <Parameter Name="PropertyValueVariable" Type="System.String, mscorlib" Direction="Out" /> 
     </Parameters> 
    </Action> 
</Actions> 
</WorkflowInfo> 

Trả lời

2

Tôi không nghĩ rằng việc này có thể thực hiện trong SharePoint Designer ngoài hộp. Bạn có thể có thể viết một hành động tùy chỉnh để có được người khởi tạo, nhưng tôi không tin rằng nó được tiếp xúc thông qua giao diện dòng công việc SPD ở tất cả.

Điều tốt nhất bạn có thể làm là lấy người dùng đã tạo hoặc sửa đổi mục trong danh sách, nhưng điều này sẽ không xử lý các trường hợp luồng công việc được chạy theo cách thủ công.

+0

hiện được hỗ trợ trong SharePoint 2010 OOTB - xem câu trả lời của tôi bên dưới – Bkwdesign

1

Tôi có thể nghĩ về một giải pháp đơn giản nhưng không phức tạp cho giải pháp này bằng cách sử dụng SPD. Chỉ trong các bước dòng công việc tạo một mục thử nghiệm trong một danh sách thứ cấp (có thể là danh sách nhiệm vụ lưu trữ các thuộc tính workflowId và itemId để lặp lại) và sau đó thực hiện tra cứu trong luồng công việc của bạn trên danh sách đó để xem ai là tác giả của mục đó, giá trị sẽ là bộ khởi tạo dòng công việc hiện tại.

4

Đối với những người mà google vào bài viết này và hiện đang sử dụng SharePoint 2010, biến khởi tạo luồng công việc hiện được hỗ trợ OOTB trong SharePoint Designer.

Nguồn dữ liệu sẽ là "Ngữ cảnh công việc" và trường là, "Initiator" và bạn có thể chọn trả lại là "Tên hiển thị", "Email", "Tên đăng nhập" hoặc "User ID Số "

0

Giải pháp hoạt động tùy chỉnh chỉ hoạt động nếu bạn đang làm việc với rêu, nếu bạn chỉ có 3,0, bạn có thể đặt thêm một bước trong luồng công việc của mình và đặt trường nhận xét tùy chỉnh với bất kỳ thông tin nào để thay đổi và trở thành giống như bộ khởi tạo luồng công việc, thì bạn có thể sử dụng trường ModifiedBy để đưa ra bất kỳ quyết định nào mà bạn cần.