• Kiran Pandiyan
  • NEWBIE
  • 50 Points
  • Member since 2015
  • Application Development Analyst
  • Accenture

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 25
    Replies
I'm trying to remove as many if loops as possible to improve code efficiency , so I'm planning to change the below code 
if(!mapProduct.containsKey(aobj.bexample__c)){
                            mapProduct.put(aobj.bexample__c), new List<cobject__c>());
                        }
into the below using ternary operator
mapProductToPLI =  (!mapProductToPLI.containsKey(oPriceListItem.Apttus_Config2__ProductId__c)) ? 
mapProductToPLI.put(oPriceListItem.Apttus_Config2__ProductId__c, new List<Apttus_Config2__PriceListItem> ) :
nul ;

If no what is wrong here . Explain me elaborately
 
This is my class
public class APTS_OrderRequest {
	public class Order {
        public String OrderSource{get;set;}
        public String PurchaseOrderNumber{get;set;}
        public String POOrderDate;
        public String SalesResponsibleUnit{get;set;}
        public String QuotationReference{get;set;}
        public String ApttusQuotationID{get;set;}
        public String QuotationRevisionNo{get;set;}
        public String QuoteCreationDate{get;set;}
        public String QuoteReferenceDescription{get;set;}
        public String EndUserCustomerIdentifier{get;set;}
        public String CustomerGUID{get;set;}
        public String PlacedBy{get;set;}
        public String ProjectName{get;set;}
        public String CurrencyCode{get;set;}
        public String SourceSystemOrderNumber{get;set;}
        public String OrderDate{get;set;}
        public String OrderingSystem{get;set;}
        public String HandledBy{get;set;}
        public String AdditionalSalesPersonEmail{get;set;}
        public String ExpectedDeliverDate{get;set;}
        public String IndustryUsage{get;set;}
        public String ChannelClass{get;set;}
        public string TenderLocationLevel2ID{get;set;}
        public String CustomerReference{get;set;}
        public String Application{get;set;}
        public String IndustryUsageLevel1{get;set;}
        public String IndustryUsageLevel2{get;set;}
        public Warranty Warranty{get;set;}
	}
	public class Warranty {
        public String WarrantyMax{get;set;}
        public String Warranty{get;set;}
        public String QualityControl{get;set;}
        public String Penalty{get;set;}
        public String Packing{get;set;}
        public string SpecialWarranty{get;set;}
    }

    public class ConfiguredItem {
        public String ConfigurationId{get;set;}
        public String NomenclatureNumber{get;set;}
        public String ConfiguratorId{get;set;}
        public String ConfiguratorPlatform{get;set;}
    }
	public class OrderLineItems {
        public String SourceSystemItemId{get;set;}
        public String ApttusQuotationLineID{get;set;}
        public Integer LineNumber{get;set;}
        public Integer ItemSequence{get;set;}
        public String ProductID{get;set;}
        public String ProductNumber{get;set;}
        public String ProductDescription{get;set;}
        public string PartID{get;set;}
        public string ProductType{get;set;}
        public string TechnicalID{get;set;}
        public string ClassificationID{get;set;}
        public string StandardCategoryType{get;set;}
        public string CategoryID{get;set;}
        public Integer Quantity{get;set;}
        public String CurrencyCode{get;set;}
        public String UnitOfMeasure{get;set;}
        public Decimal UnitPrice{get;set;}
        public String DeliveryDate{get;set;}
        public String ContractDeliveryDate{get;set;}
        public Integer ManualLeadTime{get;set;}
        public String ProductionUnit{get;set;}
        public Decimal ListPrice{get;set;}
        public Decimal TotalNetSalesPrice{get;set;}
        public Decimal NetSalesPrice{get;set;}
        public Decimal TransferPrice{get;set;}
        public String TransferPriceCurrency{get;set;}
        public Decimal StandardDiscount{get;set;}
        public Decimal DiscountPercentage{get;set;}
        public String ParentLineNumber{get;set;}
        public String RequiredLeadTime{get;set;}
        public Decimal BaseCost{get;set;}
        public Decimal AdditionalDiscount{get;set;}
        public String Supplier{get;set;}
        public String Customer{get;set;}
        public String EndUserCountry{get;set;}
        public String PurchaseOrderNumber{get;set;}
        public String PurchaseOrderLineNumber{get;set;}
        public String TransportMode{get;set;}
        public Boolean Send2ERP{get;set;}
        public String TopArticle{get;set;}
        public String Warehouse{get;set;}
        public Notes Notes{get;set;}
        public ConfiguredItem ConfiguredItem{get;set;}
        
	}
}

