+ Start a Discussion
RDM1961RDM1961 

Custom button for conditional new record

Is it possible for a custom button to create a new record only if certain conditions are met and provide an error message if the conditions are not met?

 

I want to place the button on a related list on the account page and only allow a new record on non-Partner Portal accounts. Would be great if anyone has some code that might get me started. 

 

Thanks,

Rick

Navatar_DbSupNavatar_DbSup

Hi,

 

 You can create a button on the related list.

 

First of all the create list button in the object on which related list you want to display the button

 

After creating the list button add the list button in related list and the page layout by following the below steps:

search layouts->click on edit link of the List View->add the button

 

After adding the button you need to add the button in the related list also where you want to display the button

Edit the page layout of the object where you want to display the button

 

Go to the object related list ->click on the related list properties button ->click on the plus (+) of the buttons section add the custom button and click on save button

 

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

 

 

RDM1961RDM1961

Thanks Navatar, 

This will go on a related list on the account page, is there a way to check if the account is a Partner Portal account or not and to prevent the new record if yes?

 

 

b-Forceb-Force

you can create Javascript button,

 

If you provide related API names and new related record url, 

 

Check your messagebox

 

Thanks,

bForce

 

 

 

 

dev_firedev_fire

Hi Rick,

 

This is achievable by developing a VF page. You will then have to create a custom List button & add it to Activity related list by editing pagelayout related list section.

 

  1. Create a VF & Apex class in which you can write the logic & perform the checks.
  2.  You can create a button on the related list.

     

    • First of all the create list button in the object on which related list you want to display the button[Select VF page]
    •  After creating the list button add the list button in related list and the page layout by following the below steps
    • Edit the page layout of the object where you want to display the button
    • Go to the object related list ->click on the related list properties button ->click on the plus (+) of the buttons section add the custom button and click on save button

 

If my solution worked for you mark it as resolved.

 

Thanks.