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
RoscoeRoscoe 

Remove/hide 'NEW' buttom from the related list

Folks -
Is there a way to remove/hide 'NEW' buttom from the related list based on certain conditions? For example, custom object A is a parent to custom object B. There is a custom field (picklist) on the object A  called 'Staus'. If the value is set to 'Approved', the users should not be able to create a new child record; for all ther statuses (In-Review, Oh-hold, etc...) the users should be able to create a new child record.
 
I know you can remove 'NEW' button from the related list by unclicking the proper box on the page layout, but it is all-or-none. I need some kind of dinamic logic...
 
Thank you in advance
jf317820jf317820
i suppose you could override the "new" button and inject your custom logic that way.  for example, when the user clicks the new button, some onclick javascript could run verifying that the parent record is not "approved."  If it checks out, you could direct the user to the "new" custom b record page.
RoscoeRoscoe

Thanks Jeff,

I will try... I was wondering though if it's possible to achieve similar outcome without JAVA code - using salesforce configuration only

sfdcfoxsfdcfox
Presuming you're in EE/UE/DE, you can create two workflow rules. One triggers if the account is a certain status, and the other for the other statuses. Then, you need two record types, and each record type would be linked to a different page layout. One layout would have the "New" button disabled, the other not. Finally, two field updates, one on each rule, that toggle the record type as appropriate. A bit confusing, at first, but it's really about a three to five minute setup. Then you're done.

~ sfdcfox ~
RoscoeRoscoe
Thank you - I thought about this approach. Problem is - we already have 20 page layouts for this particular object, so doubling this number would become a maintenance nightmare. I will use 'Custom Button' approach - thank you again for your help
Swaminathan GopalakrishnanSwaminathan Gopalakrishnan
Hi Roscoe. I have a similar problem with my development. I need to disable the new button on a related list when the status is "XYZ". Could you please share how you did it?