• Manoj Goswami 5
  • NEWBIE
  • 70 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 9
    Replies
I have total minutes calculated (total_minutes__c),
How to convert these minutes in Days, Hours and Minutes.
I want something like this :
eg.
Input: total_minutes__c = 12495
Output = 8 Days 16 Hours 15 Minutes 

Thanks in advance.
1) A developer created a Visualforce page that has a custom controller that navigates to an external website after the'
command button is pressed. What is the recommended way to test this functionality? 
A. Use .getURL() on the result of the action method and System.assertEquals () to compare the resulting URL.
B. ‘ Use ApexPages.currentPage () .getUrl () and System.assertElquals () to compare the end URL.
C. ‘ Use Test.getCurrentPage() .getUrl () and System.assertEquals () to compare the end URL.
D. Test the navigation by executing the use case through the browser and manually inspecting the resulting URL.

2) What is the output of the following code snippet?
Contact con = new Contact( LastName = 'JOHNSON', LeadSource = 'Web')
Savepoint sp = Database.setSavepoint();
insert con;
Database.rollback(sp);
con.LeadSource = 'Email'
insert con;
Error is at line 6(last) - > Can not specify id in an insert call
A. A runtime error will be thrown on line 5.
B. The contact record will be inserted with Leadsource value Web.
C. A runtime error will be thrown on line 8.
D. The contact record will be inserted with Leadsource value Email.

3) A company has 20,000 rows in the Account object and 2 million rows in the Sales_Data_c object that is related to Account. All
of the records in the Sales_Data_c object have a field that contains the string 'Le.‘ Which statement will throw a "Too many query
rows" exception? Choose 2 answers 
A. List<List<SObject>> result= [FIND 'Le' IN ALL FIELDS RETURNING Sales_Data_c(Id)];
B. List<Account> result = [SELECT Id, (SELECT Id FROM Sales_Data_r) FROM Account]
C. List<sObject> result = Database.query('SELECT Id FROM Sales_Data_c LIMIT 50000');
D, List<AggregateResult> result = [SELECT count(Id) total FROM Sales_Data_c];

4) What is the output of the following code snippet?
Contact con = new Contact( LastName = 'Smith', Department = 'Admin')
insert con;
Savepoint sp_finance = Database.set5avepoint();
con.Department = 'finance';
update con;
SavepOLnt sp_hr = Database.set5avepo1nt();
con.Department = 'HR';
update con;
Database.rollback(3p_flnance);
Database.rollback(3p_hr); = Error
A. The contact record will be saved ME department value HR.
B. A runtime error will be thrown on line 12.
C. A runtime error will be thrown on line 13.
D. The contact record will be saved with department value Finance

5) What is a limitation of compound fields? 
A. Are read-only unless accessed by Location and Address Apex classes.
B. Can only be updated through individual field components.
C. Are read-only when accessed through Visualforce pages.
D. Cannot be queried through the use of Apex classes.

6) A developer has created a solution using the SOAP API for authenticating Communities users. What is needed when issuing
the login()Call? Choose 2 answers 
A. Organization Id
B. Security Token
C. Session Id
D. Username and Password

7) Given the following code sample, what is a potential issue regarding bulk processing of records?
trigger accountTestTrggr on Account (before insert, before update)
Account acct = Trigger.new[0];
List <Contact> contacts = new List <Contact> ([select id, salutation, firstname, lastname,
email from Contact where accountId = :acct.Id]);
for (Contact con: contacts)
con.Title = 'Not Selected';
update contacts; 
A. The code will not execute because the record in the list can be null and cause an exception.
B. The code will process one record that is called explicitly per execution.
C. The code will not execute because the list can be null and cause an exception.
D. The code will have to be invoked multiple times to process all the records.

8) A company requires that a child custom record is created when an Order record is inserted. The company's administrator
must be able to make changes to the solution.
What is the recommended solution for implementing this requirement? 
A. Create a Visual Workflow that will create the custom child record when the Order is inserted.
B. Create a Force.com Workflow Rule to create the custom child record when the Order is inserted.
C. Create an Apex Trigger to create the custom child record when the Order is inserted.
D. Create a Lightning Process to create the custom child record when the Order is inserted

9) What is a best practice when unit testing a controller? Choose 2 answers 
A. Simulate user interaction by leveraging Test.setMock().
B. Verify correct page references by using getURL()
C. Access test data by using seeAllData=true.
D. Set query parameters by using getParameters () .put

