Re: Using a field in the list to filter a lookup
Posted: 09 Jul 2018
Ugh. My test worked, but then when put exactly the same syntax in the "real" lookup, I get the spinning disk... no error. It is probably something silly I missed. I verified the internal names etc...
function (term, page) {
// Getting the selected country
var countryId = fd.field('ContractorID').value();
if (!countryId) {
countryId = 0;
}
// Filtering by the selected country
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},ContractorEquipmentID/Id&$orderby=Created desc&$filter= ContractorEquipmentID eq " + countryId + "&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},ContractorEquipmentID/Id&$orderby={LookupField}&$filter=startswith({LookupField}, '" + term + "') and ContractorEquipmentID eq " + countryId + "&$top=10";
function (term, page) {
// Getting the selected country
var countryId = fd.field('ContractorID').value();
if (!countryId) {
countryId = 0;
}
// Filtering by the selected country
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},ContractorEquipmentID/Id&$orderby=Created desc&$filter= ContractorEquipmentID eq " + countryId + "&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},ContractorEquipmentID/Id&$orderby={LookupField}&$filter=startswith({LookupField}, '" + term + "') and ContractorEquipmentID eq " + countryId + "&$top=10";