This is my test class. I was getting 20% coverage before but after adding warranty fields. I'm getting an error
@isTest
public class APTS_OrderRequestTest {

     public static testmethod void testMethod1() {
        APTS_OrderRequest objRequest = new APTS_OrderRequest();
        APTS_OrderRequest.Order objOrder = new APTS_OrderRequest.Order();
		objOrder.OrderSource= '';
		objOrder.PurchaseOrderNumber= '';
        objOrder.POOrderDate= date.today();
        objOrder.SalesResponsibleUnit= '';
        objOrder.QuotationReference= '';
        objOrder.ApttusQuotationID= '';
        objOrder.QuotationRevisionNo= '';
        objOrder.QuoteCreationDate= '';
        objOrder.QuoteReferenceDescription= '';
        objOrder.EndUserCustomerIdentifier= '';
        objOrder.CustomerGUID= '';
        objOrder.PlacedBy= '';
        objOrder.ProjectName= '';
        objOrder.CurrencyCode= '';
        objOrder.SourceSystemOrderNumber= '';
        objOrder.OrderDate= '';
        objOrder.OrderingSystem= '';
        objOrder.HandledBy= '';
        objOrder.AdditionalSalesPersonEmail= '';
        objOrder.ExpectedDeliverDate= '';
        objOrder.IndustryUsage= '';
        objOrder.ChannelClass= '';
        objOrder.TenderLocationLevel2ID= '';
        objOrder.CustomerReference= '';
        objOrder.Application= '';
        objOrder.IndustryUsageLevel1= '';
        objOrder.IndustryUsageLevel2= '';
		objOrder.Warranty= '';
		objOrder.ExternalChannelPartnerId= '';
		objOrder.PaymentNDeliveryTerms= '';
		objOrder.Links= '';
		objOrder.OrderLineItems= '';
		objOrder.Addresses= '';
		objOrder.MileStoneBillingPlan= '';
		objOrder.SalesPersonDetails= '';
		APTS_OrderRequest.Order.Warranty testWarranty = new APTS_OrderRequest.Order.Warranty();
		testWarranty.WarrantyMax= '';
		testWarranty.Warranty= '';
		testWarranty.QualityControl= '';
		testWarranty.Penality= '';
		testWarranty.Packing= '';
		testWarranty.SpecialWarranty= '';
    }
}

The error I'm getting is 

 classes/APTS_OrderRequestTest.cls: Variable does not exist: testWarranty (Line: 32, Column: 28)
classes/APTS_OrderRequestTest.cls: Illegal assignment from String to APTS_OrderRequest.PaymentNDeliveryTerms (Line: 34, Column: 9)
classes/APTS_OrderRequestTest.cls: Illegal assignment from String to List<APTS_OrderRequest.Links> (Line: 35, Column: 9)
classes/APTS_OrderRequestTest.cls: Illegal assignment from String to List<APTS_OrderRequest.OrderLineItems> (Line: 36, Column: 9)
classes/APTS_OrderRequestTest.cls: Illegal assignment from String to List<APTS_OrderRequest.Addresses> (Line: 37, Column: 9)
classes/APTS_OrderRequestTest.cls: Illegal assignment from String to List<APTS_OrderRequest.MileStoneBillingPlan> (Line: 38, Column: 9)
classes/APTS_OrderRequestTest.cls: Illegal assignment from String to List<APTS_OrderRequest.SalesPersonDetails> (Line: 39, Column: 9)
classes/APTS_OrderRequestTest.cls: Invalid type: APTS_OrderRequest.Order.Warranty (Line: 40, Column: 9)
classes/APTS_OrderRequestTest.cls: Variable does not exist: testWarranty (Line: 41, Column: 9)
classes/APTS_OrderRequestTest.cls: Variable does not exist: testWarranty (Line: 42, Column: 9)

User-added image
I need to Display in the Custom object header the Record name instead of the auto number 
like the one below
User-added image
Global class AnimalLocator {
    Global static String getAnimalNameById(Integer numb){
        String response;
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/'+numb);
        request.setMethod('GET');
        HttpResponse resp = http.send(request);
        if(resp.getStatusCode()==200){
            Map<String,Object> results = (Map<String,Object>) JSON.deserializeUntyped(response.getBody());
            Map<String,Object> animal = (Map<String,Object>)results.get('animal');
            response = (String)animal.get('name');
        }
        return response;
    }
}
I'm getting the error "Method does not exist or incorrect signature : void getBody() from String type "
 
