SOLVED

Get user name using List view component?

%3CLINGO-SUB%20id%3D%22lingo-sub-388812%22%20slang%3D%22en-US%22%3EGet%20user%20name%20using%20List%20view%20component%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-388812%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20get%20the%20user%20name%20(display%20name)%20from%20a%20people%20column%20in%20a%20spfx%20web%20part%20using%20the%20List%20view%20component%20but%20I%20am%20getting%20undefined.%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20column%20calls%20SalesManager%20(internal%20name)%20and%20I%20am%20fetching%20its%20data%20like%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CPRE%3E%3CSPAN%3Econst%3C%2FSPAN%3E%20%3CSPAN%3Eitems%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3Eawait%3C%2FSPAN%3E%20%3CSPAN%3Esp%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Eweb%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Elists%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EgetById%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E'823e0102-5928-4f8a-bcda-f1794bd9026b'%3C%2FSPAN%3E%3CSPAN%3E).%3C%2FSPAN%3E%3CSPAN%3Eitems%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20.%3C%2FSPAN%3E%3CSPAN%3Eselect%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3Eselect%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20.%3C%2FSPAN%3E%3CSPAN%3Eget%3C%2FSPAN%3E%3CSPAN%3E()%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3Eitems%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EforEach%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3Eitem%3C%2FSPAN%3E%20%3CSPAN%3E%3D%26gt%3B%3C%2FSPAN%3E%3CSPAN%3E%20%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20Agreements%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Epush%3C%2FSPAN%3E%3CSPAN%3E(%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20SalesManager%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3ESalesManager%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%7D)%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%7D)%3B%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3EAnd%20then%20unsing%20the%20received%20data%20like%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CPRE%3E%3CSPAN%3Eprivate%3C%2FSPAN%3E%20%3CSPAN%3EviewFields%3C%2FSPAN%3E%3CSPAN%3E%3A%3C%2FSPAN%3E%20%3CSPAN%3EIViewField%3C%2FSPAN%3E%3CSPAN%3E%5B%5D%20%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%20%5B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20name%3A%3C%2FSPAN%3E%20%3CSPAN%3E%22SalesManager%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20displayName%3A%3C%2FSPAN%3E%20%3CSPAN%3E%22Sales%20Manager%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20isResizable%3A%3C%2FSPAN%3E%20%3CSPAN%3Etrue%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3CSPAN%3E%5D%3B%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3EIn%20the%20render%20method%3A%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CPRE%3E%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3EListView%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20items%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%7Bthis%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Estate%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Eagreements%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%2F%26gt%3B%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3EThere%20are%20more%20items%20that%20shows%20in%20the%20list%20view%20but%20SalesManager%20is%20the%20one%20that%20is%20causing%20problems.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20take%20a%20look%20to%20the%20console%20the%20SalesManager%20is%20undefined.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20can%20I%20get%20the%20display%20name%3F%20Do%20I%20need%20to%20do%20something%20special%20in%20the%20fetching%20part%20%3F%26nbsp%3B%3C%2FP%3E%3CP%3EBest%20regards%3C%2FP%3E%3CP%3EAmerico%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-388812%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-401296%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20user%20name%20using%20List%20view%20component%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-401296%22%20slang%3D%22en-US%22%3EThanks%20for%20the%20answer.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-394384%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20user%20name%20using%20List%20view%20component%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-394384%22%20slang%3D%22en-US%22%3E%3CP%3EI%20found%20the%20problem.%3C%2FP%3E%3CP%3EI%20was%20fetching%20item.id%20and%20the%20right%20one%20is%20item.Id%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20is%20working%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-394297%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20user%20name%20using%20List%20view%20component%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-394297%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F117034%22%20target%3D%22_blank%22%3E%40Americo%20Perez%3C%2FA%3E%26nbsp%3BAre%20you%20selecting%20the%20Id%20column%20from%20the%20original%26nbsp%3B%20item%20in%20your%20select%20query%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-394164%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20user%20name%20using%20List%20view%20component%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-394164%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F39836%22%20target%3D%22_blank%22%3E%40Beau%20Cameron%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20tried%20to%20build%20the%20url%20but%20I%20can't%20set%20the%20ID%20in%20the%20url%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20how%20the%20url%20looks%20like%3A%3C%2FP%3E%3CPRE%3Ehttps%3A%2F%2Ftenant.sharepoint.com%2Fsites%2FDemo2%2FLists%2FAgreementDatabase%2FDispForm.aspx%3FID%3D1%3C%2FPRE%3E%3CP%3EAnd%20in%20my%20code%20I%20am%20trying%20like%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CPRE%3E%3CSPAN%3Erender%3C%2FSPAN%3E%3CSPAN%3E%3A%3C%2FSPAN%3E%3CSPAN%3E%20(%3C%2FSPAN%3E%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E%3A%3C%2FSPAN%3E%20%3CSPAN%3EIList%3C%2FSPAN%3E%3CSPAN%3E)%20%3C%2FSPAN%3E%3CSPAN%3E%3D%26gt%3B%3C%2FSPAN%3E%3CSPAN%3E%20%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20return%3C%2FSPAN%3E%3CSPAN%3E%20(%3C%2FSPAN%3E%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3Ea%3C%2FSPAN%3E%20%3CSPAN%3Ehref%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CSPAN%3E%60https%3A%2F%2Ftenant.sharepoint.com%2Fsites%2FDemo2%2FLists%2FAgreementDatabase%2FDispForm.aspx%3FID%3D%3C%2FSPAN%3E%3CSPAN%3E%24%7B%3C%2FSPAN%3E%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EId%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3CSPAN%3E%60%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3ETitle%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3CSPAN%3E%3CSPAN%3Ea%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3CSPAN%3E)%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FPRE%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ebut%20I%20am%20getting%20undefined%20in%20the%20item.Id%26nbsp%3B%20%3A%5C%3C%2Fimg%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20see%20in%20the%20console%20the%20right%20ID%20when%20I%20set%20the%20console%20just%20before%20the%20return%20statement%20but%20I%20don't%20know%20why%20is%20not%20getting%20passed%20to%20the%20url%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegrards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-390295%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20user%20name%20using%20List%20view%20component%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-390295%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F117034%22%20target%3D%22_blank%22%3E%40Americo%20Perez%3C%2FA%3E%26nbsp%3BThe%20title%20is%20just%20a%20text%20field.%26nbsp%3B%20You%20can%20construct%20the%20URL%20via%20the%20URl%20to%20the%20Form%20%2B%20the%20ID%20of%20the%20item%20if%20you%20want.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-389756%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20user%20name%20using%20List%20view%20component%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-389756%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F39836%22%20target%3D%22_blank%22%3E%40Beau%20Cameron%3C%2FA%3E%26nbsp%3B%2C%20now%20can%20I%20render%20the%20names.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJust%20one%20last%20thing%2C%20the%20title%20column%20should%20show%20the%20name%20of%20the%20item%20linking%20to%20the%20item%20it%20self%20but%20in%20my%20case%20the%20title%20shows%20as%20a%20single%20text%2C%20the%20link%20is%20missing%2C%20do%20I%20need%20to%20do%20something%20special%20to%20render%20the%20title%20linking%20to%20the%20item%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-389391%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20user%20name%20using%20List%20view%20component%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-389391%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F117034%22%20target%3D%22_blank%22%3E%40Americo%20Perez%3C%2FA%3E%26nbsp%3BI%20can%20see%20that%2C%20but%20that%20is%20not%20how%20the%20REST%20call%20works.%20It's%20a%20complex%20field%20type%20that%20you%20need%20to%20expand%20on%20to%20get%20it's%20values.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-389196%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20user%20name%20using%20List%20view%20component%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-389196%22%20slang%3D%22en-US%22%3E%3CP%3ETahanks%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F39836%22%20target%3D%22_blank%22%3E%40Beau%20Cameron%3C%2FA%3E%26nbsp%3B%2C%20right%20now%20I%20am%20selecting%20everything%3A%3C%2FP%3E%3CDIV%3E%3CPRE%3E%3CSPAN%3Epublic%3C%2FSPAN%3E%20%3CSPAN%3Easync%3C%2FSPAN%3E%20%3CSPAN%3EgetAgreements%3C%2FSPAN%3E%3CSPAN%3E()%3C%2FSPAN%3E%3CSPAN%3E%3A%3C%2FSPAN%3E%20%3CSPAN%3EPromise%3C%2FSPAN%3E%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3EAgreement%3C%2FSPAN%3E%3CSPAN%3E%5B%5D%26gt%3B%20%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20let%3C%2FSPAN%3E%20%3CSPAN%3Eselect%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E'*'%3C%2FSPAN%3E%3CSPAN%3E%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20let%3C%2FSPAN%3E%20%3CSPAN%3EAgreements%3C%2FSPAN%3E%3CSPAN%3E%3A%3C%2FSPAN%3E%20%3CSPAN%3EAgreement%3C%2FSPAN%3E%3CSPAN%3E%5B%5D%20%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%20%5B%5D%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20const%3C%2FSPAN%3E%20%3CSPAN%3Eitems%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3Eawait%3C%2FSPAN%3E%20%3CSPAN%3Esp%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Eweb%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Elists%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EgetById%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E'823e0102-5928-4f8a-bcda-f1794bd9026b'%3C%2FSPAN%3E%3CSPAN%3E).%3C%2FSPAN%3E%3CSPAN%3Eitems%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Eselect%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3Eselect%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Eget%3C%2FSPAN%3E%3CSPAN%3E()%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20items%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EforEach%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3Eitem%3C%2FSPAN%3E%20%3CSPAN%3E%3D%26gt%3B%3C%2FSPAN%3E%3CSPAN%3E%20%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Agreements%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3Epush%3C%2FSPAN%3E%3CSPAN%3E(%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Title%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3ETitle%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20AgreementName%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3ETitle%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20CustomerAgreementNr%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3ECustomerAgreementNr%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20AgreementType%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EAgreementType%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20SalesManager%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3ESalesManagerId%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ContactPerson%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EContactPerson%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20DeliveryType%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EDeliveryType%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20AgreementStartDate%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EAgreementStartDate%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20AgreementEndDate%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EAgreementEndDate%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20AgreementEnded%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EAgreementEnded%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20LastPriceAdjustment%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3ELastPriceAdjustment%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20NextPriceAdjustment%3A%3C%2FSPAN%3E%20%3CSPAN%3Eitem%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3ENextPriceAdjustment%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D)%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20%20%7D)%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20return%3C%2FSPAN%3E%20%3CSPAN%3Enew%3C%2FSPAN%3E%20%3CSPAN%3EPromise%3C%2FSPAN%3E%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3EAgreement%3C%2FSPAN%3E%3CSPAN%3E%5B%5D%26gt%3B(%3C%2FSPAN%3E%3CSPAN%3Easync%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3Eresolve%3C%2FSPAN%3E%3CSPAN%3E)%20%3C%2FSPAN%3E%3CSPAN%3E%3D%26gt%3B%3C%2FSPAN%3E%3CSPAN%3E%20%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%20%20%20%20%20%20%20resolve%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3EAgreements%3C%2FSPAN%3E%3CSPAN%3E)%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%7D)%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%20%7D%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3ERegards!%3C%2FP%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-389072%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20user%20name%20using%20List%20view%20component%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-389072%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F117034%22%20target%3D%22_blank%22%3E%40Americo%20Perez%3C%2FA%3E%26nbsp%3BCan%20you%20share%20what%20your%20select%20value%20is%3F%20Person%20field%20is%20complex%20field%20type%2C%20that%20you%20need%20to%20select%20the%20properties%20and%20expand%20on%20the%20field.%3C%2FP%3E%0A%3CPRE%3E%20.select('SalesManager%2FFirstName%2C%20SalesManager%2FLastName').expand('SalesManager')%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Regular Contributor

