• kgrasu
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 12
    Replies
Hi everyone!
I have a problem with the challenge, my App work fine but I don´t pass the challenge. This is my code:

campingList.cmp:
 
<aura:component controller="CampingListController">
    
    <ltng:require styles="/resource/SLDS105/assets/styles/salesforce-lightning-design-system-ltng.css"/>

	<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
     <aura:attribute name="newItem" type="Camping_Item__c"
     default="{ 'sobjectType': 'Camping_Item__c',
                    'Price__c': 0,
                    'Quantity__c': 0}"/>
    
    <div class="slds-card slds-p-top--medium">
    <ui:inputText aura:id="campname" label="Camping Name"
        value="{!v.newItem.Name}" required="true"/>
    <ui:inputCheckbox aura:id="packed" label="Packed?"
        value="{!v.newItem.Packed__c}"/>
     <ui:inputCurrency aura:id="price" label="Price"
        value="{!v.newItem.Price__c}" required="true"/>
     <ui:inputNumber aura:id="quantity" label="Quantity"
        value="{!v.newItem.Quantity__c}" required="true"/>
    
    <ui:button label="Create Camping" press="{!c.clickCreateCamping}"/>
    </div>
    
    <aura:attribute name="items" type="Camping_Item__c[]"/>	 
    <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Campings</h3>
        </header>
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="item">
                    <c:campingListItem item="{!item}"/>
                </aura:iteration>
            </div>
        </section>
    </div>
</aura:component>

campingListController.js:
 
({
    
    // Load expenses from Salesforce
	doInit: function(component, event, helper) {

    // Create the action
    var action = component.get("c.getItems");

    // Add callback behavior for when response is received
    action.setCallback(this, function(response) {
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            component.set("v.items", response.getReturnValue());
        }
        else {
            console.log("Failed with state: " + state);
        }
    });

    // Send action off to be executed
    $A.enqueueAction(action);
	},
    
    clickCreateCamping: function(component, event, helper) {
        
        if(helper.validateCampingForm(component)){
	        // Create the new expense
	        var newCamping = component.get("v.newItem");
	        helper.createItem(component, newCamping);
	    }
    }
})
campingListHelper.js
 
