Как получить текст из поискового столбца в Sharepoint Online? - PullRequest
0 голосов
/ 15 мая 2019

Код ниже работает, я наконец-то извлекаю данные из простого списка, проблема в том, что когда я получаю столбец поиска, он показывает объект вместо значения.


       var ProductInfo = '';
       var listItemEnum = collListItem.getEnumerator();
       var section = oListItem.get_item("Section");

           while (listItemEnum.moveNext()) {

               if (oListItem.get_item('Section') === 'Πειραιως Leasing'){

               }

               var oListItem = listItemEnum.get_current();

               ProductInfo += '\n\nID: '+ oListItem.get_id() +
                   '<\nTitle: ' + oListItem.get_item('Title') +
                   '\nLink: ' + oListItem.get_item('Link') +
                   '<\nSection>' + oListItem.get_item('Section').get_lookupValue();
       }

       var value = SP.FieldLookup.get_lookupField ('Section');
       console.log(value);

       alert(ProductInfo.toString());
   }

   function onQueryFailed(sender, args) {
       alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
   }
   </script><input type="button" value="Get Section" onclick="getSection()"/>```

1 Ответ

0 голосов
/ 15 мая 2019

Так как вы уже установили var section = oListItem.get_item ("Section"), используйте переменную снова.Это должно быть то, что вы ищете.

   var ProductInfo = '';
   var listItemEnum = collListItem.getEnumerator();

       while (listItemEnum.moveNext()) {

           if (oListItem.get_item('Section') === 'Πειραιως Leasing'){

           }

           var oListItem = listItemEnum.get_current();
           var section = oListItem.get_item("Section");
           ProductInfo += '\n\nID: '+ oListItem.get_id() +
               '<\nTitle: ' + oListItem.get_item('Title') +
               '\nLink: ' + oListItem.get_item('Link') +
               '<\nSection>' + section.get_lookupValue();
   }

     console.log(section.get_lookupId());
     console.log(section.get_lookupValue());

   alert(ProductInfo.toString());
   }
   function onQueryFailed(sender, args) {
       alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
   }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...