10) What is a consideration when testing batch Apex? 
Choose 2 answers
A. Test methods must execute the batch with a scope size of less than 200 records.
B. Test methods must call the batch execute () method once.
C. Test methods must use the @isTest (SeeAllData=true) annotation.
D. Test methods must run the batch between Test. startTest () and Test.stopTest

11) Which statement is true about using ConnectApi namespace (also called Chatter in Apex)?
Choose 2 answers 
A. Chatter in Apex methods honor the 'with sharing' and 'without sharing' keywords.
B. Chatter in Apex operations are synchronous, and they occur immediately.
C. Chatter in Apex methods do not run in system mode; they run in the context of the current user.
D. Many test methods related to Chatter in Apex require the BIsTest (SeeAllData=true) annotation.

12) A developer is writing unit tests for the following method:
public static Boolean isFreezing(String celsiusTemp)
if(String.isNotBlank(celsiusTemp) && celsiusTemp.isNumeric())
return Decimal.valueof(celsiusTemp) <= 0;
return null;
Which assertion would be used in a negative test case? 
A_System.assertEquals(true, isFreezing(null));
B. System. assertEquals (true, isFreezing( ' 0’);
C System.assertEquals(null, isFreezing('asdf'));
D.System.assertEquals(true, isFreezing('lOO'));

13) A company wants to create a dynamic survey that navigates users through a different series of questions based on
their previous responses.
What is the recommended solution to meet this requirement? 
A. Dynamic Record Choice
B. Lightning Process Builder
C. Visualforce and Apex
D. Custom Lightning application

14) Which statement is true regarding both Flow and Lightning Process?
A. Can use Apex methods with the @InvocableMethod annotation.
B. Are both server-side considerations in the Order of Execution.
C. Can use Apex that implements the Process. Plugin interface.
D. Are able to be embedded directly into Visualforce pages.

15) A developer writes the following code:
public with sharing class OrderController
public PaqeReference sendOrder()
Order__c order = new Order__c
insert order;
ExternalOrder externalOrder = new ExternalOrder(order);
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://www.example.org/v1/orders');
req.setMethod('POST');
req.setBody(JSON.serialize(externalOrder));
HttpResponse res = h.send(req);
order = (ExternalOrder)JSON.deserialize(res.getBody(), ExternalOrder.class);
While testing the code, the developer receives the followmg error message:
System.CalloutException : You have uncommitted work pending
What should the developer do? 
Choose 2 answers
A. Use the asyncSend() method of the HTTP class to send the request in async context.
B. Ensure all callouts are completed prior to executing DML statements.
C. Move the web service callout into an @future method.
D. Use Database.insert (order, true) to immediately commit any database changes.
Error : 
User-added image

I have overridden the add and new standard buttons as well.
User-added image
Product2Extension.cls :
public class Product2Extension {

  public List<ProductWrapper> productsToInsert {get; set;}

  public Product2Extension(ApexPages.StandardController controller){
    productsToInsert = new List<ProductWrapper>();
    AddRows();
  }

  public void AddRows(){
    for (Integer i=0; i<Constants.DEFAULT_ROWS; i++ ) {
      productsToInsert.add( new ProductWrapper() );
    }
  }

  public List<ChartHelper.ChartData> GetInventory(){
    return ChartHelper.GetInventory();
  }

