• SARANG DESHPANDE
  • NEWBIE
  • 60 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 15
    Questions
  • 8
    Replies
User-added image

I am getting above error while validating challenge for Advanced Apex specialist. Following is my code, which I think is working perfectly well. I can't think of a reson why this error is being thrown. Any help is appreciated.:
 
/**
* @name TestDataFactory
* @description Contains methods to construct and/or validate commonly used records
**/
public with sharing class TestDataFactory {
    
    /**
* @name ConstructCollaborationGroup
* @description
**/
    public static CollaborationGroup ConstructCollaborationGroup(){
        //ToDo: Ensure this method returns a single Chatter CollaborationGroup
        //    whose Name starts with 'TEST' followed by the INVENTORY_ANNOUNCEMENTS constant
        //    and configured so anyone can join, see and post updates.
        CollaborationGroup cGroup = new CollaborationGroup(name = 'TEST' + Constants.INVENTORY_ANNOUNCEMENTS,
                                                           CollaborationType = 'Public',
                                                          IsAutoArchiveDisabled = true);
        insert cGroup;
        //Database.SaveResult sr = Database.insert(cGroup);
        return cGroup;
    }
    
    /**
* @name CreateProducts
* @description Constructs a list of Product2 records for unit tests
**/
    public static List<Product2> ConstructProducts(Integer cnt){
        //ToDo: Ensure this method returns a list, of size cnt, of uniquely named Product2 records
        //  with all the required fields populated
        //  and IsActive = true
        //  an Initial Inventory set to 10
        //  and iterating through the product family picklist values throughout the list.
        List<Schema.PicklistEntry> picklistValues = Constants.PRODUCT_FAMILY;
        List<Product2> productTestDataList = new List<Product2>();
        for(Integer i = 0 ; i < cnt ; i++){
            Product2 prod = new Product2(name = 'Product' + i,
                                         IsActive = true,
                                         Initial_Inventory__c = 10,
                                         Family = picklistValues[i].getValue());
            productTestDataList.add(prod);
        }
        insert productTestDataList;
        return productTestDataList;
    }
    
    /**
* @name CreatePricebookEntries
* @description Constructs a list of PricebookEntry records for unit tests
**/
    public static List<PricebookEntry> ConstructPricebookEntries(List<Product2> prods){
        //ToDo: Ensure this method returns a corresponding list of PricebookEntries records
        //  related to the provided Products
        //  with all the required fields populated
        //  and IsActive = true
        //  and belonging to the standard Pricebook
        List<PricebookEntry> pBookEntryList = new List<PricebookEntry>();
        for(Product2 prod : prods){
            PricebookEntry pEntry = new PricebookEntry(UseStandardPrice = true,
                                                       Product2Id = prod.Id,
                                                       IsActive = true,
                                                       UnitPrice = 25,
                                                       Pricebook2Id = Constants.STANDARD_PRICEBOOK_ID);
            pBookEntryList.add(pEntry);
        }
        insert pBookEntryList;
        return pBookEntryList;
    }
    
    /**
* @name CreateAccounts
* @description Constructs a list of Account records for unit tests
**/
    public static List<Account> ConstructAccounts(Integer cnt){
        //ToDo: Ensure this method returns a list of size cnt of uniquely named Account records
        //  with all of the required fields populated.
        List<Account> accList = new List<Account>();
        for(Integer i = 0 ; i< cnt ; i++){
            Account acc = new Account(name = 'Account' + i);
            accList.add(acc);
        }
        insert accList;
        return accList;
    }
    
    /**
* @name CreateContacts
* @description Constructs a list of Contacxt records for unit tests
**/
    public static List<Contact> ConstructContacts(Integer cnt, List<Account> accts){
        //ToDo: Ensure this method returns a list, of size cnt, of uniquely named Contact records
        //  related to the provided Accounts
        //  with all of the required fields populated.
        List<Contact> contList = new List<Contact>();
        for(Integer i = 0 ; i < cnt ; i++){
            Contact cont = new Contact(lastname = 'Contact' + i,
                                       AccountId = accts[i].Id);
            contList.add(cont);
        }
        insert contList;
        return contList;
    }
    
    /**
* @name CreateOrders
* @description Constructs a list of Order records for unit tests
**/
    public static List<Order> ConstructOrders(Integer cnt, List<Account> accts){
        //ToDo: Ensure this method returns a list of size cnt of uniquely named Order records
        //  related to the provided Accounts
        //  with all of the required fields populated.
        List<Order> contList = new List<Order>();
        for(Integer i = 0 ; i < cnt ; i++){
            Order cont = new Order( name = 'order ' + i,
                                   AccountId = accts[i].Id,
                                   EffectiveDate = Date.today());
            contList.add(cont);
        }
        insert contList;
        return contList;
    }
    
    /**
* @name CreateOrderItems
* @description Constructs a list of OrderItem records for unit tests
**/
    public static List<OrderItem> ConstructOrderItems(integer cnt, list<pricebookentry> pbes, list<order> ords){
        //ToDo: Ensure this method returns a list of size cnt of OrderItem records
        //  related to the provided Pricebook Entries
        //  and related to the provided Orders
        //  with all of the required fields populated.
        //  Hint: Use the DEFAULT_ROWS constant for Quantity as it will be used in the next challenge
        List<OrderItem> oItemList = new List<OrderItem>();
        for(Integer i = 0 ; i < cnt ; i++){
            OrderItem oItem = new OrderItem(UnitPrice = 100.00,
                                           Quantity	= Constants.DEFAULT_ROWS,
                                           OrderId = ords[i].Id,
                                          PricebookEntryId = pbes[i].Id);
            oItemList.add(oItem);
        }
        insert oItemList;
        return oItemList;
    }
    
    /**
* @name SetupTestData
* @description Inserts accounts, contacts, Products, PricebookEntries, Orders, and OrderItems.
**/
    public static void InsertTestData(Integer cnt){
        //ToDo: Ensure this method calls each of the construct methods
        //  and inserts the results for use as test data.
        List<Product2> productsList = ConstructProducts(cnt);
        List<PricebookEntry> pBookList = ConstructPricebookEntries(productsList);
        List<Account> actList = ConstructAccounts(cnt);
        ConstructContacts(cnt, actList);
        List<Order> orderList = ConstructOrders(cnt, actList);
        ConstructOrderItems(cnt, pBookList, orderList);
    }
    
}



 
I have got mail saying 28th October is last date for maintainance exam of DEV401 cert. If I give App builder exam before that would I still have to give anny maintainance exam? Also, do I have to give maintainance exams for App builder certs also and how frequently?
  Hi, Iam stuck in trailhead challenge in "Connect components with Events". I am getting above error(The campingList component isn't handing the added item correctly.), though my functionality is perfecly working fine. Please help me in this...I have tried solutions for the same error in this forum before, but they are not working as well.

CampingList.cmp:
 
<aura:component controller="CampingListController">
    
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
    <aura:handler name="addItem" action="{!c.handleAddItem}" event="c:addItemEvent"/>
    
    <aura:attribute name="items" type="Camping_Item__c[]" />
    
    <c:campingHeader />
    
    <c:campingListForm />
    
    <aura:iteration items="{!v.items}" var="item">
        <c:campingListItem item="{!item}" />
    </aura:iteration>
    
</aura:component>

CampingListController.js:
 
({

    doInit: function(component, event, helper){
        
        var action=component.get("c.getItems");
        action.setCallback(this, function(response)
                           {
                               var state = response.getState();
                               if(component.isValid() && state=='SUCCESS')
                               {
                                   component.set("v.items", response.getReturnValue());
                               }
                               else
                               {
                                   console.log("Error in state: "+ state);
                               }
                           });

        $A.enqueueAction(action);
        
    },
    
    handleAddItem : function(component, event, helper)
    {
        var item=event.getParam("item");
        var action=component.get("c.saveItem");
        
        action.setParams
        ({
                "item" : item
        });
        
        action.setCallback(this, function(response)
                           {
                               var state=response.getState();
                               if(component.isValid() && state == 'SUCCESS')
                               {
                                   var itemArray=component.get("v.items");
                                   itemArray.push(response.getReturnValue());
                                   component.set("v.items", itemArray);
                               }
                               else
                               {
                                   console.log('Error in state: '+ state);
                               }
                           });
        
        $A.enqueueAction(action);
    },
})

 
I have opportunity object as master and OppChild as its child object. I am cloning a record of opportunity and the child record is also getting copied from original Opportunity to this cloned opportunity. While cloning, I am changing the currency code of opportunity from USD to EURO. However, the child object still shows the currency as USD.

1)Is this a standard functionality that CurrencyISOCode of parent is copied in Child's CurrencyISOCode?
2)If yes then does it work while cloning?
3)If yes then why it would not be working in my case?
I have 10 tabs in tabpanel. NowI make some changes to contents in tab A , click save, navigate to other tab while saving is going on  come back .Now all its contents are not shown. Can you please help how to refresh the contents of tab and show them on click of that tab.
I have a tabpanel with 8-10 tabs and each tab has a form. I enter certain values in form of 1st tab and click save. In between the process, it shows action support "saving....". In this meantime, I click on several tabs in the tabpanel and after few seconds, I am forced to the original tab. Now whe nI click save again, the same record is duplicated and saved in that tab.