Control Processes with Queueable Apex challenge of Asynchronous Apex module 
I wrote the bellow queueable class
public class AddPrimaryContact implements Queueable{
    public List<Contact> contacts = new List<Contact>();
    List<Account> accs = [Select Id, Name, BillingState from Account];
    public void AddPrimaryContact(List<Account> accs){
    
      for(Account a : accs){
        Contact con = new Contact();
        con.AccountID = a.Id;
        con.LastName = 'Contact of '+a;
        contacts.add(con);
        system.debug('con check'+con);
      }
       insert contacts; 
    }
  public void execute(QueueableContext context){
        for (Contact cont : contacts) {
        cont.MailingState = cont.Account.BillingState;
        }
        update contacts;
    }
}

And then wrote the below test class
@isTest
public class AddPrimaryContactTest {
    
    @testSetup
    static void setup(){
        List<Account> accs = new List<Account>();
        for (Integer j=0; j<2; j++){
            if(j==0){
                for (Integer i=0; i<50; i++){
                    accs.add(new Account( name='TestC Account'+i, BillingState='NY'));
                }
            }
            else{
                 for (Integer i=0; i<50; i++){
                    accs.add(new Account( name='TestD Account'+i, BillingState='CA'));
                }   
                    
             }
            
        }
        insert accs;
    }
    
    static testMethod void testQueueable(){
        List<Account> accts = [Select Id, Name, BillingState from Account where BillingState = 'NY' OR BillingState = 'CA'];
    	AddPrimaryContact addressput = new AddPrimaryContact(accts);
        Test.startTest();
        System.enqueueJob(addressput);
        Test.stopTest();
        
        System.assertEquals(50, [select count() from Contact where MailingState = 'NY']);
        System.assertEquals(50, [select count() from Contact where MailingState = 'CA']);
    }

}

The error I'm getting is "constructor not defined [AddPrimaryContact].(list). And when I run the queueable class in Anonymous execution I don't see SOQL querries running. What could be the issue here ?

When our user tries to login to salesforce the following error is thrown 

"__missing label__ PropertyFile val TemporaryError  not found in section SmsVerificationStartUi"

What could be the problem ? I checked the phone no. of user and it is a valid one. The user tried to login through both Remote Client Access and Application and both failed multiple times.

public class AccountProcessor {
	@future
    public static void countContacts(set<Id> recIds){
        List<Account> accs = [Select Id, Name from Account Where Id IN :recIds];
        
        for(Account ac :accs){
            ac.Number_of_Contacts__c=[SELECT COUNT() FROM Contact WHERE Account.Id=:ac.Id];
        }
        
       update accs; 
    }
}

I'm try 'Use Future methods' challenge in Asynchronous Apex module. After saving the code and running it in anonymous window, the value is not populated , how can I solve the issue
I'm doing "Map Your Workflow Actions to Process Actions" trail in Workflow Rule Migration .

I completed my challenge and when I check it, I'm getting the below error.

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Delete failed. First exception on row 0 with id 0012800001VZifHAAT; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Cannot delete account with related opportunities.: []

What shall I do to solve the challenge

User-added image
URL ending : ex/ex.jsp?handledEx=common.sql.OracleRowLockedException

Record Currently Unavailable
The record you are attempting to edit, or one of its related records, is currently being modified by another user. Please try again. 

User-added image
This code is a sample code in Trailhead to be run on Anonymous window. I get below error always. I tried removing the space and retyping those words. But still I'm getting this error in same or someother line. Let me know a solution for this problem.

"Error: Compile Error: Invalid identifier '    BillingCity'. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_', or unicode characters from U+0080 to U+FFFE. at line 5 column 1"

Task error
As shown in the above pic. I could not edit and save this task. The task has Visible access to all the profiles. What could be the problem ?
I am trying to export records of the object Support_order__c . I'm using the condition to filter the records by Account_Name__c field (formula field). I'm not getting any records extracted . How can I extract the records ?
How can we get campaigns from web and generate lead from those campaigns ?
What is the Difference between CTI developer toolkit and OPEN CTI ? What are their advantages and disadvantages of both ? What should I use for my upcoming project ?
I have written a Lightning Component of Modal Popup to show popup in home page of public community website , it will be shown whenever user visits the website. 