  public List<SelectOption> GetFamilyOptions() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption(Constants.SELECT_ONE, Constants.SELECT_ONE));
    for(PickListEntry eachPicklistValue : Constants.PRODUCT_FAMILY) {
      options.add(new SelectOption(eachPicklistValue.getValue(), eachPicklistValue.getLabel()));
    }
    return options;
  }

  public PageReference Save(){
    Savepoint sp = Database.setSavepoint();
    try {
      List<Product2> products = new List<Product2>();
      List<PricebookEntry> pbes = new List<PricebookEntry>();

      for (ProductWrapper prodwrapper : productsToInsert) {
        if(prodwrapper.productRecord != null && prodwrapper.pricebookEntryRecord != null) {
          if(prodwrapper.productRecord.Name != null && prodwrapper.productRecord.Family != null && constants.SELECT_ONE != prodwrapper.productRecord.Family && prodwrapper.productRecord.Initial_Inventory__c != null && prodwrapper.pricebookEntryRecord.UnitPrice != null) {
            products.add(prodwrapper.productRecord);
            PricebookEntry pbe = prodwrapper.pricebookEntryRecord;
            pbe.IsActive = true;
            pbe.Pricebook2Id = Constants.STANDARD_PRICEBOOK_ID;
            pbes.add(pbe);
          }
        }
      }

      insert products;

      for (integer i = 0; i < pbes.size(); i++) {
        pbes[i].Product2Id = products[i].Id;
      }
      insert pbes;

      //If successful clear the list and display an informational message
      apexPages.addMessage(new ApexPages.message(ApexPages.Severity.INFO,productsToInsert.size()+' Inserted'));
      productsToInsert.clear();         //Do not remove
      AddRows();        //Do not remove
    } catch (Exception e){
      Database.rollback(sp);
      apexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, Constants.ERROR_MESSAGE));
    }
    return null;
  }

  public class ProductWrapper {
    public Product2 productRecord {get; set;}
    public PriceBookEntry pricebookEntryRecord {get; set;}

    public ProductWrapper() {
      productRecord = new product2(Initial_Inventory__c =0);
      pricebookEntryRecord = new pricebookEntry(Unitprice=0.0);
    }
  }
}
Product2New​.page :
<apex:page standardcontroller="Product2" extensions="Product2Extension">
  <apex:sectionHeader title="New Product" subtitle="Add Inventory"/>
  <apex:pageMessages id="pageMessages"/>
  <apex:form id="form">
    <apex:actionRegion>
      <apex:pageBlock title="Existing Inventory" id="existingInv">
        <apex:chart data="{!Inventory}" width="600" height="400">
          <apex:axis type="Category" fields="name" position="left" title="Product Family"/>
          <apex:axis type="Numeric" fields="val" position="bottom" title="Quantity Remaining"/>
          <apex:barSeries axis="bottom" orientation="horizontal" xField="val" yField="name"/>
        </apex:chart>
      </apex:pageBlock>
      <apex:pageBlock title="New Products">
        <apex:pageBlockButtons location="top">
          <apex:commandButton action="{!save}" value="Save" reRender="existingInv, orderItemTable, pageMessages"/>
        </apex:pageBlockButtons>
        <apex:pageBlockButtons location="bottom">
          <apex:commandButton action="{!addRows}" value="Add" reRender="orderItemTable, pageMessages"/>
        </apex:pageBlockButtons>

        <apex:pageBlockTable value="{!productsToInsert}" var="p" id="orderItemTable">
          <apex:column headerValue="{!$ObjectType.Product2.Fields.Name.Label}">
            <apex:inputText value="{!p.productRecord.Name}"/>
          </apex:column>
          <apex:column headerValue="{!$ObjectType.Product2.Fields.Family.Label}">
            <apex:selectList value="{!p.productRecord.Family}" size="1" multiselect="false">
              <apex:selectOptions value="{!FamilyOptions}"></apex:selectOptions>
            </apex:selectList>
          </apex:column>
          <apex:column headerValue="{!$ObjectType.Product2.Fields.IsActive.Label}">
            <apex:inputField value="{!p.productRecord.isActive}"/>
          </apex:column>
          <apex:column headerValue="{!$ObjectType.PricebookEntry.Fields.UnitPrice.Label}">
            <apex:inputText value="{!p.pricebookEntryRecord.UnitPrice}"/>
          </apex:column>
          <apex:column headerValue="{!$ObjectType.Product2.Fields.Initial_Inventory__c.Label}">
            <apex:inputField value="{!p.productRecord.Initial_Inventory__c}"/>
          </apex:column>
        </apex:pageBlockTable>
      </apex:pageBlock>
    </apex:actionRegion>
  </apex:form>
