0

component -

> <aura:component controller="ContactListController">
>     <aura:attribute name="accountId" type="String"/>  <aura:attribute name="CreateCon" Type="Contact"  default= "{
>                                                                sobjectName : 'Conatct',
>                                                                FirstName : '',
>                                                                LastName : '',
>                                                                Email : '',
>                                                                Phone : ''
>                       }"/>
> 
>     <div class="slds-p-around_medium">
>         <lightning:input type= "text" value="{!v.CreateCon.FirstName}" label="First Name" required ="true"/>
>         <br></br>
>         
>         <lightning:input type= "text" value="{!v.CreateCon.LastName}" label="Last Name" required ="true"/>
>         <br></br>
>          <lightning:input type= "phone" value="{!v.CreateCon.Phone}" label="Phone" required ="true"/>
>         <br></br>
>         <lightning:input type= "email" value="{!v.CreateCon.Email}" label="Email" required ="true" />
>         <br></br>
>         <lightning:button  label ="Create Contact" variant="Brand" onclick ="{!c.doSave}"/>
>     </div> </aura:component

Blockquote

Controller -

> ({    doSave : function(component, event, helper) {       var action =
> component.get('c.createContact');
>         action.setParams({
>             con: component.get('v.CreateCon'),
>             AccountId : component.get('v.accountId')
>         });
>         action.setCallback(this, function(response) {
>                      var state = response.getState();   
>             alert(state);
>             if (State === 'SUCCESS' || state ==='DRAFT'){
>                 var responseValue = response.getReturnValue();
>             }else if(state === 'INCOMPLETE'){
>                 
>             }else if(state ==='ERROR')
>                 
>             {
>                    var errors = response.getError();
>                 console.log('Error', errors)
>                 if(errors || errors[0].message){
>                     
>                 }
>             }   },'ALL');
>         $A.enqueueAction(action);
>           } })

1 Answer 1

0

You need to pay attention in JavaScript, as it is cAsE-sEnSiTiVe. You wrote State but should have written state.

if (state === 'SUCCESS'){

P.S. "DRAFT" is no longer used, you don't need it in modern code.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .