How do you use Runtime Models in Server Script?

I am writing a little C# script to check some data, and would like to use the nice strongly-typed Business Objects in my Server-side script.  I can't seem to figure this out though.

 

for example, if I have a process called "EmployeeIntake" then I can create an "EmployeeIntake" object, and it seems to have a Current Property as well as a sub-class of "EmployeeIntakeData".  I can'te seem to figure out how to properly use this to retrieve the data?  In particular I am trying to reference this in a process, where I want to retrieve the EmployeeIntake object for the current folder's parent.

 

If anyone has any example of how to properly use this, I would really appreciate your sharing it here.

 

Thanks,

 

Ryan

Tagged:

Comments

  • You are right, simple it aint. Having said that, it gets easier every time, and after a while becomes second nature.

     

    First off, what to pass? In a process, and any event or property (I think) for an action or stage, the process data object is the process Business Object. On a form, you have to pass in the Business Object you added to the form. This assumes you are referring to the Process Business Object. Any other one, you have to pass in explicitly.

     

    Second, how to specify the parameter. This is, from a default project with three variables added to the Process, and a server script added:

    public static object SampleMethod(Project1.Process1.Declarations.Process1Data bo)

     

    When I use "bo." in that function, intellinonsense gives me the variables I added to the process, along with the eFolderId variable and a few functions.

     

    The Current object is another thing entirely. It is the Process when in a process, and the Form when in a form. The main use for it I can see is to get the Form and all associated Business Objects, or even the Process and all associated Business objects. The type of the parameter is the Process (eg Project1.Process1 or Project1.Form1). I think I'll leave that for another post unless you have a specific need, as it can just confuse the issue.

     

    I am attaching the simple example I outlined.

  • We have discovered you can also do the following as well:

    public static object AlarmOwner()
    {
        Conflict_Alarm alarm = new Conflict_Alarm();
        alarm.Conflict_AlarmData.Found = 1;
        // continue code
    }
    

    where Conflict_Alarm() is the name of the process.  Once declared, doing alarm. will bring up the intellisense list like the bo. reference mentioned in Jerome's post.

     

    Though I'm not sure this is a "valid" approach or if there may be a "gotcha" yet, but thus far it appears to be working correctly.

  • Yes, this is the method that I was expecting to use - but the issue I was having was that I could not specify the parameter for the BO - it seems to work if it can guess that the current process's efolderid is expected for the Business object's efolderid parameter binding. 

     

    What I mean is that I want to get get a different process's BO where the efolderid is the current process's parent id.  This is one of the handiest things I have found in 9.0 (learned from Jerome's site under the "Truely Parallel Processes" lesson).  That was a real eye-opener for me about how helpful it is to separate the process, form, and business objects completely.

     

    It seemst that Jerome's post about passing in the BO will atleast provide the ability to accomish what I want from a form.  I would like to know how to get the BO for the parent process from within the child process (in a process action not in a form).  If anyone has specifics on how to do this, I would appreciate the tips.

  • You can add it to the Process itself. The downside is that it is opened every time the Folder is opened, and that will 'lock' the parent folder. In some cases that may well be acceptable, but not in most.

     

    My ideal would be to allow ANY Business Object to be used within an event only, this negating the need to open a BO every time the Folder is accessed when I only want to use it in one particular event.

     

    As for setting the parameters for other Business Objects, I have not tried, but the code implies you can set the parameters (the are just variables) and refresh the BO. Seems logical, but I've not tested it. Process BO's, as we find here, seem to use the current Folder Id by default. I am not sure you can set them and refresh as they are editable BO's - you could try, though.

  • FIrst I would like to say thanks for the examples and information put out by this group. I am assisting with a Metastorm project and would be dead in the water without a forum like this.

     

    I have tried the BO example provided by Jerome, and it Validates. However, I receive the following message when I attempt to Deploy:

     

    The type name 'Process1' does not exist in the type 'Metastorm.Runtime.Models.Project1.Project1'

     

    Did I miss something? Any ideas?

     

    Thanks,

     

    Brian