My requirement is here is popup window should show only once when the user visits the website for the first time.
But the issue is , whenever the user visits to the website or other sub pages of the site and come back to the home page, again the popup appears. 
In this we want to set the modal popup should be shown only for the first time when the users visit the site , 
as in the popup we are just making sure the user is aware of GDPR rules and regulations .
Once, the user clicks on OK, everytime the GDPR popup should not get open when the user visits the site and home page.

I have refered many Javascript examples but unfortunately I am not able to figure it out , please find my following code and suggest me.

Component :

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="isModalOpen" type="boolean" default="true"/>
    <div class="slds-m-around_xx-large">
              
        <!--Use aura:if tag to display/hide popup based on isModalOpen value-->  
        <aura:if isTrue="{!v.isModalOpen}">            
            <!-- Modal/Popup Box starts here-->
            <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <!-- Modal/Popup Box Header Starts here-->
                    <header class="slds-modal__content slds-p-around_medium">
                        <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate"><b>About Your Privacy</b></h2>
                    </header>
                    <!--Modal/Popup Box Body Starts here-->
                    <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                        <p>This website uses cookies to improve performance and enhance our visitors’ experience.You may view our privacy policy here.                    
                        </p>
                    </div>
                    <!--Modal/Popup Box Footer Starts here - class="slds-modal__header", class="slds-modal__footer"-->
                    <footer class="slds-modal__content slds-p-around_medium"> 
                          <lightning:button 
                                          label="OK"
                                          title="OK"
                                          onclick="{!c.submitDetails}"/>
                    </footer>
                </div>
            </section>
            <div class="slds-backdrop slds-backdrop_open"></div>
        </aura:if>
    </div>
</aura:component>

Controller :

({
   openModel: function(component, event, helper) {
      // Set isModalOpen attribute to true
      component.set("v.isModalOpen", true);
      
       
   },
  
   closeModel: function(component, event, helper) {
      // Set isModalOpen attribute to false  
      component.set("v.isModalOpen", false);
   },
  
   submitDetails: function(component, event, helper) {
      // Set isModalOpen attribute to false
      //Add your code to call apex method or do some processing
      component.set("v.isModalOpen", false);
   },
})
I'm trying to remove as many if loops as possible to improve code efficiency , so I'm planning to change the below code 
if(!mapProduct.containsKey(aobj.bexample__c)){
                            mapProduct.put(aobj.bexample__c), new List<cobject__c>());
                        }
into the below using ternary operator
mapProductToPLI =  (!mapProductToPLI.containsKey(oPriceListItem.Apttus_Config2__ProductId__c)) ? 
mapProductToPLI.put(oPriceListItem.Apttus_Config2__ProductId__c, new List<Apttus_Config2__PriceListItem> ) :
nul ;

If no what is wrong here . Explain me elaborately
 
This is my class
public class APTS_OrderRequest {
	public class Order {
        public String OrderSource{get;set;}
        public String PurchaseOrderNumber{get;set;}
        public String POOrderDate;
        public String SalesResponsibleUnit{get;set;}
        public String QuotationReference{get;set;}
        public String ApttusQuotationID{get;set;}
        public String QuotationRevisionNo{get;set;}
        public String QuoteCreationDate{get;set;}
        public String QuoteReferenceDescription{get;set;}
        public String EndUserCustomerIdentifier{get;set;}
        public String CustomerGUID{get;set;}
        public String PlacedBy{get;set;}
        public String ProjectName{get;set;}
        public String CurrencyCode{get;set;}
        public String SourceSystemOrderNumber{get;set;}
        public String OrderDate{get;set;}
        public String OrderingSystem{get;set;}
        public String HandledBy{get;set;}
        public String AdditionalSalesPersonEmail{get;set;}
        public String ExpectedDeliverDate{get;set;}
        public String IndustryUsage{get;set;}
        public String ChannelClass{get;set;}
        public string TenderLocationLevel2ID{get;set;}
        public String CustomerReference{get;set;}
        public String Application{get;set;}
        public String IndustryUsageLevel1{get;set;}
        public String IndustryUsageLevel2{get;set;}
        public Warranty Warranty{get;set;}
	}
	public class Warranty {
        public String WarrantyMax{get;set;}
        public String Warranty{get;set;}
        public String QualityControl{get;set;}
        public String Penalty{get;set;}
        public String Packing{get;set;}
        public string SpecialWarranty{get;set;}
    }

