Spweb.getListitem возвращает NULL в пользовательской деятельности рабочего процесса
-
16-10-2019 - |
Вопрос
Я создал пользовательскую деятельность рабочего процесса со следующим кодом:
namespace Custom.SharePoint
{
public class CustomActivity : Activity
{
#region Fields
public static readonly DependencyProperty __ContextProperty =
DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(WebServiceActivity));
public static readonly DependencyProperty AddressProperty =
DependencyProperty.Register("Address", typeof(string), typeof(WebServiceActivity));
public static readonly DependencyProperty StatusIdProperty =
DependencyProperty.Register("StatusId", typeof(string), typeof(WebServiceActivity));
#endregion
#region Properties
public WorkflowContext __Context
{
get { return (WorkflowContext)GetValue(__ContextProperty); }
set { SetValue(__ContextProperty, value); }
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Browsable(true)]
public string Address
{
get { return (string)GetValue(AddressProperty); }
set { SetValue(AddressProperty, value); }
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Browsable(true)]
public string StatusId
{
get { return (string)GetValue(StatusIdProperty); }
set { SetValue(StatusIdProperty, value); }
}
#endregion
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
var listItem = this.__Context.Web.GetListItem(this.__Context.CurrentItemUrl);
var requestId = listItem["RequestId"];
// rest of code removed for brevity
});
return ActivityExecutionStatus.Closed;
}
}
}
К сожалению, this.__Context.Web.GetListItem(this.__Context.CurrentItemUrl)
всегда возвращается ноль, хотя this.__Context.CurrentItemUrl
имеет допустимое значение (например, "http: // {name}/lists/{name} /dispform.aspx?id=9")
Я делаю что-то неправильно?
Решение
Мне никогда не повезло, используя spweb.getListitem ... Я использовал следующее в прошлом, когда я имел дело с объектами WorkFlowContext:
SPListItem item = __Context.Web.Lists[new Guid(__Context.ListId)].GetItemById(__Context.ItemId);
Должен сделать свое дело.
Не связан с sharepoint.stackexchange