none
SharePoint 2013 workflow lookup doesnt return correct value first time it runs, but when manually restarted, the correct value is returned RRS feed

  • Question

  • We've set up a workflow that checks to see if someone is on an 'pre-authorised' list. If they are, then the workflow continues one way, if not, then the workflow is routed differently.

    For most users, this works fine.  However, for some users who are on the pre-authorised list, the look up doesn't work the first time the workflow is run.  In every case, if the workflow is manually restarted, the lookup works.

    What the workflow is doing is this:

    • Sets IDVar to 0
    • Looks up the Current Item:Created by (as string) user in the  data source PreAuthorised list by matching the AuthorisedName field to the Current Item:Created by (as string)
    • Sets IDVar to the ID of the item returned
    • If IDVar is still 0 then it does x, otherwise it does y

    When a user submits a request the workflow starts and the following messages are logged:

    • IDVar is 0
    • Created by John Smith
    • Created by is set to string i:0#w/domain\jsmith
    • IDVar is 0
    • Requires authorisation

    When I manually start the workflow on the same item, the following messages are logged:

    • IDVar is 0
    • Created by John Smith
    • Created by is set to string i:0#w/domain\jsmith
    • IDVar is 142
    • Does not require authorisation

    Ive tried adding a pause of a minute before the lookup, using display name/login name/email address instead of string for the lookup. Neither helped. 

    Any ideas?  Really hoping someone can help as two of us have spent many hours trying to fix this.

    Thursday, May 9, 2019 11:56 AM

Answers

  • Hi,

    assuming that your workflow starts automatically when item is created. In this case, WF is running in context of "John Smith". If John has no permission to read authorization list, lookup will fail. If you restart the WF, it is running in your context. I assume you are an admin and allowed to read the list. Could the be true? If so, I see to options:

    • perform the lookup within an appstep to avoid permission issues
    • give all users appropriate permissions to your authorization list

    Regards
    Barbara

    P.s.: For an App Step you need to configure Elevated Permissions


    Barbara Henhapl Blog MVP


    • Edited by Barbara HenhaplMVP Monday, May 13, 2019 11:50 AM Link for elevated permissions added
    • Marked as answer by NCCAdm Tuesday, May 14, 2019 9:45 AM
    Monday, May 13, 2019 11:47 AM

All replies

  • Hi,

    assuming that your workflow starts automatically when item is created. In this case, WF is running in context of "John Smith". If John has no permission to read authorization list, lookup will fail. If you restart the WF, it is running in your context. I assume you are an admin and allowed to read the list. Could the be true? If so, I see to options:

    • perform the lookup within an appstep to avoid permission issues
    • give all users appropriate permissions to your authorization list

    Regards
    Barbara

    P.s.: For an App Step you need to configure Elevated Permissions


    Barbara Henhapl Blog MVP


    • Edited by Barbara HenhaplMVP Monday, May 13, 2019 11:50 AM Link for elevated permissions added
    • Marked as answer by NCCAdm Tuesday, May 14, 2019 9:45 AM
    Monday, May 13, 2019 11:47 AM
  • Hi Barbara

    Thank you so much - that is the solution.  Obvious in restrospect but needed pointing out. 

    Tuesday, May 14, 2019 9:45 AM