    public class ConfiguredItem {
        public String ConfigurationId{get;set;}
        public String NomenclatureNumber{get;set;}
        public String ConfiguratorId{get;set;}
        public String ConfiguratorPlatform{get;set;}
    }
	public class OrderLineItems {
        public String SourceSystemItemId{get;set;}
        public String ApttusQuotationLineID{get;set;}
        public Integer LineNumber{get;set;}
        public Integer ItemSequence{get;set;}
        public String ProductID{get;set;}
        public String ProductNumber{get;set;}
        public String ProductDescription{get;set;}
        public string PartID{get;set;}
        public string ProductType{get;set;}
        public string TechnicalID{get;set;}
        public string ClassificationID{get;set;}
        public string StandardCategoryType{get;set;}
        public string CategoryID{get;set;}
        public Integer Quantity{get;set;}
        public String CurrencyCode{get;set;}
        public String UnitOfMeasure{get;set;}
        public Decimal UnitPrice{get;set;}
        public String DeliveryDate{get;set;}
        public String ContractDeliveryDate{get;set;}
        public Integer ManualLeadTime{get;set;}
        public String ProductionUnit{get;set;}
        public Decimal ListPrice{get;set;}
        public Decimal TotalNetSalesPrice{get;set;}
        public Decimal NetSalesPrice{get;set;}
        public Decimal TransferPrice{get;set;}
        public String TransferPriceCurrency{get;set;}
        public Decimal StandardDiscount{get;set;}
        public Decimal DiscountPercentage{get;set;}
        public String ParentLineNumber{get;set;}
        public String RequiredLeadTime{get;set;}
        public Decimal BaseCost{get;set;}
        public Decimal AdditionalDiscount{get;set;}
        public String Supplier{get;set;}
        public String Customer{get;set;}
        public String EndUserCountry{get;set;}
        public String PurchaseOrderNumber{get;set;}
        public String PurchaseOrderLineNumber{get;set;}
        public String TransportMode{get;set;}
        public Boolean Send2ERP{get;set;}
        public String TopArticle{get;set;}
        public String Warehouse{get;set;}
        public Notes Notes{get;set;}
        public ConfiguredItem ConfiguredItem{get;set;}
        
	}
}

This is my test class. I was getting 20% coverage before but after adding warranty fields. I'm getting an error
@isTest
public class APTS_OrderRequestTest {

     public static testmethod void testMethod1() {
        APTS_OrderRequest objRequest = new APTS_OrderRequest();
        APTS_OrderRequest.Order objOrder = new APTS_OrderRequest.Order();
		objOrder.OrderSource= '';
		objOrder.PurchaseOrderNumber= '';
        objOrder.POOrderDate= date.today();
        objOrder.SalesResponsibleUnit= '';
        objOrder.QuotationReference= '';
        objOrder.ApttusQuotationID= '';
        objOrder.QuotationRevisionNo= '';
        objOrder.QuoteCreationDate= '';
        objOrder.QuoteReferenceDescription= '';
        objOrder.EndUserCustomerIdentifier= '';
        objOrder.CustomerGUID= '';
        objOrder.PlacedBy= '';
        objOrder.ProjectName= '';
        objOrder.CurrencyCode= '';
        objOrder.SourceSystemOrderNumber= '';
        objOrder.OrderDate= '';
        objOrder.OrderingSystem= '';
        objOrder.HandledBy= '';
        objOrder.AdditionalSalesPersonEmail= '';
        objOrder.ExpectedDeliverDate= '';
        objOrder.IndustryUsage= '';
        objOrder.ChannelClass= '';
        objOrder.TenderLocationLevel2ID= '';
        objOrder.CustomerReference= '';
        objOrder.Application= '';
        objOrder.IndustryUsageLevel1= '';
        objOrder.IndustryUsageLevel2= '';
		objOrder.Warranty= '';
		objOrder.ExternalChannelPartnerId= '';
		objOrder.PaymentNDeliveryTerms= '';
		objOrder.Links= '';
		objOrder.OrderLineItems= '';
		objOrder.Addresses= '';
		objOrder.MileStoneBillingPlan= '';
		objOrder.SalesPersonDetails= '';
		APTS_OrderRequest.Order.Warranty testWarranty = new APTS_OrderRequest.Order.Warranty();
		testWarranty.WarrantyMax= '';
		testWarranty.Warranty= '';
		testWarranty.QualityControl= '';
		testWarranty.Penality= '';
		testWarranty.Packing= '';
		testWarranty.SpecialWarranty= '';
    }
}