For data display in the tabs, wrapper classes are used. Please can anybody explain why this could be happening?? 
I am new to visualforce and I want to display a lookup field when certain value in one of dropdowns changes on a custom object detail page.All other times the lookup field should not be visible.
How can this be achieved with visualforce?
Which tags would be required?
And would need to overwrite current detail page or we can edit the current detail page?
I want to use Reg ex in validation formulat for a field name. The name entered should be in format:
"TS_IT[0-9]_UC[0-9]_[any text]" example:
TS_IT04_UC05_test script for testing

how can this be achieved?
I want to change the type of a  lookup field from non-required to required depending on value in a picklist of same object(i.e using onChange attribute in visualforce) . Can somebody give me idea how to achieve this?
I was solving this challenge and my VF code is:

<apex:page standardController="Account" recordSetVar="Accounts" >
    <apex:pageblock>
        <apex:repeat var="a" value="{!Accounts}" rendered="true"  id="account_list">
            <li>
                <apex:outputLink value="https://ap1.salesforce.com/{!a.ID}" >
                    <apex:outputText value="{!a.Name}"/>
                </apex:outputLink>
            </li>
        </apex:repeat>
    </apex:pageblock>
</apex:page>

I am getting the list of accounts as required and on clicking on any of the accouts, it redirects to that accounts detail page.
Still I am getting following error from trailhead:

