• aswin balaji
  • NEWBIE
  • 20 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
public void getContactDetails(){
    List<Opportunity> opportunityList;
    this.Id = ApexPages.currentPage().getParameters().get('Id');
    opportunityList= [Select AccountId,ContactId From Opportunity Where Id =: this.Id ];
    List<Contact> contactList = new List<Contact>();
    List<Account> AccountList = new List<Account>();
    List<Contact> ContactAccountList = new List<Contact>();
    for(Opportunity oppObj:opportunityList) {
      contactList = [Select Name, Phone, Zip_code__c,Email From Contact Where Id =:oppObj.ContactId ];
      AccountList = [Select BillingStreet,BillingCity From Account Where Id =:oppObj.AccountId];
      for(Contact contactobj:contactList){
          contName = contactobj.Name;
          contPhone = contactobj.Phone;
          contZipcode = contactobj.Zip_code__c;
          contEmail = contactobj.Email;
        system.debug('name '+contName);
        system.debug('phone '+contPhone);
        system.debug('zip '+contZipcode); 
        system.debug('Email '+contEmail); 
        for(Account accountobj:AccountList){
          acctCity = accountobj.BillingStreet;
          acctStreet = accountobj.BillingCity;
        }
      }
      if(oppObj.ContactId == null){
        ContactAccountList =  [Select Name, Phone, Zip_code__c,Email From Contact Where AccountId =:oppObj.AccountId ];
        for(Contact contactaccountobj:contactaccountList){
          contName = contactaccountobj.Name;
          contPhone = contactaccountobj.Phone;
          contZipcode = contactaccountobj.Zip_code__c;
          contEmail = contactaccountobj.Email;
          system.debug('name '+contName);
          system.debug('phone '+contPhone);
          system.debug('zip '+contZipcode); 
          system.debug('Email '+contEmail); 
          for(Account accountobj:AccountList){
            acctCity = accountobj.BillingStreet;
            acctStreet = accountobj.BillingCity;
          }
        }
      }
    }
}

 
I had tried all ossible ways but not working any suggestion?
i wrote seperate method and call that in construtor even though I cant get the values
 
I need to add these two scripts on lwc and invoke the functionality
<script src="https://js.recurly.com/v4/recurly.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
But I have tried using static resources and the script is loading but I cant able to Invoke it in html page....

LWC.html
<template>  
    <c-wizard header="Billing Details" variant="path" current-step="step-1">
        <c-wizard-step label="Card Details" name="step-1">

                <form id="my-form" method="post">
                    <input type="text" data-recurly="first_name" /><br> <br>
                    <input type="text" data-recurly="last_name" /><br>
                    <div data-recurly="number"></div>
                    <div data-recurly="month"></div>
                    <div data-recurly="year"></div>
                    <div data-recurly="cvv"></div>
                    <br>
                    <!-- Recurly.js will update this field automatically -->
                    <input type="text" name="recurly-token" id="recurly-token" data-recurly="token" />
                    <button>submit</button>
                </form>          
            </c-wizard-step>
    </c-wizard>
</template>

LWC.js
import { LightningElement, track } from 'lwc';
import { createRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { loadScript, loadStyle } from 'lightning/platformResourceLoader';
import jQuery from '@salesforce/resourceUrl/Jquery';
import Recurly from '@salesforce/resourceUrl/Recurly';
//const publicKey = 'ewr1-QJhKfvmz4IlzJJoR4jnwb6';
export default class CreateAccountWizard extends LightningElement {
    @track selectedOffer = 'Enrollment only';
    @track error;
    @track successMessage = '';

    renderedCallback() {
            // alert('newtest');
            // invoke the method when component rendered or loaded
            Promise.all([
                loadScript(this, jQuery + '/Jquery.js'),
                loadScript(this, Recurly + '/Recurly.js'),
            ]).then(() => {
                this.error = undefined;

                recurly.configure('ewr1-QJhKfvmz4IlzJJoR4jnwb6');
                recurly.token(document.querySelector('form'), tokenHandler);

                function tokenHandler(err, token) {
                    if (err) {
                        // handle error using err.code and err.fields
                    } else {
                        // handle success using token.id
                    }
                }
                recurly.on('field:submit', function(event) {
                    $('form').submit();
                });
                alert('newtest1');
                // On form submit, we stop submission to go get the token
                $('form').on('submit', function(event) {
                    alert('newtest2');
                    // Prevent the form from submitting while we retrieve the token from Recurly
                    event.preventDefault();
                    // Reset the errors display
                    $('#errors').text('');
                    $('input').removeClass('error');
                    // Disable the submit button
                    $('button').prop('disabled', true);
                    var form = this;
                    // Now we call recurly.token with the form. It goes to Recurly servers
                    // to tokenize the credit card information, then injects the token into the
                    // data-recurly="token" field above
                    recurly.token(form, function(err, token) {
                        debugger;
                        console.log(token);
                        // send any errors to the error function below
                        if (err) error(err);
                        // Otherwise we continue with the form submission
                        //else form.submit();
                    });
                });
            }).catch(error => {
                console.log('failed with error: ' + error);
                this.error = error;
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error!!',
                        message: error.message,
                        variant: 'error',
                    }),
                );
            });
        }
        // showSuccessMessage() { // call back method 
        //     this.successMessage = 'Scripts are loaded successfully!!';
        //     alert('Scripts are loaded successfully!!!');
        // }
        // handleChange(event) {
        //     this.selectedOffer = event.detail.value;
        // }
    getingToken() {}
}

