@@ -8,8 +8,8 @@ import { IContentTypesOptions, IFieldsOptions, ILibsOptions, ISPService, LibsOrd
8
8
9
9
interface ICachedListItems {
10
10
// eslint-disable-next-line @typescript-eslint/no-explicit-any
11
- items : any [ ] ;
12
- expiration : number ;
11
+ items : any [ ] ;
12
+ expiration : number ;
13
13
}
14
14
15
15
export default class SPService implements ISPService {
@@ -194,16 +194,16 @@ export default class SPService implements ISPService {
194
194
* Get List Items
195
195
*/
196
196
public async getListItems (
197
- filterText : string ,
198
- listId : string ,
199
- internalColumnName : string ,
200
- field : ISPField | undefined ,
201
- keyInternalColumnName ?: string ,
202
- webUrl ?: string ,
203
- filterString ?: string ,
204
- substringSearch : boolean = false ,
205
- orderBy ?: string ,
206
- cacheInterval : number = 1 ) : Promise < any [ ] > { // eslint-disable-line @typescript-eslint/no-explicit-any
197
+ filterText : string ,
198
+ listId : string ,
199
+ internalColumnName : string ,
200
+ field : ISPField | undefined ,
201
+ keyInternalColumnName ?: string ,
202
+ webUrl ?: string ,
203
+ filterString ?: string ,
204
+ substringSearch : boolean = false ,
205
+ orderBy ?: string ,
206
+ cacheInterval : number = 1 ) : Promise < any [ ] > { // eslint-disable-line @typescript-eslint/no-explicit-any
207
207
const webAbsoluteUrl = ! webUrl ? this . _webAbsoluteUrl : webUrl ;
208
208
let apiUrl = '' ;
209
209
let isPost = false ;
@@ -538,9 +538,18 @@ export default class SPService implements ISPService {
538
538
const result = await data . json ( ) ;
539
539
if ( result && result [ fieldName ] ) {
540
540
const lookups = [ ] ;
541
- result [ fieldName ] . forEach ( element => {
542
- lookups . push ( { key : element . ID , name : element [ lookupFieldName || 'Title' ] } ) ;
543
- } ) ;
541
+ const isArray = Array . isArray ( result [ fieldName ] ) ;
542
+ //multiselect lookups return arrays
543
+ if ( isArray ) {
544
+ result [ fieldName ] . forEach ( element => {
545
+ lookups . push ( { key : element . ID , name : element [ lookupFieldName || 'Title' ] } ) ;
546
+ } ) ;
547
+ }
548
+ //single select lookups return objects
549
+ else {
550
+ const singleItem = result [ fieldName ] ;
551
+ lookups . push ( { key : singleItem . ID , name : singleItem [ lookupFieldName || 'Title' ] } ) ;
552
+ }
544
553
return lookups ;
545
554
}
546
555
}
@@ -607,8 +616,8 @@ export default class SPService implements ISPService {
607
616
const result = await data . json ( ) ;
608
617
if ( result && result [ fieldName ] ) {
609
618
const element = result [ fieldName ]
610
- const loginNameWithoutClaimsToken = element . Name . split ( "|" ) . pop ( ) ;
611
- return loginNameWithoutClaimsToken + "/" + element . Title ;
619
+ const loginNameWithoutClaimsToken = element . Name . split ( "|" ) . pop ( ) ;
620
+ return loginNameWithoutClaimsToken + "/" + element . Title ;
612
621
}
613
622
}
614
623
0 commit comments