</apex:page>
product2Trigger : 
trigger product2Trigger on Product2 (after update) {
  Product2Helper.AfterUpdate((List<Product2>)Trigger.new);
}
Constants.cls : 
public class Constants {
  public static final Integer DEFAULT_ROWS = 5;
  public static final String SELECT_ONE = Label.Select_One;
  public static final String INVENTORY_LEVEL_LOW = Label.Inventory_Level_Low;
  public static final List<Schema.PicklistEntry> PRODUCT_FAMILY = Product2.Family.getDescribe().getPicklistValues();
  public static final String DRAFT_ORDER_STATUS = 'Draft';
  public static final String ACTIVATED_ORDER_STATUS = 'Activated';
  public static final String INVENTORY_ANNOUNCEMENTS = 'Inventory Announcements';
  public static final String ERROR_MESSAGE = 'An error has occurred, please take a screenshot with the URL and send it to IT.';
  public static final Id STANDARD_PRICEBOOK_ID = '01s6A0000031LaYQAU'; //Test.isRunningTest() ? Test.getStandardPricebookId() : [SELECT Id FROM PriceBook2 WHERE isStandard = true LIMIT 1].Id;
}
Can somebody try and paste the working code here. It would be a great help.
Thanks in advance.




 
I have trield almost every code and solution from forum still stuck into this challange.
Challange
Refactor Components and Communicate with Events
Refactor the input form for camping list items into its own component and communicate with component events.
Replace the HTML form in the campingList component with a new campingListForm component that calls the clickCreateItem JavaScript controller action when clicked.
The campingList component listens for a c:addItemEvent event and executes the action handleAddItem in the JavaScript controller. The handleAdditem method saves the record to the database and adds the record to the items value provider.
The addItemEvent event is of type component and has a Camping_Item__c type attribute named item.
The campingListForm registers an addItem event of type c:addItemEvent.
The campingListFormController JavaScript controller calls the helper's createItem method if the form is valid.
The campingListFormHelper JavaScript helper creates an addItem event with the item to be added and then fires the event. It then resets the newItem value provider with a blank sObjectType of type Camping_Item__c.

I am not pasting entire code as it is too lengthy.

I am trying from past 2 days, many hours ... still no luck.
Tried with every possible solution from Forum and StackExchange tried with fresh Trailhead Org, nothing worked.
with each try .. getting new errors.
Can someone please try the solution in their system and provide it in the comment ssection. That would be a great help.
Thanks in advance,
Manoj
 

Can someone provide Problems for Coding Round ?
I am doing preparation for interview, having 1.5 Yrs of exp in Salesforce Development. I need some scenario based problems that can be implemented with Code.

Topics to cover :
1. Collections,
2. Triggers with Cross object SOQL queries upto 4 level in lookup relationship,
3. Visualforce Page flow,
4. Batch Apex problems

Apex: 
<apex:page controller="allObjectListClass">
    <apex:pageBlock>
        <apex:form id = "myForm">
            
            <apex:pageBlockSection>
                <apex:selectList id="objList" value="{!selectedObj}" size="1">
                    <apex:selectOptions value="{!objName}"/>
                    <apex:actionSupport event="onchange" reRender="myForm"/>
                </apex:selectList>  
            </apex:pageBlockSection>
            
            <apex:pageBlockSection>
                <apex:pageblockTable value="{!fieldName}" var="f">
                    <apex:column value="{!f}"/>
                </apex:pageblockTable>
            </apex:pageBlockSection>
            
        </apex:form>        
    </apex:pageBlock>    
</apex:page>
Controller :
public class allObjectListClass {
    public String selectedObj {get;set;}
    
    public static List<selectOption> getObjName(){
        List<selectOption> options = new List<selectOption>();
        
        for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
        {
            Schema.DescribeSObjectResult objResult = o.getDescribe();           
            system.debug( 'Sobject API Name: ' + objResult.getName() +' Sobject Label Name: ' + objResult.getLabel());           
            options.add(new SelectOption(objResult.getName(),objResult.getLabel()));
        }
        return options;
    }
    
    public static List<String> getFieldName(){
        List<String> reqFields = new List<String>();
        /*
			Required Code 
		*/
        return reqFields;
    }
}
I am getting a hard time dealing with schema methods, i have gone through the Salesforce documentation though.
Thanks in advance...


 
HI, 
     I'm unable to view any Tab in my Trailhead Org's Home Page (in Lightning view only, with classic its all fine). I think i messed up the settings while customizing the Home page in a trailhead challange. Need help , I have finished many challanges in this Org only. So creating a new org is off the table. Thanks in advance.
User-added image
I want a list of all Objects in my org and displaying it in a drop down in Visualforce page. The code has compiled but giving unexpected error while getting Preview of VF page.

Controller : 
// Controller
public without sharing class getObjectNamesController {    
    
    public Map<String, Schema.SObjectType> object_Map = Schema.getGlobalDescribe(); 
    public Set<String> objNamesSet = object_Map.keyset();
    
    public List<SelectOption> objNamesList{     
        get{
            Integer i=0;
            for(String myObjName : objNamesSet)
            {
                objNamesList.add(new SelectOption(String.valueOf(i),myObjName)) ; 
                i++;
            } 	    	
            System.debug(objNamesList);   
            return objNamesList ;
        }
        set;
    }
}
VF Page: 
<apex:page controller="getObjectNamesController">
  <apex:form >
      <apex:selectList size="1">
          <apex:selectOptions value="{!objNamesList}"></apex:selectOptions>
      </apex:selectList>
  </apex:form>
