@@ -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 {
@@ -194,16 +194,16 @@ export default class SPService implements ISPService {
194194 * Get List Items
195195 */
196196 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
207207 const webAbsoluteUrl = ! webUrl ? this . _webAbsoluteUrl : webUrl ;
208208 let apiUrl = '' ;
209209 let isPost = false ;
@@ -538,9 +538,18 @@ export default class SPService implements ISPService {
538538 const result = await data . json ( ) ;
539539 if ( result && result [ fieldName ] ) {
540540 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+ }
544553 return lookups ;
545554 }
546555 }
@@ -607,8 +616,8 @@ export default class SPService implements ISPService {
607616 const result = await data . json ( ) ;
608617 if ( result && result [ fieldName ] ) {
609618 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 ;
612621 }
613622 }
614623
0 commit comments