function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
arvinarvin 

Getting the text value frm lookup

public class MyItemLookup{
    public static void updateRelease(mt__Item_Lookup__c[] item){
        for(mt__Item_Lookup__c a:item){
            a=[select mt__Item__c from mt__Item_Lookup__c where mt__Item__c=:a.mt__Item__c];
            String name='!{a.mt__Item__c}';
            MyItem.updateRel(name);
        }
    }
}

 

Is it possible to get the text value of a lookup field ?

here mt__Item__c is the lookup field..

I have a requirement to pass the text value in the lookup field

to another apex class as a String parameter.

Please let me know if there is a way to achieve this....

Message Edited by arvin on 02-03-2009 10:13 PM
shillyershillyer

Why not create a new formula field that captures the value of the lookup. For instance, if you have a lookup to Opportunity, the formula field can be a text field mapped to Opportunity Name. You can then pass this value to your Apex Class.

 

Hope that helps,

Sati

arvinarvin
No it doesn't work. I have tried. While creating a formula field which is populated by a lookup field I am just getting some long id instead of the text in the lookup field
shillyershillyer

That is probably because your formula field is a text version of the lookup field, don't do that. Instead, the lookup displays in the web UI typically the name of the custom object, so your formula field should be comprised of that. That is why in my example, I say use Opportunity Name in the formula field, and not the Opportunity Lookup.

 

Hope that helps,

Sati