How to Query a List By URL

  • 21 December 2018
  • 7 replies
  • 8 views

Badge +5

I'm using SharePoint 2010 and Nintex workflow 2010. 

I have a workflow that I want to re-use each month.

Each month i will create a list with this name format: [MonthName] [Year] Report. 

If I create a workflow that queries the current list (ex. December 2018 Report), I have to use the dropdown menu to select the list title. 

That means, if i try to import this workflow into another list, I'll have to first create the new list, and then change the list name in the drop down.

Since i will know the name of all future lists, I want to cut this step out.

Is there a way to query a list just by using the list URL? I would create a URL using variables that can change each month to point to the correct list.

Any suggestions?


7 replies

Badge +7

You'll probably need to use the Call Web Service action:

221722_pastedImage_1.png

Using that, you can build the listName.

Userlevel 5
Badge +14

one possible option is to use web service call as Chad Davis‌ mentions.

but you still can achieve it within the Query list action itself. you just cannot rely on built in CAML builder, but rather you have to switch to CAML editor and setup the query on your own. for a list reference use a workflow variable that will hold your dynamic list name.

to make life easier, you can first build whole query structure with query builder on a sample list and just then switch to CAML editor and just customize list reference.

221753_pastedImage_1.png

Badge +7

Marian Hatala‌, I had no idea you could change the CAML query's List attribute to 'Title' instead of 'ID'.

I always just assumed it needed to be the ID:

221759_pastedImage_1.png

That's an excellent thing to know! Thank you!

Userlevel 5
Badge +14

sure, with the editor you can use all the CAML features happy.png

Badge +5

Hello Marian - your suggestion appears to work great but my knowledge of CAML queries is at the beginner level. I can't seem to get it to do what I want it to do. Check out what I have:

camlsettings

I'm not quite sure I understand how to set up the syntax correctly. 

I have confirmed that the query is able to find my list and look at the Title field and save it to a variable (ParentSubject).

i need it to do the same thing with the "Created By/Author" field. But it doesn't work.

This query is on a discussion list and maybe that is complicating things. 

Essentially, I need the query to look at the current item (a message/reply) and get the parent's information (subject and author). 

Then store the subject and author to be used later in an email. 

The current set-up returns an error stating "Failed to query list data. Cannot find a field with internal name 'myUserName' on list."

"myUserName" is where it actually shows my ADS login. The CAML query is trying to match my personal login instead of whatever is in the Author field.

Any assistance with what I did wrong? Let me know if i need to provide more details. 

Userlevel 5
Badge +14

problem is not with a CAML itself but rather with the further settings.

specifically following one

222664_pastedImage_1.png

with the setting you say that at runtime value of current item's Author field is evaluated first, and then the resulting value is taken as a field name being looking for in target list.

so if you are the author on current item, field with your (login)name is being looked for. which apparently not the case.

simply type in 'Author' literally as you did for Title and it should work.

Badge +5

I set those fields up on two different days and for the life of me I couldn't remember how I did the "Title" field. Haha, thank you for the reminder. Everything is working as it should now.

Reply