Home Analyst Portal

auto insert current user

alex_kokinalex_kokin Member IT Monkey ✭

Can someone help me edit this entry so that the userpicker automatically inserts the current user into the assigned to field.


{ DataType: "UserPicker", PropertyDisplayName: "AssignedTo", PropertyName: "AssignedWorkItem", Required: false, },

Best Answer

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    Accepted Answer

    I like the ideas that were presented in this thread by @Gerhard_Goossens.

    I wrote this powershell that does the same thing.

    param($CrID)

    $crClass = Get-SCSMClass -name System.WorkItem.ChangeRequest$

    $thisCR = Get-SCSMObject -id $CrID

    Write-Output "Got CR: $($thisCR.Id)"

    $assignedUserRel = Get-SCSMRelationshipClass -Name System.WorkItemAssignedToUser

    $createdByRelClass = Get-SCSMRelationshipClass -Name System.WorkItemCreatedByUser

    $createdRelationship = Get-SCSMRelationshipObject -BySource $thisCR | ?{$_.relationshipid -eq $createdByRelClass.id -and $_.sourceobject.classname -eq $crClass.Name}

    $createdUser = Get-SCSMObject -id $createdRelationship.TargetObject.Id\

    Write-output "Assigning to $($createdUser.displayname)"

    New-SCSMRelationshipObject -Relationship $assignedUserRel -Source $thisCR -Target $createdUser -Bulk


    I added it to a Powershell activity script and created a new Powershell Activity template using that script and I mapped the Parent Base Id to the CRID parameter in the Powershell Activity Template.

Answers

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭

    @alex_kokin - using the form definition to set the Assigned User is not possible. What are you ultimately trying to accomplish? Do you want any analyst that views the ticket to become the assigned analyst?

  • alex_kokinalex_kokin Member IT Monkey ✭
    edited April 2020


  • alex_kokinalex_kokin Member IT Monkey ✭

    @Justin_Workman I built a ARO for Change requests but I need to either add a assign to field for the creator to fill in or have it auto assign to the creator of the change request.

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭

    @alex_kokin - You will need some kind of automation like an Orchestartor Runbook or Powrshell Activity in the activity chain in the CR. Do you use Orchestrator?

  • alex_kokinalex_kokin Member IT Monkey ✭

    @Justin_Workman not at all...

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭

    @alex_kokin - In that case you might want to use Powershell Activity.

  • alex_kokinalex_kokin Member IT Monkey ✭

    @Justin_Workman do you by chance have any scripts I may work with?

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    Accepted Answer

    I like the ideas that were presented in this thread by @Gerhard_Goossens.

    I wrote this powershell that does the same thing.

    param($CrID)

    $crClass = Get-SCSMClass -name System.WorkItem.ChangeRequest$

    $thisCR = Get-SCSMObject -id $CrID

    Write-Output "Got CR: $($thisCR.Id)"

    $assignedUserRel = Get-SCSMRelationshipClass -Name System.WorkItemAssignedToUser

    $createdByRelClass = Get-SCSMRelationshipClass -Name System.WorkItemCreatedByUser

    $createdRelationship = Get-SCSMRelationshipObject -BySource $thisCR | ?{$_.relationshipid -eq $createdByRelClass.id -and $_.sourceobject.classname -eq $crClass.Name}

    $createdUser = Get-SCSMObject -id $createdRelationship.TargetObject.Id\

    Write-output "Assigning to $($createdUser.displayname)"

    New-SCSMRelationshipObject -Relationship $assignedUserRel -Source $thisCR -Target $createdUser -Bulk


    I added it to a Powershell activity script and created a new Powershell Activity template using that script and I mapped the Parent Base Id to the CRID parameter in the Powershell Activity Template.

Sign In or Register to comment.