+ Start a Discussion

Hide the Name field of a custom object from the page layout

Is there a way to not display the Name field of a custom object in the create/edit page layout?
We want to populate the Name field using a blend of info from other fields, so we can enforce naming convention (such as XYZ-[Account Name]-[date]). Have already created an S-control that does it uppon clicking the Save button. Now the only thing is we have to ask users to ignore the mandatory Name field... which really isn't intuitive since they are used to not leave any mandatory field blank.
Any idea ?
Sounds like you probably want to pre-populate the Name field when the object is first dislpayed in edit mode. This will display "something" in the field, that will be over-ridden when the save button is clicked.
One way is to just default the field to "Please Ignore". :smileyvery-happy:
Another way would be to tie your s-control to the link or button on the object that creates the new object. This will however allow the user to change the Name field before saving (unless you use a trigger on save or update to change it back to what you want).
Good Luck.
Sean Shannon

Thanks Sean. Having a temporary value pre-filled is a good idea.

Since you've kindly introduced me to triggers in another post, I'm trying to move from an S-control to a trigger to update the record name. It seems to me like a better option than overwriting the save button. However, there's a little something wrong with my trigger code. Instead of displaying the name of the parent acocunt, it displays it's ID... and I just can't figure how to fix (did I mention I have no programming background ?!). There possibly other weird things in this short piece of code, but except for the ID vs Name, it works !

trigger RenameTarget on Target__c(before insert) {
 Target__c[] newTarget = Trigger.new;
 newTarget[0].Name = 'Target ' + newTarget[0].Account__r.Name + ' ' + newTarget[0].Month__c + ' ' + newTarget[0].Year__c ; 


Thanks !


I would try using an SOQL statement to get the text name from the parent object Id (I am guessing it is an Account object)
Something like this:
trigger renameTarget on target__c (before insert, before update) {
  target__c[] newTarget = Trigger.new;

  // get a text name from the id
  String parentName = [select Name from Account where Id = :newTarget[0].ParentAccountId__c ].Name;

  newTarget[0].Name = 'Target ' + parentName; // plus other stuff 

 This is pretty ambitious stuff for a non programmer. I need to warn you that there needs to be a lot of support code for error checking and the like.