The error I'm getting is 

 classes/APTS_OrderRequestTest.cls: Variable does not exist: testWarranty (Line: 32, Column: 28)
classes/APTS_OrderRequestTest.cls: Illegal assignment from String to APTS_OrderRequest.PaymentNDeliveryTerms (Line: 34, Column: 9)
classes/APTS_OrderRequestTest.cls: Illegal assignment from String to List<APTS_OrderRequest.Links> (Line: 35, Column: 9)
classes/APTS_OrderRequestTest.cls: Illegal assignment from String to List<APTS_OrderRequest.OrderLineItems> (Line: 36, Column: 9)
classes/APTS_OrderRequestTest.cls: Illegal assignment from String to List<APTS_OrderRequest.Addresses> (Line: 37, Column: 9)
classes/APTS_OrderRequestTest.cls: Illegal assignment from String to List<APTS_OrderRequest.MileStoneBillingPlan> (Line: 38, Column: 9)
classes/APTS_OrderRequestTest.cls: Illegal assignment from String to List<APTS_OrderRequest.SalesPersonDetails> (Line: 39, Column: 9)
classes/APTS_OrderRequestTest.cls: Invalid type: APTS_OrderRequest.Order.Warranty (Line: 40, Column: 9)
classes/APTS_OrderRequestTest.cls: Variable does not exist: testWarranty (Line: 41, Column: 9)
classes/APTS_OrderRequestTest.cls: Variable does not exist: testWarranty (Line: 42, Column: 9)

Global class AnimalLocator {
    Global static String getAnimalNameById(Integer numb){
        String response;
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/'+numb);
        request.setMethod('GET');
        HttpResponse resp = http.send(request);
        if(resp.getStatusCode()==200){
            Map<String,Object> results = (Map<String,Object>) JSON.deserializeUntyped(response.getBody());
            Map<String,Object> animal = (Map<String,Object>)results.get('animal');
            response = (String)animal.get('name');
        }
        return response;
    }
}
I'm getting the error "Method does not exist or incorrect signature : void getBody() from String type "
 
Control Processes with Queueable Apex challenge of Asynchronous Apex module 
I wrote the bellow queueable class
public class AddPrimaryContact implements Queueable{
    public List<Contact> contacts = new List<Contact>();
    List<Account> accs = [Select Id, Name, BillingState from Account];
    public void AddPrimaryContact(List<Account> accs){
    
      for(Account a : accs){
        Contact con = new Contact();
        con.AccountID = a.Id;
        con.LastName = 'Contact of '+a;
        contacts.add(con);
        system.debug('con check'+con);
      }
       insert contacts; 
    }
  public void execute(QueueableContext context){
        for (Contact cont : contacts) {
        cont.MailingState = cont.Account.BillingState;
        }
        update contacts;
    }
}

And then wrote the below test class
@isTest
public class AddPrimaryContactTest {
    
    @testSetup
    static void setup(){
        List<Account> accs = new List<Account>();
        for (Integer j=0; j<2; j++){
            if(j==0){
                for (Integer i=0; i<50; i++){
                    accs.add(new Account( name='TestC Account'+i, BillingState='NY'));
                }
            }
            else{
                 for (Integer i=0; i<50; i++){
                    accs.add(new Account( name='TestD Account'+i, BillingState='CA'));
                }   
                    
             }
            
        }
        insert accs;
    }
    
    static testMethod void testQueueable(){
        List<Account> accts = [Select Id, Name, BillingState from Account where BillingState = 'NY' OR BillingState = 'CA'];
    	AddPrimaryContact addressput = new AddPrimaryContact(accts);
        Test.startTest();
        System.enqueueJob(addressput);
        Test.stopTest();
        
        System.assertEquals(50, [select count() from Contact where MailingState = 'NY']);
        System.assertEquals(50, [select count() from Contact where MailingState = 'CA']);
    }

}

