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
Malli GMalli G 

how to display a string value in place of lookupfield in detailpage?

i have an account and contact object, if i didn't select "Account lookup" in "contact", after saving the record i want to display a string value in place of "account name"  in detail page using triggers.
claperclaper
the "Account Name" is a lookup field, which means you cannot input a place holder string into it. It always need to be a reference to an account record. One thing you could do, is to create an account for this purpose say "General Account" and then using a before insert trigger fill in the Account field ; something like this:
 
trigger contact_actions on Contact (before insert){
      //query the general Account id
      Id generalAccountId = [Select Id from Account where name = 'General Account'].id;

      //loop through contacts being inserted
      for(Contact thisContact: Trigger.new){
             //verify if the account lookup was left empty
             if(thisContact.AccountId == null)
                   thisContact.AccountId = generalAccountID;
      }
}

 
Arun KumarArun Kumar
Hi Malli,

You can create anew custom field of text type then assign your string to it. And change the PageLayoyt accordingly.

thanks,
Arun