Skip to main content


GetFirstValueForQuery works different in background actions



  • Matthias_Walter

    Hi DieterJauslin,

    I guess the parameter in your caml query should be a number and not a string. Therefore you have to get rid of the quote characters before and after the variable CurrentTaskID

    <Where><Eq><FieldRef Name="EHConfigImplemTaskNumber"></FieldRef><Value Type="Number">[[@Variables.CurrentTaskID]]</Value></Eq></Where>

    or how about using the current item value directly instead of using a variable?

    <Where><Eq><FieldRef Name="EHConfigImplemTaskNumber"></FieldRef><Value Type="Number">[[=[[@Action.Loop_thru_all_tasks.CurrentItem]].EHImplemTasnNumber]]"</Value></Eq></Where>

    BR Matthias

  • DieterJauslin

    Hi Matthias

    You are absolutely right. I tried so much on friday evening that i simply pasted the wrong query. Sorry ;)

    However, i just back on track and tried to cleanup everything. I have set an email with the responses ...
    In the Body i have put this code ...

    var content = [[@Web.GetFirstValueForQuery('Configuration Implementation Tasks', '<Where><Eq><FieldRef Name="EHConfigImplemTaskNumber"></FieldRef><Value Type="Number">[[=[[@Actions.Loop_thru_all_tasks.CurrentItem]].EHImplemTaskNumber]]</Value></Eq></Where>', 'Title')]];
    content = content + "<br>" + "Current Task Number : " + [[=[[@Actions.Loop_thru_all_tasks.CurrentItem]].EHImplemTaskNumber]];
    return content;
    I wanted to make sure that i use the correct lookup values when actually doing the lookup.
    The response i got looks like this:
    Workstep update Product Status ListCurrent Task Number : 414
    I expect the first line to be the title of the item referenced by the current task number (2nd line for debugging). 

    Now i got an email for each of the existing task items. Each has its own number (401 to 421) which is being looked up in the configuration list.
    But still, i only get back the Title value of "Workstep update Product Status List" which is the very first item in the configuration.

    What makes me laugh is, when i use the same code on form action button, it works as expected!
    I just got this problem when using it on the backend action 
    Best wishes and thanks a lot
  • Christof

    Hi Dieter

    I can reproduce your issue and have a random guess that it's caching the result of the query function to reduce duplicate time consuming calls during execution - for sure this works not as expected when the query contains dynamic changing variables inside a loop which returns different item(s) as result...
    Did create a support ticket on your behalf that we fix this issue in an upcoming product development sprint.
    If you have any more question in this topic we can continue communication in the ticket.
    Thank you for the feedback!


Please sign in to leave a comment.