SharePoint 2013 REST How to select a look up field and also filter based on look up field? - rest

I can't select look up field in my SharePoint 2013 List.
also I can't filter base on a Look up field.
for example I have List with Name Test and this list has fields: Title, Company, Province
the Company and Province is look up fields I want to filter based on Province which is a look up field
using REST query it gives error:
my query:
https://TestServer/sites/AIB/OBC/_api/web/lists/getByTitle('Test')/items?$select=Province/Title&$expand=Province&$filter=Province/Title eq 'ABC'
it gives error when I put the URL in My browser for testing it gives the blow error:
<m:message xml:lang="en-US">The field or property 'Province' does not exist.</m:message>
How to filter based on a look up field in SharePoint 2013 REST ?

How to filter by lookup field value using SharePoint REST
Assume a Contacts list that contains a lookup field named Province
Option 1
When a lookup column is being added into list, its ID become accessible automatically via REST. For example, when the field named Province is added into List, Province Id could be set or get via ProvinceId property of List Item.
The following query demonstrate how to filter list items by lookup field Id (Province Id in our case):
/_api/web/lists/GetByTitle('<list title>')/items?$filter=LookupField eq <ProvinceId>
where <ProvinceId> is a province id
Option 2
In order to filter by lookup value, the query should contain $expand query option to retrieve projected fields (like Province Title). The following example demonstrates how to filter by lookup field value (by Province Title in our case):
/_api/web/lists/GetByTitle('Contacts')/items?$select=Province/Title&$expand=Province&$filter=Province/Title eq <ProvinceTitle>
where <ProvinceTitle> is a Title of Province

Use $expand like blow code:
/_api/web/lists/GetByTitle('Test')/items?$select=Province/Title&$expand=Province&$filter=Province/Title eq 'XYZ'

Mehdi jalal, I found why it was throwing that error. You need to close your ProvinceTitle with Single Quotes and there you have it. like this
Query Syntax:
/_api/web/lists/GetByTitle('Contacts')/items?$select=Province/Title,Province/ID&$expand=Province&$filter=Province/Title eq '<ProvinceTitle>'
Now this is Example Query:
/_api/web/lists/GetByTitle('Contacts')/items?$select=Province/Title,Province/ID&$expand=Province&$filter=Province/Title eq 'Detroit Province'

Related

How to define a tags / value query in Grafana 7.4?

I am having some trouble understanding the concept of Value groups/tags in Grafana 7.4.x with MySQL as a data source.
My main query gets the Countries
SELECT
NAME as __text,
id AS __value
from
countries
The tags query gets the Continents
SELECT
NAME as __text,
id AS __value
from
continents
That works so far, tags are shown in the list, but nothing happens once I click on them.
My tags query:
continents.$tag.*
The tags query seems to be the problem. Any help is greatly appreciated.
3 queries are involved:
The first one is under "Query Options" -> "Query": This one should list all the values (all the countries in your case).
The second query is the "Tags query" under "Value groups/tags": This query should list all the Tags you want (continents).
The third query is "Tag values query": This is where the magic happens, this query should return all the different values matching the selected tags, so, you must add a WHERE clause somewhere that Grafana will use to create a query to get the correct values, ...WHERE continent = '$tag'. <- $tag will automatically be replaced by a list of tags the user has chosen.
Be aware that the official documentation provides examples for InfluxDB datasource, since you are using MySQL, you must use SQL queries everywhere, so continents.$tag.* is invalid.

Sharepoint Online Rest Query with $expand generating 400 bad request