</apex:page>
User-added image

 
Apex: 
<apex:page controller="allObjectListClass">
    <apex:pageBlock>
        <apex:form id = "myForm">
            
            <apex:pageBlockSection>
                <apex:selectList id="objList" value="{!selectedObj}" size="1">
                    <apex:selectOptions value="{!objName}"/>
                    <apex:actionSupport event="onchange" reRender="myForm"/>
                </apex:selectList>  
            </apex:pageBlockSection>
            
            <apex:pageBlockSection>
                <apex:pageblockTable value="{!fieldName}" var="f">
                    <apex:column value="{!f}"/>
                </apex:pageblockTable>
            </apex:pageBlockSection>
            
        </apex:form>        
    </apex:pageBlock>    
</apex:page>
Controller :
public class allObjectListClass {
    public String selectedObj {get;set;}
    
    public static List<selectOption> getObjName(){
        List<selectOption> options = new List<selectOption>();
        
        for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
        {
            Schema.DescribeSObjectResult objResult = o.getDescribe();           
            system.debug( 'Sobject API Name: ' + objResult.getName() +' Sobject Label Name: ' + objResult.getLabel());           
            options.add(new SelectOption(objResult.getName(),objResult.getLabel()));
        }
        return options;
    }
    
    public static List<String> getFieldName(){
        List<String> reqFields = new List<String>();
        /*
			Required Code 
		*/
        return reqFields;
    }
}
I am getting a hard time dealing with schema methods, i have gone through the Salesforce documentation though.
Thanks in advance...


 
Error : 
User-added image

I have overridden the add and new standard buttons as well.
User-added image
Product2Extension.cls :
public class Product2Extension {

  public List<ProductWrapper> productsToInsert {get; set;}

  public Product2Extension(ApexPages.StandardController controller){
    productsToInsert = new List<ProductWrapper>();
    AddRows();
  }

  public void AddRows(){
    for (Integer i=0; i<Constants.DEFAULT_ROWS; i++ ) {
      productsToInsert.add( new ProductWrapper() );
    }
  }

  public List<ChartHelper.ChartData> GetInventory(){
    return ChartHelper.GetInventory();
  }

