Skip to main content

Hi there,


 I have a process that requires approval from 4 different departments. The approval takes place on 4 different InfoPath forms and sets the value of 4 different fields (created within InfoPath). I have 4 lines going into 1 data manipulation event with the following user defined code:


 If SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields  
  ("K2InfoPathSchema").Value,"my:myFields/my:TechnicalApproval") = "Approved" And _
  SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields
  ("K2InfoPathSchema").Value,"my:myFields/my:RetailApproval") = "Approved" And _
  SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields
  ("K2InfoPathSchema").Value,"my:myFields/my:CentralPlanningApproval") = "Approved" And _
  SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields
  ("K2InfoPathSchema").Value,"my:myFields/my:SitePlanningApproval") = "Approved" Then
       K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value =   
       SourceCode.K2Utilities.XMLFieldMod.SetXMLValue(K2.ProcessInstance.XmlFields
       ("K2InfoPathSchema").Value, "my:myFields/my:ProductApproval", "Approved")
End If


The line event from this then checks the value of 'ProductApproval', but the workflow completes without completing this last step.


I suspect that once the first approval is fired, it gets to the data manipulation event and terminates at the first try.
What would be the best way to achieve the result I'm looking for?


Many thanks.

Good day.


My understanding here is as follows:


you have 4 forms, to 4 departments. The approval step is made possible by 4 different activities, each activity with its own destinations. Then, those 4 activities flow to your 'decision' activity?


If this is the case,, preceding rule is definately the way to go, on the 'decision' activity - not on the last activty of the 4 approval activities.


The K2 help file has a solution for this scenario. In the 'index' search, search for preceding rule and follow the links to the code sample.


hth


Thanks for all your replies so far, but I still seem to be having problems.


I have tried the following methods:


- I have the 4 separate InfoPath forms activiies on which the approval for each takes place. From here I have 4 lines linking to a default client activity containing an email event. I have set a preceding event on the email activity to check the xml values stored from the InfoPath forms. This appears not to work once I introduce more than one value into the mix. OK, the first code sample below works, I get the email if the approval step is approved and I don't if it is declined.


K2.PrecedingRule =

False


If SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:TechnicalApproval") = "Approved" Then


K2.PrecedingRule =

True


End If


This second code sample does not send an email at all:


K2.PrecedingRule =

False


If SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:TechnicalApproval") = "Approved" And _


SourceCode.K2Utilities.XMLFieldMod.GetXMLValue(K2.ProcessInstance.XmlFields("K2InfoPathSchema").Value,"my:myFields/my:SitePlanningApproval") = "Approved"

Then


K2.PrecedingRule =

True


End If 


- I have also tried creating a data field on the InfoPath activity, setting the value using an event on this activity, then testing for the associated values on the email activity. However, the data fields I created do not appear in the list when writing the preceding rule on the email activity.


I am very new to K2 and must just be doing something very stupid.


Hi Faccenda


The process schema xml is being overwritten every time one of the activities is completed. A simple solution would be to create process level data fields and store the xml field values to the data fields every time a form is completed but I recommend you to approach our consulting services.



hth


Wessel


 


Reply