• MRITYUNJAY PATEL 3
  • NEWBIE
  • 50 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 3
    Replies
i want to display the image in aura component. i already create a static resouces and upload the file as zip format so what is the tag attribute
i am trying this 

<img  src="{!$Resource.weatherimages +'/weather-64x64-day/'+ v.R_Main.main_img + '.png'}"> </img>

weatherimages : it is is my resource name
weather-64x64-day : this is my zip folder
v.R_Main.main_img + '.png'  : this is image name 

Thanks in advanced

Hi Everyone,
why showing variable not exist. give me solution

//This is my code

global class JsonParseringClass
{
    public static void getJSONData()
    {
        HTTP http = new HTTP();
        HTTPRequest request = new HTTPRequest();
        request.setEndpoint('https://jsonplaceholder.typicode.com/posts');
        request.setMethod('GET');
        HTTPResponse response = http.send(request);
        string res = response.getBody();
        system.debug(response.getStatus());
        List<BlogWrapper> blogObj = ( List<BlogWrapper>)JSON.deserialize(res,  List<BlogWrapper>.class);
       System.debug('Respone- ' + blogObj.id);
        System.debug('Respone- ' + blogObj.userId);
        System.debug('Respone- ' + blogObj.title);
        System.debug('Respone- ' + blogObj.body);
        //return blogObj;
      }
     
    global class BlogWrapper
    {
       public Integer userId { get; set; }
       public Integer id { get; set; }
       public string title { get; set; }
        public string body { get; set; }
    }
}

Thanks in advance
Hi there,
I want to insert the new account record by clicking the toggle. if the user has not an existing account in the dropdown menu. so the new account is not inserted. please solve my problem. 

// .cmp code
<aura:component controller="AuraApex" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="FirstName" type="String"  />
    <aura:attribute name="LastName" type="String"  />
    <aura:attribute name="AccountList" type="List" />
     <aura:attribute name="NewAccount" type="String" />
    <div>
         <lightning:input type="String" label="FirstName" aura:id="firstn" value="{!v.FirstName}" required="true"/>
         <lightning:input type="String" label="LastName" aura:id="lastn" value="{!v.LastName}" required="true" />
         <div>
             <div aura:id="DivIDI" class="remove">
        <lightning:select name="select1" label="List Of Existing Account"  aura:id="AccountId"   required="false" >
            <option value="" label="--None--">
                  </option>
            <aura:iteration items="{!v.AccountList}" var="ac" >
                <option value="{!ac.Id}" label="{!ac.Name}" />
            </aura:iteration>
        </lightning:select>
             </div></div>
        <div>
        <lightning:select name="select2" label="List Of Industry"  aura:id="IndId"   required="false" >
            <option value="" label="--None--">
                  </option>
            <aura:iteration items="{!v.AccountList}" var="in" >
                <option value="{!in.Industry}" label="{!in.Industry}" />
            </aura:iteration>
        </lightning:select>
    </div>
        <br/>
        <br/>
        <div class="slds-form-element">
    <label class="slds-checkbox_toggle slds-grid">
      <span class="slds-form-element__label slds-m-bottom_none">New Account Create</span>
       <ui:inputCheckbox change="{!c.selectChange}"/>
      <span id="toggle-desc" class="slds-checkbox_faux_container" aria-live="assertive">
        <span class="slds-checkbox_faux"></span>
        <span class="slds-checkbox_on">New</span>
        <span class="slds-checkbox_off">Old</span>
      </span>
    </label>
  </div>
<!--PART 2 : create a Div with slds-hide class, control by toggle checkbox-->        
   <div aura:id="DivID" class="slds-hide">
      <lightning:input type="String" label="Account Name" aura:id="AcId" value="{!v.NewAccount}"/>
   </div>
        
        <br/>
        <lightning:button variant="brand" label="Submit" title="Brand action" onclick="{! c.handleClick }" />    
      
    </div>
</aura:component>