  public List<SelectOption> GetFamilyOptions() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption(Constants.SELECT_ONE, Constants.SELECT_ONE));
    for(PickListEntry eachPicklistValue : Constants.PRODUCT_FAMILY) {
      options.add(new SelectOption(eachPicklistValue.getValue(), eachPicklistValue.getLabel()));
    }
    return options;
  }

  public PageReference Save(){
    Savepoint sp = Database.setSavepoint();
    try {
      List<Product2> products = new List<Product2>();
      List<PricebookEntry> pbes = new List<PricebookEntry>();

      for (ProductWrapper prodwrapper : productsToInsert) {
        if(prodwrapper.productRecord != null && prodwrapper.pricebookEntryRecord != null) {
          if(prodwrapper.productRecord.Name != null && prodwrapper.productRecord.Family != null && constants.SELECT_ONE != prodwrapper.productRecord.Family && prodwrapper.productRecord.Initial_Inventory__c != null && prodwrapper.pricebookEntryRecord.UnitPrice != null) {
            products.add(prodwrapper.productRecord);
            PricebookEntry pbe = prodwrapper.pricebookEntryRecord;
            pbe.IsActive = true;
            pbe.Pricebook2Id = Constants.STANDARD_PRICEBOOK_ID;
            pbes.add(pbe);
          }
        }
      }

      insert products;

      for (integer i = 0; i < pbes.size(); i++) {
        pbes[i].Product2Id = products[i].Id;
      }
      insert pbes;

      //If successful clear the list and display an informational message
      apexPages.addMessage(new ApexPages.message(ApexPages.Severity.INFO,productsToInsert.size()+' Inserted'));
      productsToInsert.clear();         //Do not remove
      AddRows();        //Do not remove
    } catch (Exception e){
      Database.rollback(sp);
      apexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, Constants.ERROR_MESSAGE));
    }
    return null;
  }

  public class ProductWrapper {
    public Product2 productRecord {get; set;}
    public PriceBookEntry pricebookEntryRecord {get; set;}

    public ProductWrapper() {
      productRecord = new product2(Initial_Inventory__c =0);
      pricebookEntryRecord = new pricebookEntry(Unitprice=0.0);
    }
  }
}
Product2New​.page :
<apex:page standardcontroller="Product2" extensions="Product2Extension">
  <apex:sectionHeader title="New Product" subtitle="Add Inventory"/>
  <apex:pageMessages id="pageMessages"/>
  <apex:form id="form">
    <apex:actionRegion>
      <apex:pageBlock title="Existing Inventory" id="existingInv">
        <apex:chart data="{!Inventory}" width="600" height="400">
          <apex:axis type="Category" fields="name" position="left" title="Product Family"/>
          <apex:axis type="Numeric" fields="val" position="bottom" title="Quantity Remaining"/>
          <apex:barSeries axis="bottom" orientation="horizontal" xField="val" yField="name"/>
        </apex:chart>
      </apex:pageBlock>
      <apex:pageBlock title="New Products">
        <apex:pageBlockButtons location="top">
          <apex:commandButton action="{!save}" value="Save" reRender="existingInv, orderItemTable, pageMessages"/>
        </apex:pageBlockButtons>
        <apex:pageBlockButtons location="bottom">
          <apex:commandButton action="{!addRows}" value="Add" reRender="orderItemTable, pageMessages"/>
        </apex:pageBlockButtons>

        <apex:pageBlockTable value="{!productsToInsert}" var="p" id="orderItemTable">
          <apex:column headerValue="{!$ObjectType.Product2.Fields.Name.Label}">
            <apex:inputText value="{!p.productRecord.Name}"/>
          </apex:column>
          <apex:column headerValue="{!$ObjectType.Product2.Fields.Family.Label}">
            <apex:selectList value="{!p.productRecord.Family}" size="1" multiselect="false">
              <apex:selectOptions value="{!FamilyOptions}"></apex:selectOptions>
            </apex:selectList>
          </apex:column>
          <apex:column headerValue="{!$ObjectType.Product2.Fields.IsActive.Label}">
            <apex:inputField value="{!p.productRecord.isActive}"/>
          </apex:column>
          <apex:column headerValue="{!$ObjectType.PricebookEntry.Fields.UnitPrice.Label}">
            <apex:inputText value="{!p.pricebookEntryRecord.UnitPrice}"/>
          </apex:column>
          <apex:column headerValue="{!$ObjectType.Product2.Fields.Initial_Inventory__c.Label}">
            <apex:inputField value="{!p.productRecord.Initial_Inventory__c}"/>
          </apex:column>
        </apex:pageBlockTable>
      </apex:pageBlock>
    </apex:actionRegion>
  </apex:form>
</apex:page>
product2Trigger : 
trigger product2Trigger on Product2 (after update) {
  Product2Helper.AfterUpdate((List<Product2>)Trigger.new);
}
Constants.cls : 
public class Constants {
  public static final Integer DEFAULT_ROWS = 5;
  public static final String SELECT_ONE = Label.Select_One;
  public static final String INVENTORY_LEVEL_LOW = Label.Inventory_Level_Low;
  public static final List<Schema.PicklistEntry> PRODUCT_FAMILY = Product2.Family.getDescribe().getPicklistValues();
  public static final String DRAFT_ORDER_STATUS = 'Draft';
  public static final String ACTIVATED_ORDER_STATUS = 'Activated';
  public static final String INVENTORY_ANNOUNCEMENTS = 'Inventory Announcements';
  public static final String ERROR_MESSAGE = 'An error has occurred, please take a screenshot with the URL and send it to IT.';
  public static final Id STANDARD_PRICEBOOK_ID = '01s6A0000031LaYQAU'; //Test.isRunningTest() ? Test.getStandardPricebookId() : [SELECT Id FROM PriceBook2 WHERE isStandard = true LIMIT 1].Id;
}
Can somebody try and paste the working code here. It would be a great help.
Thanks in advance.




 
I have trield almost every code and solution from forum still stuck into this challange.
Challange
Refactor Components and Communicate with Events
Refactor the input form for camping list items into its own component and communicate with component events.
Replace the HTML form in the campingList component with a new campingListForm component that calls the clickCreateItem JavaScript controller action when clicked.
The campingList component listens for a c:addItemEvent event and executes the action handleAddItem in the JavaScript controller. The handleAdditem method saves the record to the database and adds the record to the items value provider.
The addItemEvent event is of type component and has a Camping_Item__c type attribute named item.
The campingListForm registers an addItem event of type c:addItemEvent.
The campingListFormController JavaScript controller calls the helper's createItem method if the form is valid.
The campingListFormHelper JavaScript helper creates an addItem event with the item to be added and then fires the event. It then resets the newItem value provider with a blank sObjectType of type Camping_Item__c.

