Crosssite Lookup Filter
I have been successfull with cascading the cross site lookups from this link http://spform.com/forms-designer- ... office-365 but can't figure out how to apply a simple filter based on text.
function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby=Title&filter=Catagory eq "Client"";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$filter=startswith({LookupField}, '" + term + "')";
}
function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby=Title&filter=Catagory eq "Client"";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$filter=startswith({LookupField}, '" + term + "')";
}
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Of which type is the Category field?
What I would like to accomplish is the Cross Site Lookup connected to the "Comapny List" pulling the "Name". That list has another column called "Catagory". Depending on another choice field where the catagory is selected the filter will apply to the lookup.
I hope that makes sense.
I hope that makes sense.
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
This is my current script:
function (term, page) {
if (!term || term.length == 0) {
var fltr = 'Client'
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Catagory&$orderby=Title&filter=Catagory eq " + fltr;
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Catagory&$orderby={LookupField}&$filter=startswith({LookupField}, '" + term + "') and Catagory eq " + fltr;
}
No errors but the filter is not working. The "Catagory" field on the parent form is a choice field, does that make a differance?
function (term, page) {
if (!term || term.length == 0) {
var fltr = 'Client'
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Catagory&$orderby=Title&filter=Catagory eq " + fltr;
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Catagory&$orderby={LookupField}&$filter=startswith({LookupField}, '" + term + "') and Catagory eq " + fltr;
}
No errors but the filter is not working. The "Catagory" field on the parent form is a choice field, does that make a differance?
Hello,
Please, make sure that you don't have JS-errors or notifications in the browser console when you expand the lookup drop-down. Try to wrap "Client" into single quotes:
Please, make sure that you don't have JS-errors or notifications in the browser console when you expand the lookup drop-down. Try to wrap "Client" into single quotes:
Code: Select all
function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,
{LookupField}&$orderby=Title&filter=Catagory eq 'Client'";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&
$orderby={LookupField}&$filter=startswith({LookupField}, '" + term + "') and Catagory eq 'Client'";
}
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
For my sample I've used a choice field too. Please, try to wrap your fltr variable into single quotes as in my sample. Make sure that there are no notifications in the browser console when you expand drop-down.
Current script:
function (term, page) {
var utype = fd.field('Update_x0020_Type').control().value();
var fltr = ' '
if (utype == 'Opportunity Update') {
fltr = 'Client'
}
if (utype == 'Lead Update') {
fltr = 'Potential Client'
}
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Catagory&$orderby=Title&$filter=Catagory eq " + fltr + "&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Catagory&$orderby={LookupField}&$filter=startswith({LookupField}, '" + term + "')and Catagory eq " + fltr + "&$top=10";
}
The browser console returns this error:
An error has occured during retrieving results. Column 'Client' does not exist. It may have been deleted by another user.
Thank you
function (term, page) {
var utype = fd.field('Update_x0020_Type').control().value();
var fltr = ' '
if (utype == 'Opportunity Update') {
fltr = 'Client'
}
if (utype == 'Lead Update') {
fltr = 'Potential Client'
}
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Catagory&$orderby=Title&$filter=Catagory eq " + fltr + "&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Catagory&$orderby={LookupField}&$filter=startswith({LookupField}, '" + term + "')and Catagory eq " + fltr + "&$top=10";
}
The browser console returns this error:
An error has occured during retrieving results. Column 'Client' does not exist. It may have been deleted by another user.
Thank you
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Please, put 'fltr' in quotes:
Code: Select all
function (term, page) {
var utype = fd.field('Update_x0020_Type').control().value();
var fltr = ' '
if (utype == 'Opportunity Update') {
fltr = 'Client'
}
if (utype == 'Lead Update') {
fltr = 'Potential Client'
}
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,
{LookupField},Catagory&$orderby=Title&
$filter=Catagory eq '" + fltr + "'&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Catagory&$orderby=
{LookupField}&$filter=startswith({LookupField}, '" + term + "') and
Catagory eq '" + fltr + "'&$top=10";
}
-
- Information
-
Who is online
Users browsing this forum: No registered users and 9 guests