​​​​​​​
This is the code of auto lead conversion and autoLeadConversion is the function.I had written master class so i need specific function to be tested
public class AAAExisting{ 
    public List<wrapLead> wrapLeadList {get; set;}
    public List<Lead> accs {get; set;}
    
    public void ConvertedLeadList(){
       accs = [SELECT Id, Name, ConvertedAccountId, ConvertedContactId, ConvertedOpportunityId, Status FROM Lead WHERE IsConverted=true];
   // System.debug(accs);
    }
    
    
    
    public AAAExisting(){
        if(wrapLeadList == null) {
            wrapLeadList = new List<wrapLead>();
            for(Lead a: [select Id, Name, Company, Email, Phone, Status FROM Lead WHERE IsConverted=false]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapLeadList .add(new wrapLead(a));
               // System.debug(wrapLeadList);
            }
        }
    }
       
  
    
       Public void autoLeadConversion(List<Lead> autoLeadConversions) {
       //  List<Lead> autoLeadConversions= new List <Lead>();
           for(Lead lead: autoLeadConversions){
              if (lead.isConverted == false) { //to prevent recursion
       Database.LeadConvert lc = new Database.LeadConvert();
       lc.setLeadId(lead.Id); 
       String oppName = lead.LastName;
       lc.setOpportunityName(oppName);
       LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
       lc.setConvertedStatus(convertStatus.MasterLabel);
       Database.LeadConvertResult lcr = Database.convertLead(lc);
       System.assert(lcr.isSuccess());            
           }
        } 
    }
 
   
    
    public void processSelected() {
        for(wrapLead wrapAccountObj : wrapLeadList ) {
        if(wrapAccountObj.selected == true) {
            Database.LeadConvert lc = new Database.LeadConvert();
           lc.setLeadId(wrapAccountObj.acc.Id);
           lc.setopportunityname(wrapAccountObj.acc.Company);
            LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            lc.setConvertedStatus(convertStatus.MasterLabel);
            Database.LeadConvertResult lcr = Database.convertLead(lc);
            }
            }
             }
 
    // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapLead{
        public Lead acc {get; set;}
        public Boolean selected {get; set;}
 
        //This is the contructor method. When we create a new wrapAccount object we pass a Account that is set to the acc property. We also set the selected value to false
        public wrapLead(Lead a) {
            acc = a;
            selected = false;
            System.debug('convertStatus'+ acc);
        }

    }
    
}



 
I had tried all ossible ways but not working any suggestion?
i wrote seperate method and call that in construtor even though I cant get the values
 
This is the code of auto lead conversion and autoLeadConversion is the function.I had written master class so i need specific function to be tested
public class AAAExisting{ 
    public List<wrapLead> wrapLeadList {get; set;}
    public List<Lead> accs {get; set;}
    
    public void ConvertedLeadList(){
       accs = [SELECT Id, Name, ConvertedAccountId, ConvertedContactId, ConvertedOpportunityId, Status FROM Lead WHERE IsConverted=true];
   // System.debug(accs);
    }
    
    
    
    public AAAExisting(){
        if(wrapLeadList == null) {
            wrapLeadList = new List<wrapLead>();
            for(Lead a: [select Id, Name, Company, Email, Phone, Status FROM Lead WHERE IsConverted=false]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapLeadList .add(new wrapLead(a));
               // System.debug(wrapLeadList);
            }
        }
    }
       
  
    
       Public void autoLeadConversion(List<Lead> autoLeadConversions) {
       //  List<Lead> autoLeadConversions= new List <Lead>();
           for(Lead lead: autoLeadConversions){
              if (lead.isConverted == false) { //to prevent recursion
       Database.LeadConvert lc = new Database.LeadConvert();
       lc.setLeadId(lead.Id); 
       String oppName = lead.LastName;
       lc.setOpportunityName(oppName);
       LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
       lc.setConvertedStatus(convertStatus.MasterLabel);
       Database.LeadConvertResult lcr = Database.convertLead(lc);
       System.assert(lcr.isSuccess());            
           }
        } 
    }
 
   
    
    public void processSelected() {
        for(wrapLead wrapAccountObj : wrapLeadList ) {
        if(wrapAccountObj.selected == true) {
            Database.LeadConvert lc = new Database.LeadConvert();
           lc.setLeadId(wrapAccountObj.acc.Id);
           lc.setopportunityname(wrapAccountObj.acc.Company);
            LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            lc.setConvertedStatus(convertStatus.MasterLabel);
            Database.LeadConvertResult lcr = Database.convertLead(lc);
            }
            }
             }
 
    // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapLead{
        public Lead acc {get; set;}
        public Boolean selected {get; set;}
 
        //This is the contructor method. When we create a new wrapAccount object we pass a Account that is set to the acc property. We also set the selected value to false
        public wrapLead(Lead a) {
            acc = a;
            selected = false;
            System.debug('convertStatus'+ acc);
        }

    }
    
}