You need to sign in to do that
Don't have an account?
Akash Garg 2
how to add one click javascript custom button and its functionality to salesforce1.
I have a one click javascript custom button on my opportunity page and I want to add that button on salesforce1.
Please help to add this button urgently.
ONE CLICK JAVASCRIPT code of that button is as follows:-
{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/23.0/apex.js")}
var cOpp = new sforce.SObject("Opportunity");
var QuoteRecord = sforce.connection.query("Select Opportunity__c,Id From Opportunity_Product__c where Opportunity__c='{!Opportunity.Id}'");
var records = QuoteRecord.getArray("records");
cOpp.Sales_Area__c = "{!Opportunity.Sales_Area__c}";
cOpp.NPD_Required__c = "{!Opportunity.NPD_Required__c}";
if(records[0] != null)
{
if(!((cOpp.Sales_Area__c == null) || (cOpp.Sales_Area__c == ''))){
if((cOpp.NPD_Required__c == true) || (cOpp.NPD_Required__c == 'true'))
window.open('apex/sendInquirytoSAP?id={!Opportunity.Id}&rNPD=1&scontrolCaching=1','_self');
else
window.open('apex/sendInquirytoSAP?id={!Opportunity.Id}&rNPD=0&scontrolCaching=1','_self');
}
else
alert('Before trigger to SAP, Please select a SalesArea first.');
}
else
{
alert('You cannot send Opportunity to SAP as no Opportunity Product is associated with it');
}
Please help to add this button urgently.
ONE CLICK JAVASCRIPT code of that button is as follows:-
{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/23.0/apex.js")}
var cOpp = new sforce.SObject("Opportunity");
var QuoteRecord = sforce.connection.query("Select Opportunity__c,Id From Opportunity_Product__c where Opportunity__c='{!Opportunity.Id}'");
var records = QuoteRecord.getArray("records");
cOpp.Sales_Area__c = "{!Opportunity.Sales_Area__c}";
cOpp.NPD_Required__c = "{!Opportunity.NPD_Required__c}";
if(records[0] != null)
{
if(!((cOpp.Sales_Area__c == null) || (cOpp.Sales_Area__c == ''))){
if((cOpp.NPD_Required__c == true) || (cOpp.NPD_Required__c == 'true'))
window.open('apex/sendInquirytoSAP?id={!Opportunity.Id}&rNPD=1&scontrolCaching=1','_self');
else
window.open('apex/sendInquirytoSAP?id={!Opportunity.Id}&rNPD=0&scontrolCaching=1','_self');
}
else
alert('Before trigger to SAP, Please select a SalesArea first.');
}
else
{
alert('You cannot send Opportunity to SAP as no Opportunity Product is associated with it');
}
Salesforce1 and Lightning experience doesn't support Javascript buttons. What I did was to create a new visual force page with the content of the javascript button and call that visual force page from a button, global action or whatever suits you.
I've been waiting for Salesforce to support this feature in order to move to lightning, most of the logic of our business resides in those buttons that are not supported in Salesforce1 and lightning experience but are supported in Salesforce Classic
Please mark this as solved if it's resolved.
Regards,
Nagendra.P