Crosssite Lookup Filter
Posted by Hubbaroo - Apr 4 ’14 at 10:38
I have been successfull with cascading the cross site lookups from this link http://formsdesigner.blogspot.com/2013/07/cascading-drop-downs-with-cross-site.html 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 + "')";
}
-
Dmitry KozlovAdminMember for: 10 years 1 day
Of which type is the Category field?
-
HubbarooMemberMember for: 10 years 2 days
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.
-
Dmitry KozlovAdminMember for: 10 years 1 day
[#2]: 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:
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'";
}
-
HubbarooMemberMember for: 10 years 2 days
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?
-
Dmitry KozlovAdminMember for: 10 years 1 day
[#4]: 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.
-
HubbarooMemberMember for: 10 years 2 days
[#5]: 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
-
Dmitry KozlovAdminMember for: 10 years 1 day
[#6]: Please, put 'fltr' in quotes:
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"; }