Updating RequestStatusDetail

Not long ago I wrote a post about writing status messages back to the Request object from a custom workflow. I used custom attributes because I was following the only documentation I could find. But Henrik said “why don’t you use RequestStatusDetail?” – and actually the reasons were a. I hadn’t thought of it, and b. I didn’t know how.

But now I’ve had a play with it, and figured out how to update the field (it needs to be in XML) and why it’s very cool to do so (it makes the message easily available to the user).

In my custom workflow I have the following activities:

  • A CurrentRequestActivity
  • A code activity, and
  • A ResourceUpdateActivity.

During my code activity I have set two variables:

  • Boolean “success”, and
  • String “returnMessage”.

Now at the end of my code activity I add the following code to prepare the ground for the ResourceUpdateActivity (which I’ve named “updateRequestDetails”) that writes the message back.

        Me.updateRequestDetails_ActorId1 = New Guid(FIMADMIN_GUID)
        Me.updateRequestDetails_ResourceId1 = Me.currentRequestActivity.CurrentRequest.ObjectID
        Dim returnXML As String
        Dim returnLevel As String
        If success Then
            returnLevel = "Information"
            returnLevel = "Error"
        End If
        returnXML = "<RequestStatusDetail xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" " _
                    & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" DetailLevel=""" & returnLevel & """ " _
                    & "EntryTime=""" & DateTime.Now.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.000'") & """>" _
                    & returnMessage & "</RequestStatusDetail>"
        Dim updateInstruction As New UpdateRequestParameter
        updateInstruction.PropertyName = "RequestStatusDetail"
        updateInstruction.Mode = UpdateMode.Insert
        updateInstruction.Value = returnXML
        Me.updateRequestDetails_UpdateParameters1 = New UpdateRequestParameter() {updateInstruction}

I’ve used the FIM Admin account to write the message, and I had to explicitly give it permission to write to the RequestStatusDetail attribute of the Request resource type. You could also use the requestor’s account to update the field (Me.updateRequestDetails_ActorId1 = Me.currentRequestActivity.CurrentRequest.Creator), but you will still need to explicitly grant permissions with an MPR (have a look at the “Request Management: Request creators can…” MPRs to see what you need to do).

And here’s a picture of the Request after the custom workflow activity failed.

2 Replies to “Updating RequestStatusDetail”

  1. In the middle of some custom activity work to update this field. Though it’s a bit roundabout I found a way to generate the XML instead of hard coding the variable. You add a new RequestStatusDetail to the request and then retrieve the value from the request itself. Odd steps to take but it returns the proper XML without worrying about format changes or human error.

    CurrentRequest.AddStatusDetail(new RequestStatusDetail(DetailLevel.Information, “LogID:” + currentRequestID));

    UpdateRequestParameter updateRequestParameter = new UpdateRequestParameter();
    updateRequestParameter.PropertyName = “RequestStatusDetail”;
    updateRequestParameter.Value = CurrentRequest.RequestStatusDetails[0];//use safer method than assuming index position
    updateRequestParameter.Mode = UpdateMode.Insert;

    this.UpdateRequest.UpdateParameters = new UpdateRequestParameter[]

Leave a Reply

Your email address will not be published. Required fields are marked *