"The page does not bind to the record ID value (in order to link to the record detail page)"
I was solving the challenge of trailhead of Apex development:

The question was:
Create an Apex class that returns an array (or list) of formatted strings ('Test 0', 'Test 1', ...). The length of the array is determined by an integer parameter.The Apex class must be called 'StringArrayTest' and be in the public scope.
The Apex class must have a public static method called 'generateStringArray'.
The 'generateStringArray' method must return an array (or list) of strings. Each string must have a value in the format 'Test n' where n is the index of the current string in the array. The number of returned strings is specified by the integer parameter to the 'generateStringArray' method.

My code is:


public class StringArrayTest {

    static List<String> TestArray= new List<String>();
    public static String[] generateStringArray(Integer n){
        
        for(Integer i=1;i<=n;i++){   
            TestArray.add('Test'+i);
        }
        
        return TestArray;
    }
    
}

I am able to get desired outpuut but still it is returning an error:
Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

Not able to understand what it want exactly
I want to retrive standard filed of an object aolng with nme of its parent object.

My code is:

Line_item__c li=[select invoice_statement__r.name, line_item_number from Line_item__c limit 1];
String name=li.invoice_statement__r.name;
System.debug('Ivoice statement name for line item : '+li.line_item_number+' is :'+name);

where line_item is child object and invoice_statement is parentobject. I am trying to retieve line_item_number  which is standard field of object line_item object.

Error given is:Line: 1, Column: 17
No such column 'line_item_number' on entity 'Line_Item__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

How can we retrive stamdard fields in this fashion? Or is there is some other way?
User-added image

I am getting above error while validating challenge for Advanced Apex specialist. Following is my code, which I think is working perfectly well. I can't think of a reson why this error is being thrown. Any help is appreciated.:
 