Hi,

I am trying to get the user name (display name) from a people column in a spfx web part using the List view component but I am getting undefined. 

The column calls SalesManager (internal name) and I am fetching its data like this:

 

const items = await sp.web.lists.getById('823e0102-5928-4f8a-bcda-f1794bd9026b').items
.select(select)
.get();
items.forEach(item => {
Agreements.push({
SalesManager: item.SalesManager,
});
});

And then unsing the received data like this:

 

private viewFields: IViewField[] = [
{
name: "SalesManager",
displayName: "Sales Manager",
isResizable: true,
}];

In the render method: 

<ListView
items = {this.state.agreements}
/>

There are more items that shows in the list view but SalesManager is the one that is causing problems. 

 

When I take a look to the console the SalesManager is undefined. 

 

How can I get the display name? Do I need to do something special in the fetching part ? 

Best regards

Americo

9 Replies
best response confirmed by Americo Perez (Regular Contributor)
Solution

@Americo Perez Can you share what your select value is? Person field is complex field type, that you need to select the properties and expand on the field.

 .select('SalesManager/FirstName, SalesManager/LastName').expand('SalesManager')

Tahanks @Beau Cameron , right now I am selecting everything:

public async getAgreements(): Promise<Agreement[]> {
let select = '*';
let Agreements: Agreement[] = [];
const items = await sp.web.lists.getById('823e0102-5928-4f8a-bcda-f1794bd9026b').items.select(select).get();
items.forEach(item => {
Agreements.push({
Title: item.Title,
AgreementName: item.Title,
CustomerAgreementNr: item.CustomerAgreementNr,
AgreementType: item.AgreementType,
SalesManager: item.SalesManagerId,
ContactPerson: item.ContactPerson,
DeliveryType: item.DeliveryType,
AgreementStartDate: item.AgreementStartDate,
AgreementEndDate: item.AgreementEndDate,
AgreementEnded: item.AgreementEnded,
LastPriceAdjustment: item.LastPriceAdjustment,
NextPriceAdjustment: item.NextPriceAdjustment,
});
});
return new Promise<Agreement[]>(async(resolve) => {
resolve(Agreements);
});
}