I am not pasting entire code as it is too lengthy.

I am trying from past 2 days, many hours ... still no luck.
Tried with every possible solution from Forum and StackExchange tried with fresh Trailhead Org, nothing worked.
with each try .. getting new errors.
Can someone please try the solution in their system and provide it in the comment ssection. That would be a great help.
Thanks in advance,
Manoj
 
The error message states there is an error in column 3 line 1



trigger Region_cLeadTrigger on Lead (before insert) {

    staticResource sr = [
        select Body
        from StaticResource
        where Name = 'regionjson'

 
Apex: 
<apex:page controller="allObjectListClass">
    <apex:pageBlock>
        <apex:form id = "myForm">
            
            <apex:pageBlockSection>
                <apex:selectList id="objList" value="{!selectedObj}" size="1">
                    <apex:selectOptions value="{!objName}"/>
                    <apex:actionSupport event="onchange" reRender="myForm"/>
                </apex:selectList>  
            </apex:pageBlockSection>
            
            <apex:pageBlockSection>
                <apex:pageblockTable value="{!fieldName}" var="f">
                    <apex:column value="{!f}"/>
                </apex:pageblockTable>
            </apex:pageBlockSection>
            
        </apex:form>        
    </apex:pageBlock>    
</apex:page>
Controller :
public class allObjectListClass {
    public String selectedObj {get;set;}
    
    public static List<selectOption> getObjName(){
        List<selectOption> options = new List<selectOption>();
        
        for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
        {
            Schema.DescribeSObjectResult objResult = o.getDescribe();           
            system.debug( 'Sobject API Name: ' + objResult.getName() +' Sobject Label Name: ' + objResult.getLabel());           
            options.add(new SelectOption(objResult.getName(),objResult.getLabel()));
        }
        return options;
    }
    
    public static List<String> getFieldName(){
        List<String> reqFields = new List<String>();
        /*
			Required Code 
		*/
        return reqFields;
    }
}
I am getting a hard time dealing with schema methods, i have gone through the Salesforce documentation though.
Thanks in advance...


 
I want a list of all Objects in my org and displaying it in a drop down in Visualforce page. The code has compiled but giving unexpected error while getting Preview of VF page.

Controller : 
// Controller
public without sharing class getObjectNamesController {    
    
    public Map<String, Schema.SObjectType> object_Map = Schema.getGlobalDescribe(); 
    public Set<String> objNamesSet = object_Map.keyset();
    
    public List<SelectOption> objNamesList{     
        get{
            Integer i=0;
            for(String myObjName : objNamesSet)
            {
                objNamesList.add(new SelectOption(String.valueOf(i),myObjName)) ; 
                i++;
            } 	    	
            System.debug(objNamesList);   
            return objNamesList ;
        }
        set;
    }
}
VF Page: 
<apex:page controller="getObjectNamesController">
  <apex:form >
      <apex:selectList size="1">
          <apex:selectOptions value="{!objNamesList}"></apex:selectOptions>
      </apex:selectList>
  </apex:form>
</apex:page>
User-added image

 
I've followed step 2 step by step.  There should be two fields on th Battle Station Custom object (Project Status and Weapons Status).  I have only completed step 1, and when I go to verify step 2, it states I don't have the correct field count....
User-added image
HI,
I'm learning Salesforce using FOrce.com Fundamentals Book. I've to use Data Import Wizard to import Records from csv files. My queries -
1. I'm unable to import Hiring Managers (User field) for Positions object though the user record in the csv file exists in the Positions records.
2. I'm unable to import Job Applications using External Id - Email for Candidates. Error that I get for all records is - 
"Id","Success","Created","Error"

"","false","false","INVALID_FIELD:Foreign key external ID: george@schnell.com not found for field First_Name__c in entity Candidate__c:--"

Please guide me.
Thank you in advance,
Kapil.