({
    
    createItem: function(component, camping) {
        
        var action = component.get("c.saveItem");
        action.setParams({
            "item": camping
        });
    	action.setCallback(this, function(response){
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            var campings = component.get("v.items");
            campings.push(response.getReturnValue());
            component.set("v.items", campings);
        }
    	});
    	$A.enqueueAction(action);
    },
    
    validateCampingForm: function(component) {
      
     	var validQuantity = true;
        var validPrice = true;

        var nameField = component.find("campname");
        var campname = nameField.get("v.value");
        
        var quantityField = component.find("quantity");
        var quantity = quantityField.get("v.value");
        
        var priceField = component.find("price");
        var price = priceField.get("v.value");
        
        if ($A.util.isEmpty(campname) || $A.util.isEmpty(quantity) || $A.util.isEmpty(price)){
            validQuantity = false;
            validPrice = false;
            nameField.set("v.errors", [{message:"Camping name, quantity or price can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
		
		return(validQuantity && validPrice);        
	}
})
CampingListController.apxc:
 
public with sharing class CampingListController {

    @AuraEnabled
    public static List<Camping_Item__c> getItems() {
    
        // Check to make sure all fields are accessible to this user
        String[] fieldsToCheck = new String[] {
            'Id', 'Name', 'Packed__c', 'Price__c', 'Quantity__c'
        };
        
        Map<String,Schema.SObjectField> fieldDescribeTokens = 
            Schema.SObjectType.Camping_Item__c.fields.getMap();
        
        for(String field : fieldsToCheck) {
            if( ! fieldDescribeTokens.get(field).getDescribe().isAccessible()) {
                throw new System.NoAccessException();
                return null;
            }
        }        
        
        // Perform isAccessible() checking first, then
        return [SELECT Id, Name, Packed__c, Price__c, Quantity__c 
                FROM Camping_Item__c];
    }
    
    @AuraEnabled
    public static Camping_Item__c saveItem(Camping_Item__c item) {
        // Perform isUpdatable() checking first, then
        upsert item;
        return item;
    }
}
I am still getting this error:

Challenge Not yet complete... here's what's wrong:
The campingList JavaScript helper isn't saving the new record to the database or adding it to the 'items' value provider.


My App save the new record into the database and add it to the "items" list.
Thanks for your answers!




 
Hi,
 
I have a custom button that executes a javascript code when clicked. It works fine for all user profiles in production, but does not work in sandbox and throws the following error message:
 
[object Error]-sforce.apex is null or not an object
It works in sanbox only for administrator profile.

Appreciate is anyone can help identify the cause for this. This is my js code for the custom button:
 
Javascript Code for the custom button:
{!requireScript("/soap/ajax/11.1/connection.js")}
try{
var userid = '{!User.Id}';
var username='{!User.Name}'; 
var userEmail='{!User.Email}'; 
var apprId='{!Fixture_Order__c.Approver_Name__c}';
var fixOrder='{!Fixture_Order__c.Id }'; 
var vtoemailid='BHN.fixtures@bhnetwork.com';


var args = {puser:userid,pusername:username,puseremail:userEmail,pfixorderno:fixOrder,papprId:apprId,pemailtype:2,ptoEmailid:vtoemailid,pisruntest:false}; 
var result = sforce.apex.execute('HandlerFOSendEmail' , 'sendMail', args);

if(vCardKitsNeeded==1){
var args = {puser:userid,pusername:username,puseremail:userEmail,pfixorderno:fixOrder,papprId:apprId,pemailtype:3,ptoEmailid:vtoemailid,pisruntest:false}; 
var result = sforce.apex.execute('HandlerFOSendEmail' , 'sendMail', args);
}

if(vMerchReq==1){
var args = {puser:userid,pusername:username,puseremail:userEmail,pfixorderno:fixOrder,papprId:apprId,pemailtype:4,ptoEmailid:vtoemailid,pisruntest:false}; 
var result = sforce.apex.execute('HandlerFOSendEmail' , 'sendMail', args);
}

alert("The fixture order has been sent to BHN Fixtures.");

}catch(e)
 {
  alert("Send Email has failed. Please contact your system administrator with this screeshot or error message: "+e + "-" + e.message);
 }

 
Hi
I am trying to override the edit page for "Log a Call" or task with a custom visualforce page. I am having trouble getting some of the fields like
Assigned To,
Related To and
the checkbox "Send Notification Email".
I was able to add other fields uisng the API names.
 
Appreciate if anyone can help with the right way to adding the above fields in VF page.

When I add the following for the Assigned To, it throws the error "Assigned To ID: owner cannot be blank". Basiaclly I want to display the Assigned To field as it appears in the standard Log a Call edit page. Is there some reference available somewhere for converting all these fields in the standard page into a VF page?
 
VF Code:
<apex:page standardController="Task" extensions="conTaskNew">
<apex:form >
       <apex:pageBlock id="mypageblock" title="Task Edit" mode="new">       
     
            <apex:pageBlockButtons >                    
            <apex:commandButton onclick="return lsave()"   action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Task Information" columns="2" id="theSection">  
           <apex:inputField id="vOwner" value="{!task.OwnerId}"/>             
            <apex:inputField id="vActDate" value="{!task.ActivityDate}"/>     
            <apex:inputField id="vsubject" value="{!task.Subject}"/>                
     </apex:pageBlockSection>               
</apex:pageBlock>
</apex:form>
</apex:page>

 Appreciate all your valuable feedbacks.
Hi,
 
I have a very basic question in Visualforce. I need to have a parameter in the VF page, assign a value to it using javascript and then retrieve the parameter values from the controller.
 This is my part VF code:
 
Code:
<apex:page controller="conLeadTab" action="{!validate}">
<apex:pageBlock id="mypageblock" mode="new">
                 <apex:param id="vesg"   name="vesg" value=""/>
     </apex:pageBlock>
<script language="javascript">
var vesgval = 'SOme value';
//The line below does not work, but here I need to assign the value of vesgval to the parameter vesg
//{!$CurrentPage.parameters.vesg}=vesgval;
</script>  
</apex:page> 

 

   
//My controller method 
 
Code:
  public PageReference validate() {
      this.pesgval = System.currentPageReference().getParameters().get('vesg');
      System.debug('this.pesgval--->>>'+this.pesgval);
               if(pesgval==null || pesgval.length()==0){
                    PageReference secondPage1 = new PageReference('/apex/editLeadError');
                        secondPage1.setRedirect(true);
                  return secondPage1; 
                  
                 } else{//do something else, but the execution never comes here as the value of pesgval is always NULL}          
            return null;      
                }

 
The system.debug in the controller for this.pesgval always return null and the value is not fetched from the VF page.

All that I am struggling to achieve here is:
1. Creating a parameter (not query string) in the VF page
2. Assigning a value to it within javascript on pageload
3. Retrieving the parameter value from the controller
 
Appreciate if anyone can give their feedbacks on this or send some sample code for the same.
Thanks and regards,
Rasu
Hello everyone, just wanted to share with the community this custom component I made and give something back for the help I've received. :smileyhappy:

The purpose of the component is to enable autocomplete in lookup fields. I used the autocomplete js created by Jim Roos:
(http://www.jimroos.com/2007/05/ajax-autocomplete.html) but made some modifications to it so that it could interact with an Apex controller among some other things...

So my idea was that if you were making a VF page that had an inputfield that was related to a lookupfield you would just insert this autocomplete component to that inputfield. Something like this:

Code:
           <apex:inputField value="{!Contact.accountid}" id="accname" styleClass="cField">
<c:autocomplete ObjectName="Accounts" InputId="{!$Component.accname}" AutoCompleteId="accACid" ClassName="autocomplete300"/>
</apex:inputField>

The component has 4 parameters:

The name of the object or custom object that the inputfield relates to (new objects must be added inside the apex classes since i had some problems constructing a dynamic query).
The InputId which is used to relate the component to the input field
The id for the Component
A classname parameter that basically just defines the width of the suggestions menu.

Here's a screenshot of how it looks like in action:




Here's a link to the file containing the required files:

AutoCompleteComponent



Jonathan.


Message Edited by jonathan rico on 08-16-2008 01:55 PM

Message Edited by jonathan rico on 08-17-2008 09:04 AM
Message Edited by jonathan rico on 01-02-2010 05:01 PM
Hi,
 
I am trying to deploy a set of Apex Classes and triggers from sandbox to production. Although the apex classes and triggers have >85% test coverage each, when I try to deploy them together using ant , it throws the following exception:
Code:
*** Ending Workflow Evaluation*** Beginning Test 1: AccountScheduler.static testMethod void testAccountScheduler()
System.QueryException: List has no rows for assignment to SObject

Class.AccountScheduler.getLocation: line 84, column 25
Class.AccountScheduler.createNew: line 700, column 19
Trigger.TgrAssignmentDupCheck: line 22, column 24

20080805070410.845:Class.AccountScheduler.testAccountScheduler: line 1113, column 5: Insert failed. First exception on row 0; 
first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, TgrAssignmentDupCheck: execution of BeforeInsert

caused by: System.QueryException: List has no rows for assignment to SObject

Class.AccountScheduler.getLocation: line 84, column 25
Class.AccountScheduler.createNew: line 700, column 19
Trigger.TgrAssignmentDupCheck: line 22, column 24
System.Exception: Assertion Failed

Class.AccountScheduler.testAccountScheduler: line 1114, column 5

*** Ending Test AccountScheduler.static testMethod void testAccountScheduler()


Two of the apex triggers has a dependency on two of the apex classes as it invokes a method from those two classes.

I have successfully deployed the apex classes to production, but I need help to figure out how I can deploy the triggers to production which currently throws the abovesaid error.

Appreciate all your feedback on this.

Thanks and regards,Rasu

Hi,
 
Is there a way to capture the windows login "username" into salesforce.com when user logs in to salesforce?
 
Any feedback is greatly appreciated.
 
Regards
Rasu
Hi, I need to over write the Contact Home page because I don't want some profiles can see the Report and Tools sections. I have created my own Visual Force page but I would like now to over write the Contact home page just for those profiles.

So, Can we over write the client account tab, so that sys admin’s see the standard page, other users see the visualforce page? If so how?

Any help?

Thanks!
Hi,
 
Say Windows returns a Pop-up box with Customer Identifier.
Can we have SalesForce.com do a search on the Customer Identifier automatically?
Our marketing partner uses a dialer to make calls. Leads are fed into this box which makes calls, screening out bad number/faxes etc. before connecting LIVE calls to the Customer Service Rep.
Their existing Customer Information System (CIS) would pop up with the correct customer information on the screen.
Can we do this with SalesForce?
The dailer is AVAYA.
 
Appreciate if anyone could provide some feedback on this.
 
Thanks