Find a metaverse object attribute from a custom workflow
Hi, I'm new to FIM and custom workflows, so I'm not even sure I'm going about this the right way. I have a requirement that when a group is created in the FIM portal, the display name should be changed to have the Office Location of the creator pre-pended to it. I've got a workflow that can update the displayname for the group and can find the objectId for the group creator using enumeration, thanks to helpful posts in this forum. However, I'm stuck on how I can get the Office Location for the creator now. Is workflow even the right approach I should be taking to accomplish this? If so, what can I do to get the officeLocation and if not, I would appreciate guidance on the better approach. Many thanks for any assistance at all. Best regards, Sami
July 12th, 2010 12:28am

Hi Sami! You can't get an attribute value from MV for use in a workflow, you must write it to the FIM Service (the creator resource) before this value can be used. I believe the best solution would be a custom action workflow with the following activities: 1. ReadResourceActivity - This allows you to read information from the group, pass in the TargetID for your group that you fetch from the workflow. Using the EnumerateResourcesActivity that performs a search rather than a fetch might not be the best solution since you know the ObjectID for your group already since that is the target resource for you workflow. This is how you could get the containing Workflow and the TargetID (for your group): // Try to get parent workflow. SequentialWorkflow containingWorkflow = null; if (!SequentialWorkflow.TryGetContainingWorkflow(this, out containingWorkflow)) { throw new InvalidOperationException("Could not get parent workflow!"); } // Then you should be able to get the target resource for the request like this: Guid targetID = containingWorkflow.TargetID; You can initialize the first ReadResourceActivity with the target for the workflow like this: //Get The resource the workflow is currently acting on. this.readResourceActivity1.ResourceID = targetID; 2. CodeActivity - Use the event handler supplied by this activity to gather information from the first ReadResourceActivity and feed the next. The displayName is later on used to update the groups displayName. // Get Creator and DisplayName from first Group.<br/> ResourceType resource = this.readResourcesActivity1.Resource as ResourceType;<br/> Guid creatorID = resource.Creator;<br/> string displayName = resource.DisplayName;<br/> <br/> // Feed the next readResourceActivity to get the Creator person with it's office location.<br/> this.readResourcesActivity2.ResourceID = creatorID;<br/> this.readResourceActivity2.SelectionAttributes = new<br/> string[]{"OfficeLocation"};<br/> 3. ReadResourceActivity - This allows you to get information out of the Creator person resource. The previous ReadResourceActivity got you the ResourceID for the Creator, pass this value into this activity and the Office Location attribute name (see above). 4. CodeActivity - Use the event handler supplied by this activity to gather information from the second ReadResourceActivity and feed the UpdateResourceActivity. // Get info from second ReadResourceActivity, creator person. ResourceType resource2 = this.readResourcesActivity2.Resource as ResourceType; string officeLocation = resource2["OfficeLocation"]; // Create update parameter, concatenate Office location with Displayname. List<UpdateRequestParameter> parameters = new List<UpdateRequestParameter>(); parameters.Add(new UpdateRequestParameter("DisplayName", UpdateMode.Modify , officeLocation + " " + displayName)); // Set targetID(the group ObjectID) to updateResourceActivity. updateResourceActivity.ResourceId = targetID; updateResourceActivity.UpdateParameters = parameters.ToArray<UpdateRequestParameter>(); 5. UpdateResourceActivity - You have collected all information you need and it's now time to perform the update of the Group DisplayName (see above). I can't guarantee the code works so you might have to fix parts of it but otherwise it shows how this could be done... //HenrikHenrik Nilsson, ILM/FIM MVP Blog: http://www.idmcrisis.com Company: Cortego (http://www.cortego.se)
Free Windows Admin Tool Kit Click here and download it now
July 12th, 2010 10:27am

Hi Henrik, Thank you for the advice. Our dev environment is being rebuilt at the moment, but I'm going to get started with your suggestion. I appreciate your time and guidance and will let you know how it goes. Thanks! Sami
July 14th, 2010 7:49pm

Hi Henrik, I promised an update. It took a bit longer to get back to this than I had hoped. There was one step I had to add in and that was setting the actor id on the readReadourceActivity to the actorID on the containing workflow. After that, by following your example, things were good to go. Many thanks again for the help. Best regards, Sami
Free Windows Admin Tool Kit Click here and download it now
August 9th, 2010 4:49pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics