Instantiating a Business Object within a server-side script

Hi,

 

I have searched the forums to find a method to instantiate a business object in a server side script, with no success.

 

I have a business object which parses a parameter and returns a single row of user information. (Its an LDAP BO)

 

I would like to use this business object within a server side script, however I have not been able to find a method to do this.

Has anyone else achieved this?

 

ie of what I am trying to achieve

BO1 myBO = new BO1(paramters parsed);

string myName = myBO.name;

 

Thanks,

Ryan

Tagged:

Comments

  • Agreed, I have posted about this before but it drew no responses - would be interesting to get a response from OpenText......

  • Hi,

     

    Has anyone had any success with this?

     

    Thanks,

    Ryan

  • How about passing in a Business Object to your server side script instead of instatiating?

    So you would define your business object, set the parameter(s) you want for the business object, then pass it in as an object.

     

    Here is an example method that you can then use in the visual scripting by dragging it in, and then just assign the parameter and it is useable in the method.

     

        [Promote(PromotionTargets.VisualToolbox)]
        [Category("UserCategory")]
        public static bool SampleActivity(Metastorm.Runtime.Models.ConnectionTestProj.BusinessObject1 bo1)
        {
            
          if(string.IsNullOrEmpty(bo1.eUserName)){
            return false;
          }
          return true;
            
        }

     

    Does that work for your requirement?

     

    Cheers

    Phil

  • I can initiate a parameterless BO in code, and it works fine (ignore the erroneous Intellinonsense that it shows you):

     

    Metastorm.Runtime.Models.Project1.BusinessObject1 bo = new Metastorm.Runtime.Models.Project1.BusinessObject1();

    What I cannot do is add and set the parameters and make it refresh. I have tried:

     

    bo.Parameters[0] = new Metastorm.Runtime.Core.Mbo.Parameter("@pMapName", "BL_Invoice");
    bo.Refresh();

    but that does not work. It may be that there is another way to refresh it that does work.

  • Hi Phil,

     

    Thanks.

     

    For example; if I have a BO MyProcessData which has a parameter against it, such as the efolderid.

    How would I pass this through to the function?

     

    Cheers,

    Ryan

  • Hi Jerome,

     

    Thank you too for your solution.

     

    Similar question I have just posted to Phil...

    If I need to pass a parameter such as efolderid; would I not be able to use your solution, as the refresh of the BO with a parameter will not work?

     

    Cheers,

    Ryan

  • Hey Ryan,

     

    Well if you setup the Business Object with the eFolderId parameter, and at the process level you define the "eFolderId" parameter to ProcessContext.FolderId, then when you pass this business object to the function from within your visual script, the assignment of the parameter is already set so you don't need to do anything.

     

    I haven't needed to instantiate a business object from within a server side script, but from what Jerome is saying, it sounds like it has to be a business object without any parameters as you can't call the refresh() method to update the dataset returned.

     

    Hope that helps.

    Phil

     

  • Hi Phil,

     

    Thanks again for your help.

     

    If my function is using the ExpressionBuilder and I am parsing the BO; what parameter would I use to replace ****?

    Currently I have myProcessData1 as the BO used in the process; however this is the incorrect type to parse through.

     

    eg.

     

    From the expression builder I would call:

    ServerScript.myFunction(****);

     

    Script:

     

    [Promote(PromotionTargets.ExpressionBuilder)]

    [Category(

    "My functions")]

    [Alias(

    "Test function")]

    public static string myFunction(Metastorm.Runtime.Models.TenantProject.TEProcess myProcess) {

    ....

    }

     

    Cheers,

    Ryan

  • Hey Ryan,

     

    I've put together this quick solution to demo how either the process data object or a defined business object can be passed to, and used in a server side script.

     

    This is set as a visual scripting activities, but the expression builder method is very similar.

     

    The solution is coded up in version 9.1.2.3.

    http://www.evolosoft.com/wp-content/uploads/2012/12/BusinessObjectToScript.zip

     

    Any questions or problems getting it deployed just let me know.

     

    Cheers

    Phil

  • Hi Phil,

     

    I can't thank you enough for taking the time to assist!

     

    I have deployed your solution, and this is exactly what I am looking for.

    It will save me plenty of duplicate code (and maintenance) for long functions/procedures using BO's.

     

    Cheers,

    Ryan