Question

Photo of Michael Garrison

0

Auto-filling person attribute in "Action" menu triggered workflow

I'm creating a rather all-purpose workflow to allow a person to be added to the "task" list of staff members in order to request follow-up contact to be made. I've gotten everything working when triggered through the "Workflows" page and I've added this workflow to the "Actions" menu on the person profile pages.

And while it's ok, it would be ideal if the "Person" attribute (the person to be followed up with) could be auto-populated with the person from whose profile the workflow was begun.

If I look at other similar workflows (Data Error, for example), they include a "Set Person" action, which is set to "Set Attribute to Entity", the Attribute being set to "Person". I'm assuming that this is where that information gets automatically set. (the only other pertinent item I can see in the documentation is the "Activate Workflow" block which I don't think is right for this - it appears that if I add that to the person profile page it tries to activate the workflow immediately - I'd probably have to make a sub-page with a button linking to it)

But if I add this same action to the top of my own workflow, the "Person" attribute still does not auto-populate on the data collection form, and what's more when I submit the form I get an error:

  • Error in Activity: Request; Action: Set Person (Set Attribute To Entity action type)
  • The entity is null or not a Rock IEntity.

I don't know what that means- the only thing I can think is that it's being called upon the form submission for some reason, which is AFTER the personid URL parameter has already been cleared, so there IS no person attribute to read. But unless I'm mistaken, this should have already happened since my actions are "Set Person", THEN "Prompt User".

  • Photo of Rock RMS

    0

    This is probably due to how your workflow is persisted. When a user selects the workflow from the Actions dropdown list on the person page, it is navigating to a page that has the Activate Workflow block. This block will evaluate the query string parameters and attept to set the person.  That block then redirects the user to the workflow entry page.  However, if the workflow is not persisted at that point, this setting of the person value will be lost when it redirects. Take a look at the Data Error workflow and model the persistence after that one. 

     

    • Michael Garrison

      OK, that works ... but my concern is that I didn't want to persist the workflow until AFTER the data was requested from the user, in case they cancel it at that point (similar to the reason it's not persisted until that point on the public webpage contact form). I suppose the right way to do it is to offer a "Cancel" button that triggers a "delete" activity...?
      Edit: Such a cancel button doesn't work, since I have form elements marked as "required" =/

    • Michael Garrison

      One other thing, if I do that, they can't trigger it from "Tools -> Workflows" or I get the same "Entity is null or not a Rock IEntity" error. Probably a minor thing to hide it from there and force them to trigger it from a profile, but is there a way to check if the parameter exists and only conditionally run the "Set Attribute To Entity" action if it does?

  • Photo of Rock RMS

    0

    If you create a workflow with several activities that are activated with the workflow, you should be able to accomplish this...

    First Activity ( This activity is for when workflow is launched from person profile )
        Set Attribute From Entity
        Persist Workflow

    Second Activity ( This is where normal workflow processing would begin.  If First activity ran successfully, then person attribute would already be filled in, if not, then user would have to select a person )
        Entry Form
        Persist Workflow

    Third Activity ( Because the first activity may persist the workflow and then user never enters any data, this activity would delete the workflow if no data was ever entered ).
        Delay (10 mins)
        Delete Workflow ( conditional action that is only run if one of the entry form attributes is blank )

    There is a temporary sample "Follow-Up" workflow on the Rock Demo site that models this.

    • Michael Garrison

      Seems brilliant, the question that came to mind was what happens when one of the two (really three, but one's in a delay) activities that launch at start has an error? So I tried it out- I set up my workflow like you described and launched it from the "Tools > Workflows" menu. Sure enough, no auto-complete, no error. So I filled out the request and submitted it. Oops! Now I get the error:
      Workflow Processing Error(s): •Error in Activity: Auto-fill the person; Action: Auto-fill Person (Set Attribute To Entity action type)
      •The entity is null or not a Rock IEntity.


      So while I was hoping that an error in one activity would be ignored if there were others running (or queued, as I guess the situation is), the error instead stops the entire workflow- I see that neither workflow persist action executed, as the workflow does not appear in the "Manage" menu for that task.


      Edit: And do I need to add another 1 minute delay to Third Activity set to complete the activity upon completion? Because it looks like "Delete Blank Request" stays active when the task is launched from a profile (or at least listed under "Activities" in the management window) even after 10 minutes have elapsed and theoretically it shouldn't be there any more. Would that work that way? I'm assuming that selecting that attribute on the "Delete Workflow" action would have no effect if the filter kept the action from running...

  • Photo of Rock RMS

    0

    Based on this scenario, we've updated the 'Set Attribute From Entity' action to include an 'Entity is Required' option. If this option is selected (default), then the action will work as it does today, but if it is unselected, an error would no longer be reported and the activity/actions would continue processing. This will be available in the next update.

    Also, it does appear there is an issue with the Delay action in v2.0 that is also fixed in the next update.

    • Michael Garrison

      Hopefully the delay fix will address the errors that occurred once I had that element in my workflow- thanks! To the rest...BRILLIANT! ;) Appreciate it.