• SAHANA GHOSH
  • NEWBIE
  • 15 Points
  • Member since 2014
  • Cognizant Technology Solutions

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
Lightning Component  - 
<aura:component implements="flexipage:availableForAllPageTypes, force:hasRecordId" access="global" controller="addBooks">
    <aura:attribute name="bookToAdd" type="Books__c" />
    <aura:attribute name="authId" type="String" />
    
    <div class="Styling">
        <lightning:card title="Quick register Books">
            
            <lightning:input label = "Book Name : " value="{!v.bookToAdd.Name}" required="true" />
            <lightning:input label = "Book Price : " value="{!v.bookToAdd.Price__c}" required="true" />
            <lightning:button variant="brand" label="Add books" title="Add books" onclick="{! c.addBooks }"/>
        </lightning:card>
    </div>
</aura:component>

JS - 
({
    addBooks : function(component, event, helper) {
        var action = component.get('c.addbooks');
        component.set('v.authId',v.recordId);
        console.log('v.recordId***',v.recordId);
        action.setParams({
            b : component.get('v.bookToAdd'),
            authId : component.get('v.authId')
        });
        action.setCallback(this, function(response){
            
        },'ALL');
        $A.enqueueAction(action);
    }
})

Controller - 
public class addBooks {
    @AuraEnabled
    public static void addbooks(Books__c b, Id authId){
        if((b.Name != NULL ||b.Name !='') && (b.Price__c >0)){
            b.Author__c=authId;
            insert b;
        }
    }
}

I get the following error when I try to enter input -

Error
Here goes my Lightning component - 

<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="cboard_seeContacts">
    <aura:attribute name="accId" type="String" />
    <aura:attribute name="Con" type="Contact" 
                    default="{sObjectname: 'Contact',
                    FirstName:'Roza',
                    LastName:'Stalin',
                    Phone:'8981103780',
                    Email:'rozaStalin@cboard.com'}"/>
    <div class="slds-p-around_medium">
        <lightning:input name="First Name" type="text" label = "First Name" value="{!v.con.FirstName}"/>
        <lightning:input name="Last Name" type="text" label = "Last Name" value="{!v.con.LastName}"/>
        <lightning:input name="Phone" type="phone" label = "Phone" value="{!v.con.Phone}"/>
        <lightning:input name="Email" type="email" label = "Email" value="{!v.con.Email}"/><br/><br/>
        <lightning:button label="Quick Create Contact" variant="Brand" onclick="{!c.doSave}"/>
    </div>
</aura:component>

Controller - 

public class cboard_seeContacts {
    
    @AuraEnabled
    public static List<Contact> ContactList(string accId){
        return [Select Id, FirstName,LastName from Contact where AccountId =:accId];
    }
    
    @AuraEnabled
    public static Contact createContact(Contact c, Id AccountId){
        c.AccountId=AccountId;
        insert c;
        return c;
    }
}

JS-  
({
    doSave : function(component, event, helper) {
        var action = component.get('c.createContact');
        action.setParam({
            c : component.get('v.Con'),
            AccountId : component.get('v.accId')
        });
        action.setCallBack(this, function(response){
            var state= response.getState();
            if(state === 'SUCCESS' || state ==='DRAFT'){
                var reposneValue = response.getReturnvalue();
            }
        },'ALL');
        $A.enqueueAction(action);
    }
})


I am unable to figure out why the inputs and button is not working. Any help will be appreciated. 
 
Unable to edit/preview VF pages and apex classes. This error is appearing - An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 648673073-170378 (-617778647)
Here goes my Lightning component - 

<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="cboard_seeContacts">
    <aura:attribute name="accId" type="String" />
    <aura:attribute name="Con" type="Contact" 
                    default="{sObjectname: 'Contact',
                    FirstName:'Roza',
                    LastName:'Stalin',
                    Phone:'8981103780',
                    Email:'rozaStalin@cboard.com'}"/>
    <div class="slds-p-around_medium">
        <lightning:input name="First Name" type="text" label = "First Name" value="{!v.con.FirstName}"/>
        <lightning:input name="Last Name" type="text" label = "Last Name" value="{!v.con.LastName}"/>
        <lightning:input name="Phone" type="phone" label = "Phone" value="{!v.con.Phone}"/>
        <lightning:input name="Email" type="email" label = "Email" value="{!v.con.Email}"/><br/><br/>
        <lightning:button label="Quick Create Contact" variant="Brand" onclick="{!c.doSave}"/>
    </div>
</aura:component>

Controller - 

public class cboard_seeContacts {
    
    @AuraEnabled
    public static List<Contact> ContactList(string accId){
        return [Select Id, FirstName,LastName from Contact where AccountId =:accId];
    }
    
    @AuraEnabled
    public static Contact createContact(Contact c, Id AccountId){
        c.AccountId=AccountId;
        insert c;
        return c;
    }
}

JS-  
({
    doSave : function(component, event, helper) {
        var action = component.get('c.createContact');
        action.setParam({
            c : component.get('v.Con'),
            AccountId : component.get('v.accId')
        });
        action.setCallBack(this, function(response){
            var state= response.getState();
            if(state === 'SUCCESS' || state ==='DRAFT'){
                var reposneValue = response.getReturnvalue();
            }
        },'ALL');
        $A.enqueueAction(action);
    }
})


I am unable to figure out why the inputs and button is not working. Any help will be appreciated. 
 
Unable to edit/preview VF pages and apex classes. This error is appearing - An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 648673073-170378 (-617778647)