/**
* @name TestDataFactory
* @description Contains methods to construct and/or validate commonly used records
**/
public with sharing class TestDataFactory {
    
    /**
* @name ConstructCollaborationGroup
* @description
**/
    public static CollaborationGroup ConstructCollaborationGroup(){
        //ToDo: Ensure this method returns a single Chatter CollaborationGroup
        //    whose Name starts with 'TEST' followed by the INVENTORY_ANNOUNCEMENTS constant
        //    and configured so anyone can join, see and post updates.
        CollaborationGroup cGroup = new CollaborationGroup(name = 'TEST' + Constants.INVENTORY_ANNOUNCEMENTS,
                                                           CollaborationType = 'Public',
                                                          IsAutoArchiveDisabled = true);
        insert cGroup;
        //Database.SaveResult sr = Database.insert(cGroup);
        return cGroup;
    }
    
    /**
* @name CreateProducts
* @description Constructs a list of Product2 records for unit tests
**/
    public static List<Product2> ConstructProducts(Integer cnt){
        //ToDo: Ensure this method returns a list, of size cnt, of uniquely named Product2 records
        //  with all the required fields populated
        //  and IsActive = true
        //  an Initial Inventory set to 10
        //  and iterating through the product family picklist values throughout the list.
        List<Schema.PicklistEntry> picklistValues = Constants.PRODUCT_FAMILY;
        List<Product2> productTestDataList = new List<Product2>();
        for(Integer i = 0 ; i < cnt ; i++){
            Product2 prod = new Product2(name = 'Product' + i,
                                         IsActive = true,
                                         Initial_Inventory__c = 10,
                                         Family = picklistValues[i].getValue());
            productTestDataList.add(prod);
        }
        insert productTestDataList;
        return productTestDataList;
    }
    
    /**
* @name CreatePricebookEntries
* @description Constructs a list of PricebookEntry records for unit tests
**/
    public static List<PricebookEntry> ConstructPricebookEntries(List<Product2> prods){
        //ToDo: Ensure this method returns a corresponding list of PricebookEntries records
        //  related to the provided Products
        //  with all the required fields populated
        //  and IsActive = true
        //  and belonging to the standard Pricebook
        List<PricebookEntry> pBookEntryList = new List<PricebookEntry>();
        for(Product2 prod : prods){
            PricebookEntry pEntry = new PricebookEntry(UseStandardPrice = true,
                                                       Product2Id = prod.Id,
                                                       IsActive = true,
                                                       UnitPrice = 25,
                                                       Pricebook2Id = Constants.STANDARD_PRICEBOOK_ID);
            pBookEntryList.add(pEntry);
        }
        insert pBookEntryList;
        return pBookEntryList;
    }
    
    /**
* @name CreateAccounts
* @description Constructs a list of Account records for unit tests
**/
    public static List<Account> ConstructAccounts(Integer cnt){
        //ToDo: Ensure this method returns a list of size cnt of uniquely named Account records
        //  with all of the required fields populated.
        List<Account> accList = new List<Account>();
        for(Integer i = 0 ; i< cnt ; i++){
            Account acc = new Account(name = 'Account' + i);
            accList.add(acc);
        }
        insert accList;
        return accList;
    }
    
    /**
* @name CreateContacts
* @description Constructs a list of Contacxt records for unit tests
**/
    public static List<Contact> ConstructContacts(Integer cnt, List<Account> accts){
        //ToDo: Ensure this method returns a list, of size cnt, of uniquely named Contact records
        //  related to the provided Accounts
        //  with all of the required fields populated.
        List<Contact> contList = new List<Contact>();
        for(Integer i = 0 ; i < cnt ; i++){
            Contact cont = new Contact(lastname = 'Contact' + i,
                                       AccountId = accts[i].Id);
            contList.add(cont);
        }
        insert contList;
        return contList;
    }
    
    /**
* @name CreateOrders
* @description Constructs a list of Order records for unit tests
**/
    public static List<Order> ConstructOrders(Integer cnt, List<Account> accts){
        //ToDo: Ensure this method returns a list of size cnt of uniquely named Order records
        //  related to the provided Accounts
        //  with all of the required fields populated.
        List<Order> contList = new List<Order>();
        for(Integer i = 0 ; i < cnt ; i++){
            Order cont = new Order( name = 'order ' + i,
                                   AccountId = accts[i].Id,
                                   EffectiveDate = Date.today());
            contList.add(cont);
        }
        insert contList;
        return contList;
    }
    
    /**
* @name CreateOrderItems
* @description Constructs a list of OrderItem records for unit tests
**/
    public static List<OrderItem> ConstructOrderItems(integer cnt, list<pricebookentry> pbes, list<order> ords){
        //ToDo: Ensure this method returns a list of size cnt of OrderItem records
        //  related to the provided Pricebook Entries
        //  and related to the provided Orders
        //  with all of the required fields populated.
        //  Hint: Use the DEFAULT_ROWS constant for Quantity as it will be used in the next challenge
        List<OrderItem> oItemList = new List<OrderItem>();
        for(Integer i = 0 ; i < cnt ; i++){
            OrderItem oItem = new OrderItem(UnitPrice = 100.00,
                                           Quantity	= Constants.DEFAULT_ROWS,
                                           OrderId = ords[i].Id,
                                          PricebookEntryId = pbes[i].Id);
            oItemList.add(oItem);
        }
        insert oItemList;
        return oItemList;
    }
    
    /**
* @name SetupTestData
* @description Inserts accounts, contacts, Products, PricebookEntries, Orders, and OrderItems.
**/
    public static void InsertTestData(Integer cnt){
        //ToDo: Ensure this method calls each of the construct methods
        //  and inserts the results for use as test data.
        List<Product2> productsList = ConstructProducts(cnt);
        List<PricebookEntry> pBookList = ConstructPricebookEntries(productsList);
        List<Account> actList = ConstructAccounts(cnt);
        ConstructContacts(cnt, actList);
        List<Order> orderList = ConstructOrders(cnt, actList);
        ConstructOrderItems(cnt, pBookList, orderList);
    }
    
}



 
I was solving this challenge and my VF code is:

