Skip to main content

Search

Condition to check if sub list has items?

Comments

10 comments

  • Joerg_K.

    So I found that:

    [[@Web.GetFirstValueForQuery('Listname', 'CAML QUERY','ID')]] == null

    seem to work, at least if I first time enter the edit form.

    Still there is a problem. Because when you add an item into the sub list, it will not get saved and due to this, the count is still null and the "+ New" button will keep being visible. I added a button to Save and Reload, but then the user starts on top of the edit form, there is an action to jump to a tab, but it is not doing the required reload.

    Maybe there is even a better way?

     

    0
  • Matthias_Walter

    Hi Jörg,

    I can reproduce your case and looks like we have to fix this. Looks like the visible evaluation is done too early, when the sublist is not loaded completely.

    And the GetFirstValueForQuery approach is not working as this is just executed once, but not again, when adding/removing sublist items.

    We will add this to our backlog and keep you updated when fixed and released.

    Kind regards

    Matthias

    0
  • Joerg_K.

    Matthias-Walter Excellent many thanks. I also found that the CAML query builder, especially when using date comparisons and multiple rows of queries with && (AND) using the copy to expression function at the  CAML builder, the parser posts & " instead of the entities (& or '), which I then had manually to change and make the query work!

    0
  • Matthias_Walter

    Hi Jörg,

    I don't know how to reproduce this CAML Builder issue. Can you please send a screenshot of the configuration and how it looks like when it is parsed?

    Kind regards

    Matthias

    0
  • Joerg_K.

    Hey Matthias-Walter,

    first I was unable to reproduce, but basically it looked like this:

    [[@Web.GetFirstValueForQuery('OneTouch Tickets', '<View Scope="Recursive"><Query><Where><And><Eq><FieldRef Name="LookupToWeeklyReports_x003a_Repo" /><Value Type="Lookup" ProviderType="FormInput">[[{return [[ReportDate]]&amp;&amp;[[ReportDate]].format(&quot;yyyy-MM-ddTHH:mm:00Z&quot;);}]]</Value></Eq><Eq><FieldRef Name="UpdatesOnTicketsGT7days" /><Value Type="Boolean" ProviderType="Value">0</Value></Eq></And></Where></Query></View>', 'ID')]] != null
     
    instead of:

    [[@Web.GetFirstValueForQuery('OneTouch Tickets', '<View Scope="Recursive"><Query><Where><And><Eq><FieldRef Name="LookupToWeeklyReports_x003a_Repo" /><Value Type="Lookup" ProviderType="FormInput">[[{return [[ReportDate]]&&[[ReportDate]].format('yyyy-MM-ddTHH:mm:00Z');}]]</Value></Eq><Eq><FieldRef Name="UpdatesOnTicketsGT7days" /><Value Type="Boolean" ProviderType="Value">0</Value></Eq></And></Where></Query></View>', 'ID')]] != null
     
    Now I encountered the issue again, and it is the CAML Query builder itself that is going to produce the "faulty" string, when I run the query it looks good:

    but looking into the XML tab it shows up like this:
     
     
    Maybe this occurs when doing a run and checking how the XML looks like means changing from Designer to the XML tab.
     
     
    I tried to manually change the HTML entities into the character & and ' but as soon I made a change at the designer mode, the builder was coming up again with the HTML entities showing in the XML tab instead.
    0
  • Joerg_K.

    Matthias-Walter

    There is another issue with the Expression Builder - I experienced that the editor is adding additional blanks to a date string:

    0
  • Matthias_Walter

    Hi Joerg-K

    unfortunately I'm not able to reproduce this issue with the spaces. Did you update the solution to the latest version?

    where exactly are you trying to do this?

    Kind regards

    Matthias

    0
  • Joerg_K.

    Matthias-Walter Yes, I am at the latest version, but I believe it depends on the quotes used, it makes a different if you use a single or double quote!? However, I'm not knowing if I introduced the single quotes or something else!?

    0
  • Matthias_Walter

    Hi Joerg-K

    regarding your initial question, I guess we've figured it out and it was just the column name missing in the placeholder.

    [[@SubLists.SublistName.ColumnName.Count]]==0

    Like this it is working as expected for me. Could you try it again and let me know?

    BR Matthias

    0
  • Joerg_K.

    Hello Matthias,

    unfortunately, the condition cant be used, as the condition does a count over the entire sub list and not just the related items.

    [[@SubLists.OneTouchTickets.ID.Count]]==0

    currently I am using

    [[@Web.GetFirstValueForQuery('OneTouch Tickets', '<View Scope="Recursive"><Query><Where><And><Eq><FieldRef Name="LookupToWeeklyReports_x003a_Repo" /><Value Type="Lookup" ProviderType="FormInput">[[{return [[ReportDate]]&&[[ReportDate]].format("yyyy-MM-ddTHH:mm:00Z");}]]</Value></Eq><Eq><FieldRef Name="Author" LookupId="TRUE" /><Value ProviderType="CurrentUserId"><UserID /></Value></Eq></And></Where></Query></View>','ID')]] == null


    but the downside is, that the condition only works after a save and re-open in edit mode. 

    I wish I could check the existence of an item in a sub list while the parent is in edit mode, so I could hide the "+ New" button as soon as a certain amount of items in the sub list is reached and that the button will show again once I am below the amount of items again. As said currently it only works if the user hits a button I created for saving the parent incl. all changes made to sub lists and do a reload/reopen in edit mode.
    At the end I just want to have one entry for the specific sub list.

    0

Please sign in to leave a comment.