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
DJ 367DJ 367 

Go to task from opportunity through custom button

Hello All,
Schrren shot for reference
I am working on opportunity and I have a custom button on opportunity as GoToTask. There is custom field on the opportnuity called Test which is a picklist field. It have two values : 1-Ok and 2- Not Ok . If Test field has value as OK then once I click on GoToTask button it should take me to opportunity's NEW TASK creation activity. If Test field has value as NOT OK then there should be a message saying "You can not goto Task". Pls help me to achieve this. I think this can be done thrugh JavaScript but I am not sure how to achieve this.

Thanks.
Best Answer chosen by DJ 367
Prashant Pandey07Prashant Pandey07
Hi

You can use code to solve your problem.
 
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")}

if('{!Opportunity.Test__c}' == 'OK' )
{
window.location.replace("/00T/e?who_id={!Opportunity.AccountId}&what_id={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}")

}
else{
alert('You can not goto Task')
}

--
Thanks,
Prashant

All Answers

Prashant Pandey07Prashant Pandey07
Hi

You can use code to solve your problem.
 
{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")}

if('{!Opportunity.Test__c}' == 'OK' )
{
window.location.replace("/00T/e?who_id={!Opportunity.AccountId}&what_id={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}")

}
else{
alert('You can not goto Task')
}

--
Thanks,
Prashant
This was selected as the best answer
DJ 367DJ 367
Hi  Prashant Pandey07,

Thank you so much for you reply and solution. Could you please help me how you did this? Can you refer me some good resource online thru I can understand completely.

Thanks 
Prashant Pandey07Prashant Pandey07
Hi..
you can email me your question prashant90.pandey@gmail.com

--
Thanks,
Prashant