locked
Template question RRS feed

  • Question

  • Hi all.

    Prompt please how in a template  make so, that in the field "Description" value from field "Title" was substituted.
    In my MP I tried to make the following:

    <ObjectTemplate ID="Template.5671ff330dde4efe82bc9b4892d2cb7b" TypeID="CustomForm_fc6fd43f_c9cb_49e4_a76b_58b1331c5a4b_TypeProjection">
     <Property Path="$Context/Property[Type='Alias_c8940672_64a0_4d6b_9a6d_fb923cbfc8f9!System.WorkItem.TroubleTicket']/Description$"> $MPElement[Name='Alias_c8940672_64a0_4d6b_9a6d_fb923cbfc8f9!System.WorkItem.TroubleTicket']/Title$</Property>
        </ObjectTemplate>

    But the result: when i apply template in the field Description i see the text:

    $MPElement[Name='Alias_c8940672_64a0_4d6b_9a6d_fb923cbfc8f9!System.WorkItem.TroubleTicket']/Title$

    what i do wrong?


     

    Tuesday, March 30, 2010 10:31 AM

Answers

  • OK - so the outline of the solution is this:

    1) Create a new type projection which includes the incident as the Seed class and includes System.Domain.User over your custom relationship type and also include the Affected User relationship.  see this blog post (and the blog posts it links to!) for information on type projections:

    http://blogs.technet.com/servicemanager/archive/2010/02/02/creating-views-that-use-related-property-criteria-type-projections-software-views-example.aspx

    2) Create a custom Windows Workflow Foundation activity which takes an Incident ID as an input parameter.  The code should take the Incident ID GUID and get an EnterpriseManagementObjectProjection by passing your Type Projection ID (from #1 above) and the Incident ID GUID.  Then get the user defined in the Affected User relationship and set the same user to be over your custom relationship.  Then call .Overwrite() on the EnterpriseManagementObjectProjection.

    I'll be posting a detailed example on the blog of creating a custom Windows Workflow Foundation activity later this week or early next week.

    3) Now, add your WinWF activty from #2 above to your Toolbox in the authoring console by first copying the workflow activity .dll into the C:\Program Files (x86)\Microsoft System Center\Service Manager 2010 Authoring\PackagesToLoad folder.  Then start the authoring console.  Then right click on a folder in the workflow activity Toolbox and choose to add an activity.

    4) Now create a new worfklow triggered by a database change where the incident assigned to user user name after the incident update is not blank and the custom relationship user username after the update is blank.  Then drag your custom workflow activity onto the workflow designer and bind the Incident ID input parameter to the Internal ID of the Incident object.

    This is pretty complicated, so let me know if you have any trouble. I'll add it into my list of things to blog about in case you can't get it going.


    Travis Wright Senior Program Manager Lead Microsoft
    Wednesday, April 28, 2010 4:14 AM