Regards!

@Americo Perez I can see that, but that is not how the REST call works. It's a complex field type that you need to expand on to get it's values.

Thanks @Beau Cameron , now can I render the names.

 

Just one last thing, the title column should show the name of the item linking to the item it self but in my case the title shows as a single text, the link is missing, do I need to do something special to render the title linking to the item? 

 

Regards!

@Americo Perez The title is just a text field.  You can construct the URL via the URl to the Form + the ID of the item if you want.

Thanks, @Beau Cameron 

 

I've tried to build the url but I can't set the ID in the url

 

This is how the url looks like:

https://tenant.sharepoint.com/sites/Demo2/Lists/AgreementDatabase/DispForm.aspx?ID=1

And in my code I am trying like this:

 

render: (item: IList) => {
return (<a href={`https://tenant.sharepoint.com/sites/Demo2/Lists/AgreementDatabase/DispForm.aspx?ID=${item.Id}`}>{item.Title}</a>);
}

 

but I am getting undefined in the item.Id  :\ 

I can see in the console the right ID when I set the console just before the return statement but I don't know why is not getting passed to the url

 

Regrards

@Americo Perez Are you selecting the Id column from the original  item in your select query?

I found the problem.

I was fetching item.id and the right one is item.Id 

 

Now is working

 

 

Thanks for the answer.