Generic Visual Script updating Business Objects
This is an interesting, but not an obvious subject. The situation is that we want a script to update a Business Object, let's say from a Process. That has been possible for some time using the 'Current' object. But let's say the requirements are that we want to update this from anywhere we are using it regardless of where the function is called from - ie a form or a process.
Those who are becoming familiar with the use of Business Objects will probably be aware that within a Process the Business Object is handled differently to that on a form. The main reason is that the form is not directly linked to the process, so we must create an instance of the Process BO. In the Process, the BO is already there. The most obvious difference is the 'name' of this object.
At first, the most obvious approach when creating a function to pass the BO to is to pass the form object like so:
public static void SetupDefaults(Metastorm.Runtime.Models.TestPassingBO.Form1 FormToUpdate)
FormToUpdate.T_PassingBOData1.Variable1 = "One";
FormToUpdate.T_PassingBOData1.Variable2 = "Two";
FormToUpdate.T_PassingBOData1.Variable3 = "Three";
And then pass the 'Current' object from the form.
This is in part because this was the only way we could do it in earlier versions, as passing other BO's was broken.
Now that this has been fixed at last (in 9.0.2, at least), we have the ability to use a Process BO properly, like so:
public static void SetupDefaults(Metastorm.Runtime.Models.TestPassingBO.T_PassingBO.Declarations.T_PassingBOData ProcessBO)
ProcessBO.Variable1 = "One";
ProcessBO.Variable2 = "Two";
ProcessBO.Variable3 = "Three";
In this way, we are perfectly able to pass the BO from a process, form, or wherever else it may be used.
I suspect strongly that we'll see a lot of the former approach being used in demonstrations and examples, which is a shame, as it is extremely limiting. This is the reason we were not at all happy with the workaround suggested of using the 'Current' object, although it was hard to explain why in detail.
The attached example is a demonstration of using the BO passed from a process and a form, to the fame function.