All replies

  • Sorry, this is not possible to do in templates.  The only way I can think of to do this is with a custom workflow and would require writing code.

    Could you tell us more about your scenario and why you need to do this?  Maybe we can figure out a workaround instead.


    Travis Wright Senior Program Manager Lead Microsoft
    Tuesday, March 30, 2010 6:00 PM
  • Certainly. My scenario looks so.

    In my organisation not always the person who start incident, for example via "Email", is Affected user. Whether processing incident the operator solves is Caller and Affected user one person. If NO operator fills custom field Caller with necessary value. If Yes field Caller remains empty. And then Save incident. I want if the field Caller is empty system (Automatically) put  value from field Affected user in field Caller. But when i create workflow it is necessary to apply a template.

    I with pleasure use a variant with a create custom workflow. But I really not so well understand as it is possible to make.

    There can be you will give an example for my case?

     

    p.s. fields Description and Title in my code Have been resulted as the simplified examples.

    Wednesday, March 31, 2010 9:28 AM
  • OK - so to restate the requirement:

    You have two relationships between incident and user:

    1) The out of the box relationship for Affected User.

    2) A custom relationship you created between Incident and User called 'Calling User'.

    Your requirement is that if the field 'Affected User' is populated and the 'Calling User' field is not populated then the user that is in the Affected User field should be set as the Calling User.

    Is that right?


    Travis Wright Senior Program Manager Lead Microsoft
    Thursday, April 1, 2010 2:27 AM
  • Absolutely right.

    Only One insignificant difference: 

    my custom relationship between Incident and User called "Caller"

     

    Thursday, April 1, 2010 10:38 AM
  • OK - the only way I can think of doing this involves writing a custom workflow and will require writing code.  Do you want me to provide an outline of the solution so you can attempt to code it?
    Travis Wright Senior Program Manager Lead Microsoft
    Wednesday, April 7, 2010 4:46 AM
  • Sure, it would be very kind of you!

    Thank you very much in advance!

    Thursday, April 8, 2010 8:14 AM
  • OK - so the outline of the solution is this:

    1) Create a new type projection which includes the incident as the Seed class and includes System.Domain.User over your custom relationship type and also include the Affected User relationship.  see this blog post (and the blog posts it links to!) for information on type projections:

    http://blogs.technet.com/servicemanager/archive/2010/02/02/creating-views-that-use-related-property-criteria-type-projections-software-views-example.aspx

    2) Create a custom Windows Workflow Foundation activity which takes an Incident ID as an input parameter.  The code should take the Incident ID GUID and get an EnterpriseManagementObjectProjection by passing your Type Projection ID (from #1 above) and the Incident ID GUID.  Then get the user defined in the Affected User relationship and set the same user to be over your custom relationship.  Then call .Overwrite() on the EnterpriseManagementObjectProjection.

    I'll be posting a detailed example on the blog of creating a custom Windows Workflow Foundation activity later this week or early next week.

    3) Now, add your WinWF activty from #2 above to your Toolbox in the authoring console by first copying the workflow activity .dll into the C:\Program Files (x86)\Microsoft System Center\Service Manager 2010 Authoring\PackagesToLoad folder.  Then start the authoring console.  Then right click on a folder in the workflow activity Toolbox and choose to add an activity.

    4) Now create a new worfklow triggered by a database change where the incident assigned to user user name after the incident update is not blank and the custom relationship user username after the update is blank.  Then drag your custom workflow activity onto the workflow designer and bind the Incident ID input parameter to the Internal ID of the Incident object.

    This is pretty complicated, so let me know if you have any trouble. I'll add it into my list of things to blog about in case you can't get it going.


    Travis Wright Senior Program Manager Lead Microsoft
    Wednesday, April 28, 2010 4:14 AM
  • Thanks Travis.

    I have question about 2)
    You wrote

    2) Create a custom Windows Workflow Foundation activity which takes an Incident ID as an input parameter. The code should take the Incident ID GUID and get an EnterpriseManagementObjectProjection by passing your Type Projection ID (from #1 above) and the Incident ID GUID. Then get the user defined in the Affected User relationship and set the same user to be over your custom relationship. Then call .Overwrite() on the EnterpriseManagementObjectProjection.

    I find topic
    http://blogs.technet.com/servicemanager/archive/2010/05/06/incident-sla-management-in-service-manager.aspx


    where illustrate how create custom workflow, but my coding skill is very low. so i have some problem.
    May be you can post the example where show me how can i create WF where Incident ID as an input parameter. And Then WF for example update incident to set title='Test incident'

    I think it will be intrasted for many.

    Thank you very much in advance

     

    Wednesday, May 19, 2010 1:33 PM
  • An even easier option is to use Patrik's PowerShell cmdlets:

    http://blogs.technet.com/b/servicemanager/archive/2010/06/04/new-codeplex-project-service-manager-powershell-cmdlets.aspx

    You could either just set up a PowerShell script to run on a Windows scheduled task.

    Or you create a workflow in the SCSM authoring tool that runs on a schedule.  Then just put a single PowerShell script activity in there to run Patrik's PowerShell cmdlets.


    Travis Wright Senior Program Manager Lead Microsoft
    Tuesday, June 8, 2010 10:35 PM