Skip to main content
Nintex Community Menu Bar

Succeding Rule

  • August 1, 2006
  • 7 replies
  • 15 views

Forum|alt.badge.img+3
Hi

I have an activity that must only succeed if the field "ManagerApproval" is set to true in both slots.

I've set the number of slots available to 2, but every time I do the workflow I go to the next activity just with one "ManagerApproval" set to true...

Can any one help me with this?

Thanks in advance.

Ricardo Carvalho

7 replies

Forum|alt.badge.img+11
  • Nintex Employee
  • August 1, 2006
And what does your Succeeding rule look like?

Regards,
Ockert

Forum|alt.badge.img+3
  • Author
  • August 1, 2006
looks like this

public void Main(ref SucceedingRuleContext K2) {
K2.SucceedingRule = false;
if ( (Func1(ref K2) == true) )
K2.SucceedingRule = true;
else
K2.SucceedingRule = false;
}

private bool Func1(ref SucceedingRuleContext K2) {

string strTemp1;
string strTemp2;
string strTempLD;
object firstVariable;
object secondVariable;
object LogicalData;


secondVariable = "true";
int Counter = 0;
foreach (ActivityInstanceDestination ActInstDest in K2.ActivityInstance.Destinations)
{
firstVariable = K2.ProcessInstance.DataFields["ManagerApproval"].Value;
if (firstVariable.ToString().ToUpper() == secondVariable.ToString().ToUpper())
Counter += 1;
}
if (Counter == K2.ActivityInstance.Slots)
{
return true;
}
else
{
return false;
}
}

Forum|alt.badge.img+11
  • Nintex Employee
  • August 1, 2006
Your problem lies in the fact that you are comparing a process-level datafield "ManagerApproval" = true. You should change your Succeeding Rule to validate against an Activity level datafield.

Remember, there exists only one instance of any process level datafield at any point in time whereas a separate Activity level datafield instance exists for each destination user - for as long as the Activity "lives".

Hope this makes sense,
Ockert

Forum|alt.badge.img+3
  • Author
  • August 1, 2006
It sure makes sence.

The question is:
How do I do that?

That was my first ideia, to use something like:
K2.ProcessInstance.DataFields["ManagerApproval"][0].Value

where the [0] was the number of slots...

Forum|alt.badge.img+11
  • Nintex Employee
  • August 1, 2006
You need to:
1. Declare the datafield on Activity level i.e. Right-click on Activity in K2.net Studio | Properties | Datafields | Add;
2. Change your Succeeding Rule to use this Activity level datafield i.e. the line "firstVariable = K2.ProcessInstance.DataFields["ManagerApproval"].Value;" should become something like: "firstVariable = ActInstDest.DataFields["ManagerApproval"].Value;"
3. Export your process to K2.net Server.
4. Change your client event to manipulate this 'just created' Activity level datafield instead of the process level datafield.
5. Test

Regards,
Ockert

Forum|alt.badge.img+3
  • Author
  • August 1, 2006
How do I create a instance of a ActivityInstanceDestination?

Can it be done by the Connection on the k2 dll?

ProcessInstance _myProcessInstance = _myConn.OpenProcessInstance(Convert.ToInt32(_myInstanceID));
ActivityInstanceDestination _myActivityInstance =
for(int i=0 ; i<_myActivityInstance.DataFields.Count; i++)
{
_myActivityInstance.DataFields.Value= _myHash[_myActivityInstance.DataFields.Name.ToString()];
}

Forum|alt.badge.img+3
  • Author
  • August 1, 2006
Ok.

All done.

I just used the worlistItem to get the ActivityInstanceDestination

Like this:

WorkListItem.ActivityInstanceDestination.DataFields

Them after puting the succeding rule with the activity instance instead of a process instance all worked just fine.

Thanks a lot.