@@ -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 {
@@ -211,16 +211,16 @@ export default class SPService implements ISPService {
211
211
* Get List Items
212
212
*/
213
213
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
224
224
const webAbsoluteUrl = ! webUrl ? this . _webAbsoluteUrl : webUrl ;
225
225
let apiUrl = '' ;
226
226
let isPost = false ;
@@ -555,9 +555,18 @@ export default class SPService implements ISPService {
555
555
const result = await data . json ( ) ;
556
556
if ( result && result [ fieldName ] ) {
557
557
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
+ }
561
570
return lookups ;
562
571
}
563
572
}
@@ -624,8 +633,8 @@ export default class SPService implements ISPService {
624
633
const result = await data . json ( ) ;
625
634
if ( result && result [ fieldName ] ) {
626
635
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 ;
629
638
}
630
639
}
631
640
0 commit comments