Workflow Actions not associated with my DropDownList


Badge +1

Hi


I have two actions Accept/Decline I have associated them with my DropDownList but when i run it, the two actions do not appear on the dropdown list below is the code for doing the association:


protected

void DDLDecision_SelectedIndexChanged(object sender, EventArgs e)


{


if (DDLDecision.SelectedItem.Text == "Accept")


{


WorkflowActions(

"Accept");


}


else if (DDLDecision.SelectedItem.Text == "Decline")


{


WorkflowActions(

"Decline");


}


}


public void WorkflowActions(string Actions)


{


try


{


//Generate the Connection String for the K2 Server


SCConnectionStringBuilder cb = new SCConnectionStringBuilder();


cb.Host =

"centaurus";


cb.Port = 5555;


cb.Integrated =

true;


cb.IsPrimaryLogin =

true;


//Open the Worklist item and retrieve the SmartObject ID


//Connect to Workflow Server


wfConnection.Open(

"centaurus");


//Open the Worklist Item and retrieve the SmartObjectID


WorklistItem wiClientEvent = wfConnection.OpenWorklistItem(Request.QueryString["SN"].ToString());


wiClientEvent.Actions[Actions.ToString()].Execute();


}


catch


{


Response.Write(

"Error");


}


finally


{


//Close Connection


wfConnection.Close();


//now redirect to the workspace page


string[] Url = System.Web.Configuration.WebConfigurationManager.AppSettings.GetValues("TaskList");


//Response.Redirect(Url[0]);


}


}


 


I am confused as to why the actions do not appear in the DDL can anyone please help as I am about to go crazy


3 replies

Badge +6

Hi there,


I don't quite understand your problem based on the information you gave here. The method you posted does not contain any code to populate a dropdown list with actions, instead this is the code to execute the action. Even the code in this method you posted is quite strange. For instance you open a connection string builder object but then never use it? Also not sure what is the purpose of the initial "if" statement if you just need to execute the action.


Cheers,

Badge +6

The really simple version of what your code should look like is something like this:


protected void Page_Load(object sender, EventArgs e)
    {
        // create connection to the K2 server
        Connection con = new Connection();
        ConnectionSetup conSetup = new ConnectionSetup();
        conSetup.ConnectionString = "Integrated=True;IsPrimaryLogin=True;Authenticate=True;EncryptedPassword=False;Host=blackpearl;Port=5252";
        con.Open(conSetup);
        // open the work list item
        WorklistItem wli = con.OpenWorklistItem(Request.QueryString["sn"]);
        // populate the actions in the drop down box.
        foreach (Action a in wli.Actions)
        {
            cboActions.Items.Add(a.Name);
        }
        con.Close();
    }


Hope that helps,


 

Badge +1

Hi,


Thank you it help me a lot


Regards 

Reply