You need to sign in to do that
Don't have an account?
How to hide related list button?
Hi,
How do i hide a related list standard button 'New Opportunity', when i choose picklist values?


Here, the related list button should visible only when i choose the values "REQ", "Solution Sale" in the picklist field 'Pre Opportunity Type' and the picklist Approval Status valus is "Approved".
Any possibilities(VF page, Trigger) other than assigning record type to different layout?
Thanks & Regards,
Karthikeyan Chandran
How do i hide a related list standard button 'New Opportunity', when i choose picklist values?
Here, the related list button should visible only when i choose the values "REQ", "Solution Sale" in the picklist field 'Pre Opportunity Type' and the picklist Approval Status valus is "Approved".
Any possibilities(VF page, Trigger) other than assigning record type to different layout?
Thanks & Regards,
Karthikeyan Chandran
Problem is that account not specified on your record, and instead of {!Account.Id} you have empty. You can add condition as "if ('{!Account.Id}')"
Try this code
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks,
Alex
All Answers
Apply some sort of JavaScript logic to create related opportunity record or display message.
Below is the JavaScript logic that you need to put in your button and change some of the logic based upon your requirements.
My JavaScript code is checking if Account industry is Energy then open window to create new opportunity else display popup message "you cannot create new oppty).
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}
if('{!Account.Industry}' == 'Energy'){
window.open('https://na9.salesforce.com/006/e?retURL=%{!Account.Id}&accid={!Account.Id}');
}
else{
alert('You can not create new oppty');
}
I just used the below script and i got an error,
In my URL:
https://cs50.salesforce.com/006/e?retURL=%&oppid=
The error message is:
Illegal Request
You have sent us an Illegal URL or an improperly formatted request.
I don't know what i am missing here.
Can you help me on this?
Thanks & Regards,
Karthikeyan Chandran
Problem is that account not specified on your record, and instead of {!Account.Id} you have empty. You can add condition as "if ('{!Account.Id}')"
Try this code
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks,
Alex
if you are checking more than one condition using if statement then you should have && or || between each condition within if statement.
I corrected your if condition please use above code and let me know if you get any error.
You also might need to correct your URL 'https//cs50.salesforce...........' based upon the business requirement and when you move this code to production you need to change https://cs50.salesforce.... to https://naXX.salesforcce.com where XX is your salesforce production instance number.