Pregunta

Creé una actividad de flujo de trabajo personalizado con el siguiente código:

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;
        }
    }
}

Desafortunadamente, this.__Context.Web.GetListItem(this.__Context.CurrentItemUrl) siempre devuelve nulo, aunque this.__Context.CurrentItemUrl tiene un valor válido (por ejemplo, "http: // {nombre del servidor}/lists/{name de la lista} /dispform.aspx?id=9")

¿Estoy haciendo algo mal?

¿Fue útil?

Solución

Nunca he tenido suerte usando spweb.getListItem ... He usado lo siguiente en el pasado al tratar con los objetos de flujo de trabajo de trabajo:

SPListItem item = __Context.Web.Lists[new Guid(__Context.ListId)].GetItemById(__Context.ItemId);

Debería hacer el truco.

Licenciado bajo: CC-BY-SA con atribución
scroll top