Process Mapping Logo

Process Mapping - Articles

A Process of Improvement. An Outcome of Excellence.

Reuse complex forms in different Processes

OK, so we've built some really nice and deeply complex forms. We suddenly realise that we want to use them in another Process. Should be easy after everything we've been told, right?

Well, no, not exactly. What we have probably done with all those complex and descriptive Visual Scripts is use the Process Variables. Now we want to use different Process Variables. How are we going to do that?

We could just write a whole load of separate C# scripts and call them instead of using in-line Visual Scripts. That is the 'version 7' way, if you like, and we could do that there too. We then lose the benefits we get from Visual Scripts, which may be too much of a cost. We also then have two components (or more) to maintain, and ensure that changes between all are synchronised. Wouldn't it be nice to just have the one?

Well, we can, in a couple of relatively easy steps.

1. Replace all Process variables with (preferably identical) Local variables.

2. Set these Local variables from the Process Variables on load.

3. Set the Process Variables from the Local variables on saving.

Phew, seems like a tall order, and it is tiresome (so plan ahead in future!), but it is not difficult. To test all references really are Local, comment out the assignment code on form load and save, remove the Process Business Object and validate the Project. Any missed references will be either lost (so save before doing this) or cause an error.

Next we can add the original Business Object, and another Process Business Object. I'll call them Process1 and Process2 in fine Dr Seuss style.

We can then set the variables on load thus:

Quote:

if ( ProcessContext.ProcessName == "Process1")

{

Local.Variable1 = Process1Data1.Variable1;

Local.Variable2 = Process1Data1.Variable2;

... etc

}

else if ( ProcessContext.ProcessName == "Process2")

{

Local.Variable1 = Process2Data1.Variable1;

Local.Variable2 = Process2Data1.Variable2;

... etc

}

And on save:

Quote:

if ( ProcessContext.ProcessName == "Process1")

{

Process1Data1.Variable1 = Local.Variable1;

Process1Data1.Variable2 = Local.Variable2;

... etc

}

else if ( ProcessContext.ProcessName == "Process2")

{

Process2Data1.Variable1 = Local.Variable1;

Process2Data1.Variable2 = Local.Variable2;

... etc

}

And it is done.

Note that even though we have two Business Objects on the form, one for each Process, only the 'right' Business Object will be filled as the other one (or more) will have no valid data as the Folder Id does not exist in that Process. As such, there is no danger of overwriting data or any real performance hit.

Note also that this can be done for any number of Process in the same form.