//controller.js
({
    doInit : function(component, event, helper) {
        helper.helperMethod(component, event, helper);
    },
    
   
    selectChange : function(component, event, helper) {
        // first get the div element. by using aura:id
      var changeElement = component.find("DivID");
       var changeElement1 = component.find("DivIDI");
       if(changeElement != null)
       // $A.util.removeClass(changeElement, "slds-hide");
        // by using $A.util.toggleClass add-remove slds-hide class
       {
           $A.util.toggleClass(changeElement, "slds-hide");
       }
        else
        {
            $A.util.removeClass(changeElement1, "remove");
        }
      
      },
 
    
    handleClick: function(component, event, helper){
    helper.createContact(component, event, helper);
    helper.createIndustry(component, event, helper);
}
})

//helper.js
({
    helperMethod : function(component, event, helper) {
        var action=component.get("c.getAccount");
        action.setCallback(this,function(response){
            console.log(response.getReturnValue());
            if(response.getReturnValue()!=null){
                component.set("v.AccountList",response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    },
    createContact: function(component, event, helper) {
     var acid=component.find('AccountId').get('v.value');
      var newacc=component.find('AcId').get('v.value');  
     var fname=component.find('firstn').get('v.value');
     var lname=component.find('lastn').get('v.value');
     
        var action=component.get("c.AddContact");
         action.setParams({
             idnew:newacc,
            id1:acid,
            fn:fname,
            ln:lname          
        });
        action.setCallback(this,function(response){
           
            if(response.getReturnValue()!=null){
                console.log("inside callback");
                 console.log(JSON.stringify(response.getReturnValue()));
               var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
        "title": "Success!",
        "type" : 'success',
        "mode" : 'dismissible',
        "duration" : 5000,
        "message": "The record has been created successfully."
    });
                toastEvent.fire();
                
            }
        });
        $A.enqueueAction(action);
          component.set("v.FirstName", ""); 
          component.set("v.LastName", "");
        component.set("v.AccountList", "");
        
    },
    
     createIndustry: function(component, event, helper) {
     var acido=component.find('AccountId').get('v.value');
      var indu=component.find('IndId').get('v.value');
         console.log('AccountId',+acido);
         console.log('Industry',+indu);
        var action=component.get("c.Addind");
         action.setParams({
            ida:acido,
             indus:indu,         
        });
        
        action.setCallback(this,function(response){
           
            if(response.getReturnValue()!=null){
                console.log("inside callback");
                 console.log(JSON.stringify(response.getReturnValue()));
               
            }
        });
        $A.enqueueAction(action);
    }
})

//Apex class
public with sharing class AuraApex {
   @AuraEnabled(cacheable = true)
    public static list<account> getAccount(){
        List<account> AccList = new list<account>();
        AccList = [select Id,Name,Industry from Account limit 100];
        system.debug('ac'+Acclist);
        return AccList;
    }
    
    @auraenabled
    public static contact AddContact(id id1,string indus, string fn,string ln,string idnew){
        
        contact c =new contact();
        if(id1 != null)
        {
        c.AccountId = id1;
        c.FirstName = fn;
        c.LastName = ln;

        }
        else 
        {
        Account n=new Account();
        n.Name =idnew;
        insert n;
        c.AccountId = idnew;
        c.FirstName = fn;
        c.LastName = ln;   
        }
        insert c;
        return c;
    }
    
    @auraenabled
    public static Account Addind(id ida,string indus){
        
        Account a=new Account();
        a.id=ida;
        a.Industry=indus;
        insert a;
        return a;
    }
}

Thanks in advance
 
Hi Everyone,
i m trying to clear the input field value after clicking the clear button in my code.

 //This is my code aura code
<aura:component controller="AuraApex" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="FirstName" type="String"  />
    <aura:attribute name="LastName" type="String"  />
    <aura:attribute name="AccountList" type="List" />
     <aura:attribute name="NewAccount" type="String" />
    <div>
         <lightning:input type="String" label="FirstName" aura:id="firstn" value="{!v.FirstName}" required="true"/>
         <lightning:input type="String" label="LastName" aura:id="lastn" value="{!v.LastName}" required="true" />
         <div>
        <lightning:select name="select1" label="List Of Existing Account"  aura:id="AccountId"   required="false" >
            <option value="" label="--None--">
                  </option>
            <aura:iteration items="{!v.AccountList}" var="ac" >
                <option value="{!ac.Id}" label="{!ac.Name}" />
            </aura:iteration>
        </lightning:select>
    </div>
        <div>
        <lightning:select name="select2" label="List Of Industry"  aura:id="IndId"   required="false" >
            <option value="" label="--None--">
                  </option>
            <aura:iteration items="{!v.AccountList}" var="in" >
                <option value="{!in.Id}" label="{!in.Industry}" />
            </aura:iteration>
        </lightning:select>
    </div>
        <br/>
        <br/>
        <div class="slds-form-element">
    <label class="slds-checkbox_toggle slds-grid">
      <span class="slds-form-element__label slds-m-bottom_none">New Account Create</span>
       <ui:inputCheckbox change="{!c.selectChange}"/>
      <span id="toggle-desc" class="slds-checkbox_faux_container" aria-live="assertive">
        <span class="slds-checkbox_faux"></span>
        <span class="slds-checkbox_on">New</span>
        <span class="slds-checkbox_off">Old</span>
      </span>
    </label>
  </div>
<!--PART 2 : create a Div with slds-hide class, control by toggle checkbox-->        
   <div aura:id="DivID" class="slds-hide">
      <lightning:input type="String" label="Account Name" aura:id="AccountId" value="{!v.NewAccount}"/>
   </div>
        
        <br/>
        <lightning:button variant="brand" label="Submit" title="Brand action" onclick="{! c.handleClick }" />    
        <lightning:button variant="brand" label="clear" title="Brand action" onclick="{! c.clear }" />  
    </div>
</aura:component>

 
Hi Everyone,
i am trying to create form of contact with display the exitsting account in dropdown menu and after select create a new contact with exitsting account name.
 
Hello there,
Please solve my problem, first time i am trying to ask question .

this is my component code:
<select aura:id="AccList" class="slds-select" >
            <option>All</option>
            <aura:iteration items="{!v.Accounts}" var="category" indexVar="index" >
                <option>{!category.Name}</option>
            </aura:iteration>
        </select>

Controller.js
    var selectedValue=  component.find("AccList").get("v.Value");
    alert("selectedValue:"+selectedValue);

Advance Thanks
   
i want to display the image in aura component. i already create a static resouces and upload the file as zip format so what is the tag attribute
i am trying this 

<img  src="{!$Resource.weatherimages +'/weather-64x64-day/'+ v.R_Main.main_img + '.png'}"> </img>

weatherimages : it is is my resource name
weather-64x64-day : this is my zip folder
v.R_Main.main_img + '.png'  : this is image name 

Thanks in advanced
Hi there,
I want to insert the new account record by clicking the toggle. if the user has not an existing account in the dropdown menu. so the new account is not inserted. please solve my problem. 

// .cmp code
<aura:component controller="AuraApex" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="FirstName" type="String"  />
    <aura:attribute name="LastName" type="String"  />
    <aura:attribute name="AccountList" type="List" />
     <aura:attribute name="NewAccount" type="String" />
    <div>
         <lightning:input type="String" label="FirstName" aura:id="firstn" value="{!v.FirstName}" required="true"/>
         <lightning:input type="String" label="LastName" aura:id="lastn" value="{!v.LastName}" required="true" />
         <div>
             <div aura:id="DivIDI" class="remove">
        <lightning:select name="select1" label="List Of Existing Account"  aura:id="AccountId"   required="false" >
            <option value="" label="--None--">
                  </option>
            <aura:iteration items="{!v.AccountList}" var="ac" >
                <option value="{!ac.Id}" label="{!ac.Name}" />
            </aura:iteration>
        </lightning:select>
             </div></div>
        <div>
        <lightning:select name="select2" label="List Of Industry"  aura:id="IndId"   required="false" >
            <option value="" label="--None--">
                  </option>
            <aura:iteration items="{!v.AccountList}" var="in" >
                <option value="{!in.Industry}" label="{!in.Industry}" />
            </aura:iteration>
        </lightning:select>
    </div>
        <br/>
        <br/>
        <div class="slds-form-element">
    <label class="slds-checkbox_toggle slds-grid">
      <span class="slds-form-element__label slds-m-bottom_none">New Account Create</span>
       <ui:inputCheckbox change="{!c.selectChange}"/>
      <span id="toggle-desc" class="slds-checkbox_faux_container" aria-live="assertive">
        <span class="slds-checkbox_faux"></span>
        <span class="slds-checkbox_on">New</span>
        <span class="slds-checkbox_off">Old</span>
      </span>
    </label>
  </div>
<!--PART 2 : create a Div with slds-hide class, control by toggle checkbox-->        
   <div aura:id="DivID" class="slds-hide">
      <lightning:input type="String" label="Account Name" aura:id="AcId" value="{!v.NewAccount}"/>
   </div>
        
        <br/>
        <lightning:button variant="brand" label="Submit" title="Brand action" onclick="{! c.handleClick }" />    
      
    </div>
</aura:component>

//controller.js
({
    doInit : function(component, event, helper) {
        helper.helperMethod(component, event, helper);
    },
    
   
    selectChange : function(component, event, helper) {
        // first get the div element. by using aura:id
      var changeElement = component.find("DivID");
       var changeElement1 = component.find("DivIDI");
       if(changeElement != null)
       // $A.util.removeClass(changeElement, "slds-hide");
        // by using $A.util.toggleClass add-remove slds-hide class
       {
           $A.util.toggleClass(changeElement, "slds-hide");
       }
        else
        {
            $A.util.removeClass(changeElement1, "remove");
        }
      
      },
 
    
    handleClick: function(component, event, helper){
    helper.createContact(component, event, helper);
    helper.createIndustry(component, event, helper);
}
})

//helper.js
({
    helperMethod : function(component, event, helper) {
        var action=component.get("c.getAccount");
        action.setCallback(this,function(response){
            console.log(response.getReturnValue());
            if(response.getReturnValue()!=null){
                component.set("v.AccountList",response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    },
    createContact: function(component, event, helper) {
     var acid=component.find('AccountId').get('v.value');
      var newacc=component.find('AcId').get('v.value');  
     var fname=component.find('firstn').get('v.value');
     var lname=component.find('lastn').get('v.value');
     
        var action=component.get("c.AddContact");
         action.setParams({
             idnew:newacc,
            id1:acid,
            fn:fname,
            ln:lname          
        });
        action.setCallback(this,function(response){
           
            if(response.getReturnValue()!=null){
                console.log("inside callback");
                 console.log(JSON.stringify(response.getReturnValue()));
               var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
        "title": "Success!",
        "type" : 'success',
        "mode" : 'dismissible',
        "duration" : 5000,
        "message": "The record has been created successfully."
    });
                toastEvent.fire();
                
            }
        });
        $A.enqueueAction(action);
          component.set("v.FirstName", ""); 
          component.set("v.LastName", "");
        component.set("v.AccountList", "");
        
    },
    
     createIndustry: function(component, event, helper) {
     var acido=component.find('AccountId').get('v.value');
      var indu=component.find('IndId').get('v.value');
         console.log('AccountId',+acido);
         console.log('Industry',+indu);
        var action=component.get("c.Addind");
         action.setParams({
            ida:acido,
             indus:indu,         
        });
        
        action.setCallback(this,function(response){
           
            if(response.getReturnValue()!=null){
                console.log("inside callback");
                 console.log(JSON.stringify(response.getReturnValue()));
               
            }
        });
        $A.enqueueAction(action);
    }
})

//Apex class
public with sharing class AuraApex {
   @AuraEnabled(cacheable = true)
    public static list<account> getAccount(){
        List<account> AccList = new list<account>();
        AccList = [select Id,Name,Industry from Account limit 100];
        system.debug('ac'+Acclist);
        return AccList;
    }
    
    @auraenabled
    public static contact AddContact(id id1,string indus, string fn,string ln,string idnew){
        
        contact c =new contact();
        if(id1 != null)
        {
        c.AccountId = id1;
        c.FirstName = fn;
        c.LastName = ln;

        }
        else 
        {
        Account n=new Account();
        n.Name =idnew;
        insert n;
        c.AccountId = idnew;
        c.FirstName = fn;
        c.LastName = ln;   
        }
        insert c;
        return c;
    }
    
    @auraenabled
    public static Account Addind(id ida,string indus){
        
        Account a=new Account();
        a.id=ida;
        a.Industry=indus;
        insert a;
        return a;
    }
}

Thanks in advance