• Mahitha Vaka 9
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
Hi, Can some one please help me on creating lightning button and class for this below Java script button.

Thanks in advance.

{!requireScript("/soap/ajax/18.0/connection.js")} 
{!requireScript("/soap/ajax/18.0/apex.js")} 
{!requireScript("/js/functions.js")} 


Opportunity = new sforce.SObject("Opportunity"); 

// Populate the ID and the fields we're updating. 
Opportunity["Id"] = "{!Opportunity.Id}"; 

// Get the related account name 
var accId = "{!Opportunity.AccountId}"; 
var oppProducer = "{!Opportunity.Producer__c}"; 
var oppResource = "{!Opportunity.Resouce__c}"; 
var oppDept = "{!Opportunity.Department__c}"; 
var oppCat1 = "{!Opportunity.Cat1__c}"; 
var oppCat2 = "{!Opportunity.Cat2__c}"; 
var oppOppType = "{!Opportunity.Business_Unit__c}"; 
var oppOffice = "{!Opportunity.Office__c}"; 
var oppSentToSagita = "{!Opportunity.Send_To_Sagitta__c }"; 
var oppStatus = "{!Opportunity.Approval_Status__c}"; 

function validateopp() { 

var query = "Select Name, Sic, BillingStreet, BillingCity, BillingState from account where id = '" + accId + "'"; 
result = sforce.connection.query(query); 
records = result.getArray("records"); 
// alert("Account name:" + records[0]); 

var errT = "The following information must be completed before sending an account to Sagitta: "; 
var errAdditional=""; 

if ((records[0]).Name == null || (records[0]).Name == "") { 
errAdditional += "Account Name, "; 

if (oppProducer == null || oppProducer == "") { 
errAdditional += "Producer, "; 

if ((records[0]).BillingStreet == null || (records[0]).BillingStreet == "") { 
errAdditional += "Primary Street, "; 

if ((records[0]).BillingCity == null || (records[0]).BillingCity == "") { 
errAdditional += "City, "; 

if ((records[0]).BillingState == null || (records[0]).BillingState == "") { 
errAdditional += "State, "; 

if ((records[0]).Sic == null || (records[0]).Sic == "") { 
errAdditional += "SIC Code, "; 

if (oppResource == null || oppResource == "") { 
errAdditional += "Resource Assignment, "; 

if (oppOppType == "Employee Benefits Services"){ 
if (oppCat2 == null || oppCat2 == "") { 
errAdditional += "CAT2, "; 


else{ 
if (oppCat1 == null || oppCat1 == "") { 
errAdditional += "CAT1, "; 


if (oppOffice == null || oppOffice == "") { 
errAdditional += "Office, "; 

if (oppDept == null || oppDept == "") { 
errAdditional += "Department"; 


if (errAdditional == "" && oppStatus=="Approved") { 
updateopp(); 
alert('Account successfully sent to Sagitta'); 
}else{ 
if (oppStatus!="Approved") { 
alert('Opportunity cannot be sent to Sagitta since it is currently not approved'); 
}else{ 
errT += errAdditional; 
alert(errT); 




function updateopp(){ 
Opportunity["Send_To_Sagitta__c"] = "true"; 

// Try to update the object. 
saveResults = sforce.connection.update([Opportunity]); 
if(saveResults[0].errors != null) 
alert(saveResults[0].errors.message); 

// Refresh the page. 
window.top.location.href = window.top.location.href; 


try{ 
if (oppSentToSagita == "true") { 
alert('Account is already in Sagitta. Thanks.'); 
}else{ 
validateopp(); 



catch(Exception){ 
// alert("Error: "+Exception); 
}
Hi, I have created the below VF page and controller, but i am getting "Content cannot be displayed: List has no rows for assignment to SObject".
please advice on how to fix this.


<apex:page Controller="MyController" Tabstyle="Account">
<apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton action="{!Save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!account.contacts}" var="contact">>
           
                            <apex:column headerValue="First Name"><apex:inputField value="{!contact.firstname}"/></apex:column>
                <apex:column headerValue="Last Name"><apex:inputField value="{!contact.lastname}"/></apex:column>
                <apex:column headerValue="Phone Number"><apex:inputField value="{!contact.phone}"/></apex:column>
                <apex:column headerValue="E-mail"><apex:inputField value="{!contact.email}"/></apex:column>
                <apex:column headerValue="Title"><apex:inputField value="{!contact.title}"/></apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>

    </apex:form>

</apex:page>


Controller:
public class MyController {

    private final Account account;

    public MyController() {
        account = [SELECT Id, Name, Site FROM Account 
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }

    public Account getAccount() {
        return account;
    }

    public PageReference save() {
        update account;
        return null;
    }
}

              
Hi All, I have a requirement to create a popup, popup should be displayed after saving an account, requesting users to use Clean button along with the Clean button on the popup. How can I achieve this? I am totally new to apex development can some help me with this. Thank you