RE: [OzMOSS] RE: How to Retrieve Lookup Fields - Solution
All, I have found out how to do this. You need to use the SPFieldLookupValue class. The following code retrieves the Field from the SPListItem and puts it into an SPFieldLookupValue object. You can then use the LookupValue property to retrieve the string value or the LookupId to retrieve the ID value. SPFieldLookupValue myLookupValue = new SPFieldLookupValue(myItem["mylookupvaluefield"].ToString()); string theStringValue = myLookupValue.LookupValue; Cheers, David From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Prior, David Sent: Monday, 23 July 2007 2:25 PM To: listserver@ozMOSS.com Subject: RE: [OzMOSS] RE: How to Retrieve Lookup Fields Aaron, I can write some CAML query to lookup the values in the lookup list but I still need to be able to compare those values with the one stored in the field of the SPListItem. How do I compare them? Ultimately, I just want to retrieve the string part (not the id part) value from the lookup Field stored on the SPListItem. Cheers, David From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Aaron Saikovski Sent: Monday, 23 July 2007 2:05 PM To: listserver@ozMOSS.com Subject: [OzMOSS] RE: How to Retrieve Lookup Fields Hi David, The easiest way i have found in the past is to use CAML. Try the CAML builder: http://www.u2u.info/Blogs/Patrick/Lists/Posts/Post.aspx?ID=1315 Cheers, Aaron Regards, Aaron Saikovski Readify - Senior Consultant M: +61 410 480 971 C: [EMAIL PROTECTED] From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Prior, David Sent: Monday, 23 July 2007 1:29 PM To: listserver@ozMOSS.com Subject: [OzMOSS] How to Retrieve Lookup Fields I am using MOSS 2007 WSS 3 and am trying to access the string representation of a lookup column in a list item. I want to retrieve the string value but it's a Lookup column and all I can show up is "1;#Canberra" which is the lookup id and the string. How do I just display the string value of Canberra? Do I have to go back to the originating list that the lookup column is using? Cheers, David This communication may contain confidential information and/or copyright material of KAZ Group Pty Ltd ABN 25 002 124 405 and its related bodies corporate. It may also be the subject of legal professional privilege. If you are not an intended recipient, you must not keep, forward, copy, use, save or rely on this communication and any such action is unauthorised and prohibited. If you have received this communication in error, please reply to this e-mail to notify the sender of its incorrect delivery, and then delete both it and your reply. --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net This communication may contain confidential information and/or copyright material of KAZ Group Pty Ltd ABN 25 002 124 405 and its related bodies corporate. It may also be the subject of legal professional privilege. If you are not an intended recipient, you must not keep, forward, copy, use, save or rely on this communication and any such action is unauthorised and prohibited. If you have received this communication in error, please reply to this e-mail to notify the sender of its incorrect delivery, and then delete both it and your reply. --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net This communication may contain confidential information and/or copyright material of KAZ Group Pty Ltd ABN 25 002 124 405 and its related bodies corporate. It may also be the subject of legal professional privilege. If you are not an intended recipient, you must not keep, forward, copy, use, save or rely on this communication and any such action is unauthorised and prohibited. If you have received this communication in error, please reply to this e-mail to notify the sender of its incorrect delivery, and then delete both it and your reply. --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net
RE: [OzMOSS] RE: How to Retrieve Lookup Fields
Hi David, >From memory that's how I got it to work...substring...i will see if there is >another way to solve this in my bag of tricks :-) Cheers, Aaron -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hoefel, Steven Sent: Monday, 23 July 2007 2:26 PM To: listserver@ozMOSS.com Subject: RE: [OzMOSS] RE: How to Retrieve Lookup Fields David, After fighting with this a bit, We simply used a substring that starts from the position of the # + 1. It's a dodgy method and you should check that the string length is appropriate, but it does work. Thanks, Steven. -Original Message- From: [EMAIL PROTECTED] on behalf of Prior, David Sent: Mon 23/07/2007 2:24 PM To: listserver@ozMOSS.com Subject: RE: [OzMOSS] RE: How to Retrieve Lookup Fields Aaron, I can write some CAML query to lookup the values in the lookup list but I still need to be able to compare those values with the one stored in the field of the SPListItem. How do I compare them? Ultimately, I just want to retrieve the string part (not the id part) value from the lookup Field stored on the SPListItem. Cheers, David From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Aaron Saikovski Sent: Monday, 23 July 2007 2:05 PM To: listserver@ozMOSS.com Subject: [OzMOSS] RE: How to Retrieve Lookup Fields Hi David, The easiest way i have found in the past is to use CAML. Try the CAML builder: http://www.u2u.info/Blogs/Patrick/Lists/Posts/Post.aspx?ID=1315 Cheers, Aaron Regards, Aaron Saikovski Readify - Senior Consultant M: +61 410 480 971 C: [EMAIL PROTECTED] From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Prior, David Sent: Monday, 23 July 2007 1:29 PM To: listserver@ozMOSS.com Subject: [OzMOSS] How to Retrieve Lookup Fields I am using MOSS 2007 WSS 3 and am trying to access the string representation of a lookup column in a list item. I want to retrieve the string value but it's a Lookup column and all I can show up is "1;#Canberra" which is the lookup id and the string. How do I just display the string value of Canberra? Do I have to go back to the originating list that the lookup column is using? Cheers, David This communication may contain confidential information and/or copyright material of KAZ Group Pty Ltd ABN 25 002 124 405 and its related bodies corporate. It may also be the subject of legal professional privilege. If you are not an intended recipient, you must not keep, forward, copy, use, save or rely on this communication and any such action is unauthorised and prohibited. If you have received this communication in error, please reply to this e-mail to notify the sender of its incorrect delivery, and then delete both it and your reply. --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net This communication may contain confidential information and/or copyright material of KAZ Group Pty Ltd ABN 25 002 124 405 and its related bodies corporate. It may also be the subject of legal professional privilege. If you are not an intended recipient, you must not keep, forward, copy, use, save or rely on this communication and any such action is unauthorised and prohibited. If you have received this communication in error, please reply to this e-mail to notify the sender of its incorrect delivery, and then delete both it and your reply. --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net
RE: [OzMOSS] RE: How to Retrieve Lookup Fields
David, After fighting with this a bit, We simply used a substring that starts from the position of the # + 1. It's a dodgy method and you should check that the string length is appropriate, but it does work. Thanks, Steven. -Original Message- From: [EMAIL PROTECTED] on behalf of Prior, David Sent: Mon 23/07/2007 2:24 PM To: listserver@ozMOSS.com Subject: RE: [OzMOSS] RE: How to Retrieve Lookup Fields Aaron, I can write some CAML query to lookup the values in the lookup list but I still need to be able to compare those values with the one stored in the field of the SPListItem. How do I compare them? Ultimately, I just want to retrieve the string part (not the id part) value from the lookup Field stored on the SPListItem. Cheers, David From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Aaron Saikovski Sent: Monday, 23 July 2007 2:05 PM To: listserver@ozMOSS.com Subject: [OzMOSS] RE: How to Retrieve Lookup Fields Hi David, The easiest way i have found in the past is to use CAML. Try the CAML builder: http://www.u2u.info/Blogs/Patrick/Lists/Posts/Post.aspx?ID=1315 Cheers, Aaron Regards, Aaron Saikovski Readify - Senior Consultant M: +61 410 480 971 C: [EMAIL PROTECTED] From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Prior, David Sent: Monday, 23 July 2007 1:29 PM To: listserver@ozMOSS.com Subject: [OzMOSS] How to Retrieve Lookup Fields I am using MOSS 2007 WSS 3 and am trying to access the string representation of a lookup column in a list item. I want to retrieve the string value but it's a Lookup column and all I can show up is "1;#Canberra" which is the lookup id and the string. How do I just display the string value of Canberra? Do I have to go back to the originating list that the lookup column is using? Cheers, David This communication may contain confidential information and/or copyright material of KAZ Group Pty Ltd ABN 25 002 124 405 and its related bodies corporate. It may also be the subject of legal professional privilege. If you are not an intended recipient, you must not keep, forward, copy, use, save or rely on this communication and any such action is unauthorised and prohibited. If you have received this communication in error, please reply to this e-mail to notify the sender of its incorrect delivery, and then delete both it and your reply. --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net This communication may contain confidential information and/or copyright material of KAZ Group Pty Ltd ABN 25 002 124 405 and its related bodies corporate. It may also be the subject of legal professional privilege. If you are not an intended recipient, you must not keep, forward, copy, use, save or rely on this communication and any such action is unauthorised and prohibited. If you have received this communication in error, please reply to this e-mail to notify the sender of its incorrect delivery, and then delete both it and your reply. --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net <>
RE: [OzMOSS] RE: How to Retrieve Lookup Fields
Aaron, I can write some CAML query to lookup the values in the lookup list but I still need to be able to compare those values with the one stored in the field of the SPListItem. How do I compare them? Ultimately, I just want to retrieve the string part (not the id part) value from the lookup Field stored on the SPListItem. Cheers, David From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Aaron Saikovski Sent: Monday, 23 July 2007 2:05 PM To: listserver@ozMOSS.com Subject: [OzMOSS] RE: How to Retrieve Lookup Fields Hi David, The easiest way i have found in the past is to use CAML. Try the CAML builder: http://www.u2u.info/Blogs/Patrick/Lists/Posts/Post.aspx?ID=1315 Cheers, Aaron Regards, Aaron Saikovski Readify - Senior Consultant M: +61 410 480 971 C: [EMAIL PROTECTED] From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Prior, David Sent: Monday, 23 July 2007 1:29 PM To: listserver@ozMOSS.com Subject: [OzMOSS] How to Retrieve Lookup Fields I am using MOSS 2007 WSS 3 and am trying to access the string representation of a lookup column in a list item. I want to retrieve the string value but it's a Lookup column and all I can show up is "1;#Canberra" which is the lookup id and the string. How do I just display the string value of Canberra? Do I have to go back to the originating list that the lookup column is using? Cheers, David This communication may contain confidential information and/or copyright material of KAZ Group Pty Ltd ABN 25 002 124 405 and its related bodies corporate. It may also be the subject of legal professional privilege. If you are not an intended recipient, you must not keep, forward, copy, use, save or rely on this communication and any such action is unauthorised and prohibited. If you have received this communication in error, please reply to this e-mail to notify the sender of its incorrect delivery, and then delete both it and your reply. --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net This communication may contain confidential information and/or copyright material of KAZ Group Pty Ltd ABN 25 002 124 405 and its related bodies corporate. It may also be the subject of legal professional privilege. If you are not an intended recipient, you must not keep, forward, copy, use, save or rely on this communication and any such action is unauthorised and prohibited. If you have received this communication in error, please reply to this e-mail to notify the sender of its incorrect delivery, and then delete both it and your reply. --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net
[OzMOSS] RE: How to Retrieve Lookup Fields
Hi David, The easiest way i have found in the past is to use CAML. Try the CAML builder: http://www.u2u.info/Blogs/Patrick/Lists/Posts/Post.aspx?ID=1315 Cheers, Aaron Regards, Aaron Saikovski Readify - Senior Consultant M: +61 410 480 971 C: [EMAIL PROTECTED] From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Prior, David Sent: Monday, 23 July 2007 1:29 PM To: listserver@ozMOSS.com Subject: [OzMOSS] How to Retrieve Lookup Fields I am using MOSS 2007 WSS 3 and am trying to access the string representation of a lookup column in a list item. I want to retrieve the string value but it's a Lookup column and all I can show up is "1;#Canberra" which is the lookup id and the string. How do I just display the string value of Canberra? Do I have to go back to the originating list that the lookup column is using? Cheers, David This communication may contain confidential information and/or copyright material of KAZ Group Pty Ltd ABN 25 002 124 405 and its related bodies corporate. It may also be the subject of legal professional privilege. If you are not an intended recipient, you must not keep, forward, copy, use, save or rely on this communication and any such action is unauthorised and prohibited. If you have received this communication in error, please reply to this e-mail to notify the sender of its incorrect delivery, and then delete both it and your reply. --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net --- OzMOSS.com - to unsubscribe from this list, send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by www.readify.net