Monday, February 2, 2009

Should not Use SPUser variable in Wokflow

Hi if Error
" Could not create activity of type 'MXKnowldgeObjectWorkflow.Workflow1'. System.NullReferenceException: Object reference not set to an instance of an object.
at MXKnowldgeObjectWorkflow.Workflow1..ctor() C:\Documents and Settings\Administrator.MOSS\My Documents\Vikash\MXKnowldgeObjectWorkflow\MXKnowldgeObjectWorkflow " The Compile Time Error , so just remove the SPUser variable form your workflow Code and to find the Current Person in the Workflow use the follwoing code snippit
i got this code from the Net , i'll let u know abuot the devlopper who has given this code

private string GetTheCurrentUser()
{
string ModifiedbyUserName = Convert.ToString(workflowProperties.Item.GetFormattedValue("Modified By"));
string[] strChar = { "ID=" };

string[] strChars = ModifiedbyUserName.Split(strChar, StringSplitOptions.None);

Int32 iUserID = Convert.ToInt32(strChars[1].Substring(0, strChars[1].IndexOf("\"")));
return iUserID.ToString();
}