The error I'm getting is "constructor not defined [AddPrimaryContact].(list). And when I run the queueable class in Anonymous execution I don't see SOQL querries running. What could be the issue here ?
public class AccountProcessor {
	@future
    public static void countContacts(set<Id> recIds){
        List<Account> accs = [Select Id, Name from Account Where Id IN :recIds];
        
        for(Account ac :accs){
            ac.Number_of_Contacts__c=[SELECT COUNT() FROM Contact WHERE Account.Id=:ac.Id];
        }
        
       update accs; 
    }
}

I'm try 'Use Future methods' challenge in Asynchronous Apex module. After saving the code and running it in anonymous window, the value is not populated , how can I solve the issue
I'm doing "Map Your Workflow Actions to Process Actions" trail in Workflow Rule Migration .

I completed my challenge and when I check it, I'm getting the below error.

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Delete failed. First exception on row 0 with id 0012800001VZifHAAT; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Cannot delete account with related opportunities.: []

What shall I do to solve the challenge

User-added image
URL ending : ex/ex.jsp?handledEx=common.sql.OracleRowLockedException

Record Currently Unavailable
The record you are attempting to edit, or one of its related records, is currently being modified by another user. Please try again. 

Hello Community, I'm working on the Trailhead project "Build a Lightning App with the Lightning Design System - "Build the AccountList Component"

I'm receiving this error as I try to verify the challenge: 

Step Not yet complete... here's what's wrong: 
The component is not using 'controller=AccountsController' 
Note: you may run into errors if you've skipped previous steps
.


When I completed Step 5 of the challenge "Test The App" when I did he Preview Aura gave me an error stating

"Something has gone wrong. Cannot read property 'Ud' of undefined. Please try again."

Has anyone encountered these errors, or can give any advice? 
Hi,

I have written a test class for this rest callouts but its not covering 100% code coverage. Can someone please help me

It throws me error when I run the test class 
Class.AnimalLocator.getAnimalNameById: line 16, column 1 Class.AnimalLocatorTest.testcallout: line 7, column 1

Apex class 

public class AnimalLocator {

public static string getAnimalNameById (integer i)
{
    string a;
    Http ht = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/' + i);
        request.setMethod('GET');
        HttpResponse response = ht.send(request);
        // If the request is successful, parse the JSON response.
    if (response.getStatusCode() == 200) 
    {
            Map<String, Object> result = (Map<String, Object>)JSON.deserializeUntyped(response.getBody());
             Map<string,object> cc = (Map<string,object>) result.get('animals');
        a = (string)cc.get('name');
    }
    return a;
  }
}


Test class

@isTest
public class AnimalLocatorTest 
{
@isTest static void testcallout()
{
      Test.setMock(HttpCalloutMock.class, new AnimalLocatorMock()); 
    string response = AnimalLocator.getAnimalNameById (2); 
String expectedValue = '{"animal":{"id":2,"name":"bear","eats","berries, campers, adam seligman","says":"yum yum"}}'; 
system.assertEquals('eats', response);
   
   }
}

@isTest
global class AnimalLocatorMock implements HttpCalloutMock 
{
global HTTPResponse respond(HTTPRequest request) 
{
        // Create a fake response
         HttpResponse response = new HttpResponse(); 
     response.setHeader('Content-Type', 'application/json');
    response.setBody('{"animal":{"i":2,"name":"bear","eats":"berries, campers, adam seligman","says":"yum yum"}}'); 
        response.setStatusCode(200);
        return response;
}
}
 
  • January 29, 2016
  • Like
  • 0
In the Challenge it is requested to make a call to https://th-apex-http-callout.herokuapp.com/animals/:id.

Question is are they expecting a GET call or POST call. Most probably a GET call. But suppose integet pass to the method getAnimalNameById is "45678". How are we to formulate the URL.

Is it Option 1> replace id with value i.e https://th-apex-http-callout.herokuapp.com/animals/:45678
Option 2> pass using equal sign i.e https://th-apex-http-callout.herokuapp.com/animals/:id=45678.

Regardless i am getting the following response {"animal": {"id": 0,"name": "","eats": "","says": ""}}. I want some test data to verify the code is working does any body has that

Hi,

 

I have created a page layout and marked many fields read-only.

I then created a profile with both the "Edit Read Only Fields" and "Modify All Data" boxes unchecked.

 

However, when I logged in as that user, the fields are still editable for me.

 

Is there another setting that I am missing?

I even tried to set the field security to be read-only for all profiles; those fields remain editable.

 

Any help would be greatly appreciated!

 

Thanks,

-Debby

  • July 22, 2013
  • Like
  • 0