locked
Entity Reference Not found.....but it's there! RRS feed

  • Question

  • Two entities:  Applicant (custom) and User (native CRM)

    One Lookup Reference:  On Applicant entity there is a lookup field (Intake User) to User thereby linking one CRM User to the applicant record.

    I have created a custom workflow activity that (in addition to other things) populates Intake User on the Applicant entity in code:

    This works!!  If I view the Applicant form, the link to the user is there and works perfectly.

    However, when, in the workflow, the next step tries to start a child workflow using the Intake User from the Applicant instance as the source entity, it fails or falls through since it thinks there is nothing there!

    What am I doing wrong here?

    Thanks,
    Glen

    Tuesday, June 9, 2015 7:11 PM

All replies

  • I might be missing something, but do you also have a custom ENTITY called 'Intake User' ?  Seems like the Start Child Workflow would be on 'User' not 'Intake User'...unless you have somehow renamed it?
    Tuesday, June 9, 2015 7:16 PM
  • Chris,

    Thanks for your reply.  No, there's no entity called "Intake User".  Intake User in the Start-Child-Workflow reflects the field name of the lookup on the Applicant entity.  It's in the list of Related Entities in the drop-down list of source items from which to choose.

    Thanks,
    Glen

    Tuesday, June 9, 2015 7:37 PM
  • OK, so that's not it then... :)

    Perhaps you need a 'wait for' above the 'if create new employee' and tell it to wait for 'Intake User contains data'.  That will ensure that the field has a value before it tries to execute the next step.

    Tuesday, June 9, 2015 7:47 PM
  • I think you do need the Wait step. As far as I can tell, the workflow engine does not re-read records after a custom workflow activity runs, which is why it is unaware of the value you've set in the custom workflow activity .

    The Wait step should force a re-read. If that doesn't work, try an Update step that sets the 'Intake User' attribute to itself


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, June 10, 2015 9:06 AM
    Moderator
  • You could try and return the entity reference into your workflow from the custom activity, that way you do not have to wait.

    Halldór Jóhannsson

    • Proposed as answer by Glen Wolinsky Wednesday, June 10, 2015 1:43 PM
    Wednesday, June 10, 2015 9:34 AM
  • Thanks to all who replied with suggestions. I tried the Wait solution as I came to the same conclusion as David. No dice.  Apparently, there is an issue with the workflow seeing changes made to objects in custom activities. 

    I finally tried Halldór's advice and provided an OutArgument with the EntityReference and that did the trick.

    Thanks again to everyone.

    Sincerely,
    Glen

    • Proposed as answer by Glen Wolinsky Wednesday, June 10, 2015 1:44 PM
    Wednesday, June 10, 2015 1:44 PM
  • I know this is kind of a late addition, but what if you created the new record outside of your custom workflow activity step, via the workflow, then used your workflow activity to populate the needed fields.  From here the workflow will have the reference of the new record and can pass to the child workflow.    

    Just a quick thought

    Good luck. 

    Sanford

    Wednesday, June 10, 2015 4:56 PM
  • Sanford,

    Another good idea, but in this case I'm actually re-enabling an existing CRM user.  I don't know which one until the code in my custom activity is running since it makes the determination.

    Thanks for your contribution,

    Glen

    Wednesday, June 10, 2015 5:48 PM