@@ -8,8 +8,8 @@ import { IContentTypesOptions, IFieldsOptions, ILibsOptions, ISPService, LibsOrd
88
99interface ICachedListItems {
1010 // eslint-disable-next-line @typescript-eslint/no-explicit-any
11- items : any [ ] ;
12- expiration : number ;
11+ items : any [ ] ;
12+ expiration : number ;
1313}
1414
1515export default class SPService implements ISPService {
@@ -211,16 +211,16 @@ export default class SPService implements ISPService {
211211 * Get List Items
212212 */
213213 public async getListItems (
214- filterText : string ,
215- listId : string ,
216- internalColumnName : string ,
217- field : ISPField | undefined ,
218- keyInternalColumnName ?: string ,
219- webUrl ?: string ,
220- filterString ?: string ,
221- substringSearch : boolean = false ,
222- orderBy ?: string ,
223- cacheInterval : number = 1 ) : Promise < any [ ] > { // eslint-disable-line @typescript-eslint/no-explicit-any
214+ filterText : string ,
215+ listId : string ,
216+ internalColumnName : string ,
217+ field : ISPField | undefined ,
218+ keyInternalColumnName ?: string ,
219+ webUrl ?: string ,
220+ filterString ?: string ,
221+ substringSearch : boolean = false ,
222+ orderBy ?: string ,
223+ cacheInterval : number = 1 ) : Promise < any [ ] > { // eslint-disable-line @typescript-eslint/no-explicit-any
224224 const webAbsoluteUrl = ! webUrl ? this . _webAbsoluteUrl : webUrl ;
225225 let apiUrl = '' ;
226226 let isPost = false ;
@@ -555,9 +555,18 @@ export default class SPService implements ISPService {
555555 const result = await data . json ( ) ;
556556 if ( result && result [ fieldName ] ) {
557557 const lookups = [ ] ;
558- result [ fieldName ] . forEach ( element => {
559- lookups . push ( { key : element . ID , name : element [ lookupFieldName || 'Title' ] } ) ;
560- } ) ;
558+ const isArray = Array . isArray ( result [ fieldName ] ) ;
559+ //multiselect lookups are arrays
560+ if ( isArray ) {
561+ result [ fieldName ] . forEach ( element => {
562+ lookups . push ( { key : element . ID , name : element [ lookupFieldName || 'Title' ] } ) ;
563+ } ) ;
564+ }
565+ //single select lookups are objects
566+ else {
567+ const singleItem = result [ fieldName ] ;
568+ lookups . push ( { key : singleItem . ID , name : singleItem [ lookupFieldName || 'Title' ] } ) ;
569+ }
561570 return lookups ;
562571 }
563572 }
@@ -624,8 +633,8 @@ export default class SPService implements ISPService {
624633 const result = await data . json ( ) ;
625634 if ( result && result [ fieldName ] ) {
626635 const element = result [ fieldName ]
627- const loginNameWithoutClaimsToken = element . Name . split ( "|" ) . pop ( ) ;
628- return loginNameWithoutClaimsToken + "/" + element . Title ;
636+ const loginNameWithoutClaimsToken = element . Name . split ( "|" ) . pop ( ) ;
637+ return loginNameWithoutClaimsToken + "/" + element . Title ;
629638 }
630639 }
631640
0 commit comments