none
How do I get the Target object in a custom activity to modify an attribute which may not be in the Request ? RRS feed

  • Question

  • What I am having trouble with is setting an attribute on a Target within a custom activity which wasnt changed (and so isnt seen in the Request)

    The scenario is:

    A Person is edited and his EmployeeType changes and so he gets moved INTO a set when my MPR/WF starts which starts my Activity.

    I want my custom activity to do some processing (actually it reads a sql table and other stuff) and push data into the (custom) attribute myInformation. This is easy.

    But myInformation is not touched by the change only EmployeeType is. I want my activity to do something like //Target/myInformaton = "abc123"

    Currently I am trying this approach in an _ExecuteCode block with no success.

                     // lots of code to build myNewInfo snipped....

                    //--- Tell the UpdateResourceActivity to update the Target object.
                    TargetId = currentRequest.Target.GetGuid();

                    //--- Add the myInformationattribute to the update parameters.
                    MyUpdateParameters = new UpdateRequestParameter[]
                    {
                        new UpdateRequestParameter("myInformation",
                        UpdateMode.Modify, myNewInfo)
                    };

    Maybe Modify is not the correct method?

    Howzit done then?

    Friday, June 1, 2012 1:02 PM

All replies

  • Hi-

    Modify is the correct option here. I assume you're adding this MyUpdateParameters block to the UpdateResourceActivity? What's the ActorId on the activity set to? Is it completing succesfully?


    My Book - Active Directory, 4th Edition
    My Blog - www.briandesmond.com

    Friday, June 1, 2012 2:18 PM
    Moderator
  • Actually I sort of followed the technet walkthrough of how to make a custom activity. http://msdn.microsoft.com/en-us/library/windows/desktop/ff859524.aspx

    I have 2 activities a ReadRequest and a Code.

    Something gets fired off in the "code" activity I drag into my project. I can dump my "request" and it looks something like this:

    2012-06-01 02:49:02: Request Operation: Put
    2012-06-01 02:49:02: Target Object Type: Person
    2012-06-01 02:49:02: Parameters for request: urn:uuid:56f3f22e-1608-47d2-bde1-71a06aa9bfb2
    2012-06-01 02:49:02:      EmployeeType: Contractor
    2012-06-01 02:49:02: Containing Workflow Dictionary (WorkflowData):
    2012-06-01 02:49:02:

    Ok... now I start to see... I need to drag a UpdateResourceActivity skeleton as well as a CodeActivity into my project. 

    But the technet article states that "The ExecuteCode event handler has now been defined. When the LogRequestDataToFile code activity becomes the active activity within the workflow, the code in the ExecuteCode event handler is executed." Nothing to say that it cant update resource requests!

    I will check this out on Monday, maybe the R2 RTM is out by then.

    Friday, June 1, 2012 2:47 PM
  • Correct. In your code activity, you setup the UpdateRequestParameter[] array, Target, and Actor, and assign those to the subsequent UpdateResourceActivity.

    My Book - Active Directory, 4th Edition
    My Blog - www.briandesmond.com

    Friday, June 1, 2012 3:13 PM
    Moderator