<apex:page standardController="Account" recordSetVar="Accounts" >
    <apex:pageblock>
        <apex:repeat var="a" value="{!Accounts}" rendered="true"  id="account_list">
            <li>
                <apex:outputLink value="https://ap1.salesforce.com/{!a.ID}" >
                    <apex:outputText value="{!a.Name}"/>
                </apex:outputLink>
            </li>
        </apex:repeat>
    </apex:pageblock>
</apex:page>

I am getting the list of accounts as required and on clicking on any of the accouts, it redirects to that accounts detail page.
Still I am getting following error from trailhead:

"The page does not bind to the record ID value (in order to link to the record detail page)"
I was solving the challenge of trailhead of Apex development:

The question was:
Create an Apex class that returns an array (or list) of formatted strings ('Test 0', 'Test 1', ...). The length of the array is determined by an integer parameter.The Apex class must be called 'StringArrayTest' and be in the public scope.
The Apex class must have a public static method called 'generateStringArray'.
The 'generateStringArray' method must return an array (or list) of strings. Each string must have a value in the format 'Test n' where n is the index of the current string in the array. The number of returned strings is specified by the integer parameter to the 'generateStringArray' method.

My code is:


public class StringArrayTest {

    static List<String> TestArray= new List<String>();
    public static String[] generateStringArray(Integer n){
        
        for(Integer i=1;i<=n;i++){   
            TestArray.add('Test'+i);
        }
        
        return TestArray;
    }
    
}

I am able to get desired outpuut but still it is returning an error:
Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

Not able to understand what it want exactly
I want to retrive standard filed of an object aolng with nme of its parent object.

My code is:

Line_item__c li=[select invoice_statement__r.name, line_item_number from Line_item__c limit 1];
String name=li.invoice_statement__r.name;
System.debug('Ivoice statement name for line item : '+li.line_item_number+' is :'+name);

where line_item is child object and invoice_statement is parentobject. I am trying to retieve line_item_number  which is standard field of object line_item object.

Error given is:Line: 1, Column: 17
No such column 'line_item_number' on entity 'Line_Item__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

How can we retrive stamdard fields in this fashion? Or is there is some other way?
Hello,

This is the trailhead questions which I am trying to solve :

Create an Apex class that returns an array (or list) of formatted strings ('Test 0', 'Test 1', ...). The length of the array is determined by an integer parameter.The Apex class must be called 'StringArrayTest' and be in the public scope.
The Apex class must have a public static method called 'generateStringArray'.
The 'generateStringArray' method must return an array (or list) of strings. Each string must have a value in the format 'Test n' where n is the index of the current string in the array. The number of returned strings is specified by the integer parameter to the 'generateStringArray' method.


Here is my code :

public class StringArrayTest {
    public static List <String> generateStringArray (Integer n) {
       List<String> List1 = new List<String> ();
        for(Integer i=0;i<n;i++) {
          List1.add('\'Test'+ i+'\'' );
  }
        System.debug(List1);
        return List1;
    } 

}


I am getting following error :

Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.


I tried it many times but I am not able to solve this problem. Please help. 



 
Hi all

I'm executing this query from Java code using REST service:

SELECT Id, Name, StageName, Amount FROM Opportunity WHERE AccountId = 'xyz' AND OwnerId = 'abc'

I have System Administrator role, View All permission, Object level full permission on Opportunity object, all field level permissions on Opportunity fields.

Still i'm getting this error:

sObject type 'Opportunity' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.","errorCode":"INVALID_TYPE"

can you please suggest what i'm missing

I have multi currency enabled in my org, and have accounts who we record things for in mutliple currencies. 

 

So 'account' A, has a 'project' in the US billed in USD and one in the UK billed in gbp and one in France billed in euros. So their project records reflect these currencies in the currency iso code field.

 

When we generate child 'billing' records against each of these projects, I want the records to inherit the same currency iso code as the parent by default. Unfortunately they don't inherit it. 

 

I've tried workflow field updates, but they dont seem to have access to the currency iso code field.

 

I don't know if a master detail relationship would solve it, but I cant go there as this 'billing' object is the target of a snapshot, and you cant have insert triggers either....and yes I know you can't run workflows on a snapshot object either, but i am disabling them before I run the analytic snapshot.

 

I feel like I'm stuffed here tbh...but would gladly appreciate any input by someone more familair in this area.