I have 2 sharepoint lists setup to represent different groups(circles) and the users that are apart of those groups(circles).
List: Circles Columns: Circle(single line of text)
List: UserCircles Columns: UserName(person lookup), UserCirlce(lookup to Circle list)
In the setup, all of the columns are their own columns (I have not renamed the title column to Circle or anything like that). I have not changed the display names of the lists.
When I try to run an REST GET against the UserCircles list and retrieve the projected values from the Circles list as below:
/_api/web/lists/getbytitle('UserCircles')/items?$select=Circles/Circle&$expand=Circles
I get a HTTP 400 Error and the message:
The field or property 'Circles' does not exist
I can successfully run a query against the UserName field (I assume that's the referenced field), by running the below query:
/_api/web/lists/getbytitle('UserCircles')/items?$select=Author/Title&$expand=Author
I am not sure why the query cannot find the list specified. I have verified all of the list names. Any guidance would be appreciated.
There is a typo in your example, since the name of lookup field is UserCirlce, the query should be like this:
/_api/web/lists/getbytitle('UserCircles')/items?$select=UserCirlce/Circle&$expand=UserCirlce
Note: the name of lookup field have to be specified in $expand query
option
The list of examples for syntax's of $expand query option:
/_api/web/lists/getbytitle('<listtitle>')/items?$select=<lookupfieldname>/<projectedfieldname>&$expand=<lookupfieldname>
/_api/web/lists/getbytitle('<listtitle>')/items?$select=<lookupfieldname>/<projectedfieldname1>,<lookupfieldname>/<projectedfieldname2>&$expand=<lookupfieldname>

Filtering a list lookup in Nintex Forms using an inline function

I am building a list form for SharePoint 2010 using Nintex Forms 2010.
The user must select an item from a different list, so I have added a List Lookup control. But the user can only select among items that starts with a specific string.
For example, the lookup list could contain items with titles 'foo1','foo2','bar1','bar2'. I only want the user to be able to select 'foo1' or 'foo2'.
In the filtering section of the List Lookup control I have specified the following:
Filter available selections = By a specific value
Where field = fn-Substring("Title",0,3)
Filtered by value = foo
Unfortunately this does not result in any options for the user to select - just an empty control.
If I change the filter to:
Where feild = Title
Filtered by value = foo1
Then I get the foo1 option - and only that one. Trying something like
Filtered by value = foo*
does not work either.
So how should I define the filter to get it to work. Or is what I am trying not possible in Nintex Forms?
The inline function won't work in your case, because it is a client side function, and your parameter is a server side object.
There two alternative ways can help with your request in server side.
1.Add a calculated value column to your list, use LEFT function to cut the search key for yourself:LEFT([Title],3). In nintex form, you can use this column to filter the list items.
Filter the list items in a view instead of nintex form. Suppose you have already known the [source view] property in List Lookup control.

How to search the input keyword with all the fields of a table

Hi am developing my first grails application now i want to put search method in my application.. Is it possible to match the single entered keyword with all the fields of the table.Like when i use findById it will search only on id or if i use findByName it will search only on name or findByDescription find only on description..
Is it possible to use findall or findBy* to match with all the fields like id, name, description..
If you are using a RDBMS, you can issue a query on the following lines:
SELECT .... FROM .... WHERE name like '%value%' OR description like '%value%' OR id like '%value%'
But this is going to be very inefficient. You can instead use a full text search API lucene/ solr and index entire content as part of one field and issue queries on that.

FileMaker - How to have distinct values listed on-screen?

I would like to have the distinct values of a repeating field listed in another field (in browse mode). The case is as follows:
I have a field that contains country names. The country names in this field may repeat themselves, thus when using the "List" function I get something like "France, France, France, Germany, Germany, Hungary".
How can I create a field that lists all the values from my country field, but has it grouped as "France, Germany, Hungary"?
In the case I could directly use a SQL query to interfere with the FileMaker databse I would use the GROUP BY statement.
To make a summary of all the values across every record, do as follows:
Make a new value list labeled 'Countries' (File Menu > Manage > Value Lists)
Make the value list 'Use Values From Field' and specify your repeating field
Create a new Calculation field, 'Listed Countries'
Set the calculation to type 'Text' and with the following code:
ValueListItems ( Get(FileName) ; "Countries" )
If you'd like to find the value for only the current record:
Make a new Table Occurrence, 'NewTO' of the same base table and link the two records by a unique index.
Change the 'Countries' value list so that it obtains values from 'NewTO' and your repeating field.
Select 'Only include related values starting from' and select your original Table Occurrence
If you'd like the list to update as the repeating field value changes, make certain that you Do Not Store Calculation Results for the field.