Calling a SmartObject method from inside a workflow code event

  •  02-21-2008, 4:52 PM

    • mgallen is not online. Last active: 09-04-2008, 1:17 AM mgallen
    • Top 25 Contributor
    • Joined on 01-15-2008
    • Melksham, Wiltshire, United Kingdom
    • Posts 123
    • Points 391

    Calling a SmartObject method from inside a workflow code event

    Currently i'm doing something like this:

            public string runSPGetEmailSmartObject(string userName, string connString)

            {

                string userMail = "";

                string smartObjectName = "SPUser";

                string smartObjectMethodName = "Read";

     

                try

                {

                    // create smart object server client to query smartobjects

                    SmartObjectClientServer soServer = new SmartObjectClientServer();

     

                    soServer.CreateConnection();

                    soServer.Connection.Open(connString);

     

                    //Instantiate SmartObject

                    SmartObject so = soServer.GetSmartObject(smartObjectName);

     

                    so.Properties["LoginName"].Value = userName;

                    so.MethodToExecute = smartObjectMethodName;

                    soServer.ExecuteScalar(so);

     

                    userMail = so.Properties["Email"].Value;

                }

                catch (Exception Ex)

                {

                    Console.WriteLine(Ex.Message);

                }

     

                return userMail;

            }

    inside the workflow, which is identical to how I would do it if I was to call a SmartObject method from a standalone ASPX page.

    Is there a more efficient way of doing this from inside a workflow code event. Currently i'm having to formulate a connection string which I feel I shouldn't need to create as the code runs in the context of the workflow.

    any advice greatfully recieved

    Martin.

     

     


    Martin Allen

    Visit my blog: SpittingCAML blog
View Complete Thread