Example #1
0
        public SPWorkflowCollectionInstance GetItemWorkflows(SPListItemInstance item, object filter)
        {
            if (item == null)
            {
                throw new JavaScriptException(this.Engine, "Error",
                                              "An instance of a SPListItem object must be supplied as the first argument.");
            }

            SPWorkflowCollection result;

            if (filter == Undefined.Value)
            {
                result = m_workflowManager.GetItemWorkflows(item.ListItem);
            }
            else
            {
                var wf = filter as SPWorkflowFilterInstance;
                if (wf == null)
                {
                    throw new JavaScriptException(this.Engine, "Error",
                                                  "An instance of a SPWorkflowFilter object must be supplied as the second argument.");
                }
                result = m_workflowManager.GetItemWorkflows(item.ListItem, wf.SPWorkflowFilter);
            }

            return(result == null
                ? null
                : new SPWorkflowCollectionInstance(this.Engine.Object.InstancePrototype, result));
        }