• Akash Choudhary 17
  • NEWBIE
  • 75 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 20
    Replies
Hi All ,

I have a requirement wherein I have to update the fields of a custom object Car__C to 'NOT ASSIGNED'. There are 80 fields on the object and it is not necessary that all the fileds will be having value while saving the record so all the fields which are of type text, long text Area and picklist having null values should be updated to Not assigned. I have to do it through apex class. Any help will be appreciated.

Thanks
Hi All,

while updating a particular field of an object for a single record by mistake I updated that field for all the records present for that object. I want my field to have old values restored. there is no history tracking for that object. can we do it through trigger or class. 
kindly help its urgent.

Thanks
 
Hello All,

I have a input form for a custom object Employee with three fields name, designation, phone .
on click of save button only name is getting saved, rest phone and designation fields are empty. 
Here is my code-

HTMl
<template>
    <lightning-card title= "Insert Employee Data" icon-name="standard:account">
        <div class="slds-p-around_x-small">
            <lightning-input label="Employee Name" value={rec.Name} onchange={handleNameChange}></lightning-input>
            <lightning-input label="Designation" value={rec.Designation__c} onchange={handleDesChange}></lightning-input>
            <lightning-input label="Phone" value={rec.Primary_Phone__c} onchange={handlePhnChange}></lightning-input><br/>
            <lightning-button label="Save" onclick={handleClick}></lightning-button>
   
        </div>
    </lightning-card>
</template>

JS
import { LightningElement, track } from 'lwc';
import NAME_FIELD from '@salesforce/schema/Employee__c.Name';
import DESIGNATION_FIELD from '@salesforce/schema/Employee__c.Designation__c';
import PHONE_FIELD from '@salesforce/schema/Employee__c.Primary_Phone__c';
import createEmployee from '@salesforce/apex/createEmployee.createEmployee';

import { ShowToastEvent } from 'lightning/platformShowToastEvent';

export default class InputFormForCustomObject extends LightningElement {

    @track name = NAME_FIELD;
    @track designation = DESIGNATION_FIELD;
    @track phone = PHONE_FIELD;
    rec = {
        Name : this.name,
        Designation : this.Designation__c,
        Phone : this.Primary_Phone__c
    }

    handleNameChange(event) {
        this.rec.Name = event.target.value;
        console.log("name1", this.rec.Name);
    }
    
    handleDesChange(event) {
        this.rec.Designation = event.target.value;
        console.log("Designation", this.rec.Designation);
    }
    
    handlePhnChange(event) {
        this.rec.Phone = event.target.value;
        console.log("Phone", this.rec.Phone);
    }

    handleClick() {
        createEmployee({ hs : this.rec })
            .then(result => {
                this.message = result;
                this.error = undefined;
                if(this.message !== undefined) {
                    this.rec.Name = '';
                    this.rec.Designation = '';
                    this.rec.Phone = '';
                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Success',
                            message: 'Employee created',
                            variant: 'success',
                        }),
                    );
                }
                
                console.log(JSON.stringify(result));
                console.log("result", this.message);
            })
            .catch(error => {
                this.message = undefined;
                this.error = error;
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error creating record',
                        message: error.body.message,
                        variant: 'error',
                    }),
                );
                console.log("error", JSON.stringify(this.error));
            });
    }
}

Meta Xml
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
   <apiVersion>45.0</apiVersion>
   <isExposed>true</isExposed>
   <targets>
       <target>lightning__AppPage</target>
       <target>lightning__RecordPage</target>
       <target>lightning__HomePage</target>
   </targets>
</LightningComponentBundle>

Apex
public with sharing class createEmployee {
     @AuraEnabled
    public static Employee__c createEmployee(Employee__c hs) {
        
        insert hs;
        return hs;
    }
}

​​​​​​​​​​​​​​
Hi All,

How can we make the id field in the LWC data table hyperlinked so that it can navigate to the record. 

lightningDataTable.html
<template>
<lightning-card title = "Search Employees" icon-name = "custom:custom10"> 
<div class = "slds-m-around_medium">
           <!----> <lightning-input type="search" onchange={findEmployeeResult} class = "slds-m-bottom_small" label = "Search"> </lightning-input>
            <lightning-datatable key-field="Id" data={employeeList} columns={columnList} hide-checkbox-column="true" show-row-number-column="true">

            </lightning-datatable> <template if:true= {noRecordsFound}>

                --No Employee Records Found--

            </template> </div>
   </lightning-card>
</template>

lightningDataTable.js
import { LightningElement, track } from 'lwc';

import searchEmployees from '@salesforce/apex/EmployeeController.searchEmployee';

 

const columnList = [

    {label: 'Id', fieldName: 'Id'},

    {label: 'Name', fieldName: 'Name'},

    {label: 'Designation', fieldName: 'Designation__c'},

    {label: 'Address', fieldName: 'Address__c'},

    {label: 'DOB', fieldName: 'Date_Of_Birth__c'},

    {label: 'Email', fieldName: 'Email_Id__c'},

    {label: 'Phone', fieldName: 'Primary_Phone__c'}

];

 

export default class LightningDataTable extends LightningElement {

    @track employeeList;

    @track columnList = columnList;

    @track noRecordsFound = true;

 

    findEmployeeResult(event) {

        const empName = event.target.value;

 

        if(empName) {

            searchEmployees ( {empName})

            .then(result => {

                this.employeeList = result;

                this.noRecordsFound = false;

            })

        } else {

            this.employeeList = undefined;

            this.noRecordsFound = true;

        }

    }

 

}

lightningDataTable.js-meta.xml
<?xml version="1.0" encoding="UTF-8"?>

<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lightningDataTable">

    <apiVersion>46.0</apiVersion>

    <isExposed>true</isExposed>

    <targets>

        <target>lightning__AppPage</target>

        <target>lightning__RecordPage</target>

        <target>lightning__HomePage</target>

    </targets>

</LightningComponentBundle>

Apex Class
public with sharing class EmployeeController {
        @AuraEnabled (cacheable = true)

    public static List<Employee__c> searchEmployee(String empName) {

        string strEmpName = '%'+ empName + '%';

        return [Select Id, Name, Designation__c, Address__c, Date_Of_Birth__c, Email_Id__c, Primary_Phone__c from Employee__c WHERE Name LIKE: strEmpName];

    }
}

 
Hi All,
 I have a requirement wherein I have to do this -
Create a Custom student Object and Create  student form in LWC to capture the data. Once submitted shows the data in Lightning datatable
Hello Everyone,

I have a requirement wherein I need to make a Opportunity record read only when the opportunity stage reaches to Closed won or either Closed Lost.
Any help is much appreciated.

Thanks
Hi All,

I have a lightning component on a stanalone app which is a input form for creating a new record. But somehow it is not saving the record as expected.

component:
<aura:component controller="CreateCarRecord" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="newCar" type="Car__c"
     default="{ 'sobjectType': 'Car__c',
                     'Name': '',
                     'Build_Year__c': '',
                     'Mileage__c': '',
                      'Available_For_Rent__c': '',
                   }"/>

    
    
        <lightning:layout>
            <lightning:layoutItem size="4" padding="around-small">
              <lightning:input aura:id="carField" type="text" value="{!v.newCar.Name}" Name="Name" label ="Car Name"/>
       <lightning:input aura:id="carField" type="number" name="Build Year" label="Build Year"  value="{!v.newCar.Build_Year__c}" />
                 <lightning:input aura:id="carField" type="number"  value="{!v.newCar.Mileage__c}"  Name="Mileage" label="Mileage"/>
        <lightning:input aura:id="carField" type="checkbox"  value="{!v.newCar.Available_For_Rent__c}"  Name="Available" label="Available"/>
        
        <lightning:button aura:id="carField" label="Save Car" onclick="{!c.saveCar}"/>
            </lightning:layoutItem>
            </lightning:layout>
</aura:component>

controller:
({
	saveCar :  function(component, event) {
    var newAcc = component.get("v.newCar");
    var action = component.get("c.save");
    action.setParams({ 
        "con": newAcc
    });
    action.setCallback(this, function(a) {
           var state = a.getState();
        console.log("state--" +state);
            if (state === "SUCCESS") {
                var name = a.getReturnValue();
               alert("hello from here"+name);
            }else{
                alert("nothing");
            }
        });
    $A.enqueueAction(action)
}
})

Apex:
public class CreateCarRecord {

  
    @AuraEnabled
    public static Car__c save(Car__c con)
    {
     insert con;
        return con;
    }
}

​​​​​​​​​​​​​​
Hi All ,
I have a requirement wherein I have to show the weather forecasts of the contact's records with respect to their mailing address field.

Here is the flow of my component:
1. There is a search bar wherein you can search the account you want to see.
2. Based on the searched alphabets account list opens with radio buttons to the side.
3. when you select the radio button all the contacts associated to it open up  with radio buttons along side.
 Main Requirement:
4.  when a Contact radio button is selected a weather component should opne up with weather forecast related to the mailing address of that particular contact record.
Here is my current component 

Apex class
public class RadioAccRelatedConC {

    @AuraEnabled
    public static List<Account> getAccounts(string searchKeyWord) {
        String searchKey = searchKeyWord + '%';
        List<Account> returnList =new List<Account>();
        List < Account > lstOfAccount = [select id, Name, Industry,Type, Phone, Fax from account
                                   where Name LIKE: searchKey LIMIT 500];
         for (Account acc: lstOfAccount) {
           returnList.add(acc);
  }
  return returnList;
    }
    
    @AuraEnabled
    public static List<Contact> getCon(List<String> accId) {
        return [SELECT Id, Name, Phone,MailingAddress FROM Contact WHERE AccountId=:accId];
    }
}

Component
<aura:component controller="RadioAccRelatedConC"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    <!-- attributes -->
    <aura:attribute name="data" type="Object"/>
    <aura:attribute name="columns" type="List"/>
    <aura:attribute name="data1" type="Object"/>
    <aura:attribute name="columns1" type="List"/>
    <aura:attribute name="selectedRowsCount" type="Integer" default="0"/>
    <aura:attribute name="maxRowSelection" type="Integer" default="5"/>
    <aura:attribute name="isButtonDisabled" type="Boolean" default="true" access="PRIVATE"/>
    <aura:attribute name="searchResult" type="List" description="use for store and display account list return from server"/>
    <aura:attribute name="searchKeyword" type="String" description="use for store user search input"/>
    <aura:attribute name="Message" type="boolean" default="false" description="use for display no record found message"/>
    <aura:attribute name="TotalNumberOfRecord" type="integer" default="0" description="use for display Number of records"/>
   <!-- SHOW LOADING SPINNER--> 
    <lightning:spinner variant="brand" size="large" aura:id="Id_spinner" class="slds-hide" />
    
   <!-- <div class="slds-m-around_medium"> -->
       <!-- SEARCH INPUT AND SEARCH BUTTON--> 
        <lightning:layout horizontalAlign="center">
            <lightning:layoutItem size="3" >
                <lightning:input value="{!v.searchKeyword}"
                                 required="true"
                                 placeholder="search Accounts.."
                                 aura:id="searchField"
                                 label="Account Name"/>
            </lightning:layoutItem>
       
        <lightning:layoutItem size="2" padding="around-large">
               <lightning:button onclick="{!c.Search}"
                                  variant="brand"
                                  label="Search"
                                       iconName="utility:search"/>
            
         </lightning:layoutItem>
           
        </lightning:layout>
       
        <!-- TOTAL RECORDS BADGES--> 
        <div class="slds-m-around_x-small">
            <lightning:badge label="{!v.TotalNumberOfRecord}" />
        </div>
        <!--aura:iteration items="{!v.searchResult}"  var="item">
    
           "{!item.Name}" - "{!item.Type}"
    </aura:iteration-->
        <!-- ERROR MESSAGE IF NOT RECORDS FOUND--> 
        <aura:if isTrue="{!v.Message}">
            <div class="slds-notify_container slds-is-relative">
                <div class="slds-notify slds-notify_toast slds-theme_error" role="alert">
                    <div class="slds-notify__content">
                        <h2 class="slds-text-heading_small">No Records Found...</h2>
                    </div>
                </div>
            </div>
        </aura:if>
    
    
    
    
    
    
    
    <!-- handlers-->
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    
    <!-- the container element determine the height of the datatable -->
    <div style="height: 300px">
        <lightning:datatable
                             columns="{!v.columns }"
                             data="{!v.data }"
                             keyField="id"
                             maxRowSelection="{! v.maxRowSelection }"
                             onrowselection="{! c.updateSelectedText }"/>
    </div>
    
    <br/><br/>
    
    <div style="height: 300px">
        <lightning:datatable
                             columns="{! v.columns1 }"
                             data="{! v.data1 }"
                             keyField="id"
                             maxRowSelection="{! v.maxRowSelection }"
                             onrowselection="{! c.updateSelectedText1 }"                             
                             />
    </div>
    
</aura:component>

Controller
({
    
     Search: function(component, event, helper) {
        var searchField = component.find('searchField');
        var isValueMissing = searchField.get('v.validity').valueMissing;
        // if value is missing show error message and focus on field
        if(isValueMissing) {
            searchField.showHelpMessageIfInvalid();
            searchField.focus();
        }else{
          // else call helper function 
            helper.SearchHelper(component, event);
        }
    },

    
    init: function (component, event, helper) {
        component.set('v.columns', [
            {label: 'Account Name', fieldName: 'Name', editable: false, type: 'text'},
            {label: 'Phone', fieldName: 'Phone', type: 'phone'}
        ]);
        
        component.set('v.columns1', [
            {label: 'Contact Name', fieldName: 'Name', editable: false, type: 'text'},
            {label: 'Phone', fieldName: 'Phone', type: 'phone'},
            {label: 'Address', fieldName: 'MailingAddress', type: 'Address'}

        ]);
        
        var action=component.get('c.getAccounts');
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var rows = response.getReturnValue();
                component.set("v.data", rows);
            }
        });
        $A.enqueueAction(action);    
        
        component.set('v.maxRowSelection', 1);
        component.set('v.isButtonDisabled', true);
    },
    
    updateSelectedText: function (cmp, event) {
        
        var selectedRows = event.getParam('selectedRows');
        var aId;
        aId = selectedRows[0].Id;

        
        var action=cmp.get('c.getCon');
        action.setParams({accId : aId});
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                var rows1 = response.getReturnValue();
                console.log('rows1 ->> ' + rows1);
                cmp.set("v.data1", rows1);
            }
        });
        $A.enqueueAction(action);    
    },
    updateSelectedText1: function (cmp, event) {
        
        var selectedRows = event.getParam('selectedRows');
        var aId;
        aId = selectedRows[0].Id;
        alert('contact id: '+aId);  
    },    
    
})

Helper
({
    SearchHelper: function(component, event) {
        // show spinner message
         component.find("Id_spinner").set("v.class" , 'slds-show');
        var action = component.get("c.getAccounts");
        action.setParams({
            'searchKeyWord': component.get("v.searchKeyword")
        });
        action.setCallback(this, function(response) {
           // hide spinner when response coming from server 
            component.find("Id_spinner").set("v.class" , 'slds-hide');
            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();
                
                // if storeResponse size is 0 ,display no record found message on screen.
                if (storeResponse.length == 0) {
                    component.set("v.Message", true);
                } else {
                    component.set("v.Message", false);
                }
                
                // set numberOfRecord attribute value with length of return value from server
                component.set("v.TotalNumberOfRecord", storeResponse.length);
                
                // set searchResult list with return value from server.
                //component.set("v.searchResult", storeResponse); 
                component.set("v.data", storeResponse); 
                //console.log('dddjjd '+JSON.stringify(component.get("v.searchResult")));
                
            }else if (state === "INCOMPLETE") {
                alert('Response is Incompleted');
            }else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        alert("Error message: " + 
                                    errors[0].message);
                    }
                } else {
                    alert("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);
    },
})

​​​​​​​
Add radio button to the account list in a lightning component and on selecting that particular radio button on account list it should open the related contacts to it. How to achieve this requirement
Hi All,

I have a scenario where I need to create a VF page with these details:
whenever a parent record from (Auctions__c) object is selected, automaically option for creating a child record in 
(SellerAuctionItem__c) object opens up in which Auction field(read only) (master detial relationship) is autopopulated with the parent record selected. And rest can be filled and saved
Hi All,

I am attemption to update a field of a child object of a master detail .

Here is the code:

public class SubmitApproval {

public static void createAccountManager(List<SellerAuctionItem__c> triggerNewList){
      
        List<string> AuctionSet = new List<String>();
        for (SellerAuctionItem__c item : triggerNewList) {
            if(item.Auction__c != null){
                AuctionSet.add(item.Auction__r.Name);
                system.debug('Name' +AuctionSet);
            }
        }
        
        Map<String, Auctions__c> mapAuction = new Map<String,Auctions__c>([Select Name , Account_Manager__c From Auctions__c  WHERE Name IN:AuctionSet ]);
        system.debug('Name and account manager' +mapAuction);
        for (SellerAuctionItem__c item : triggerNewList) {
            if(item.Account_Manager__c == Null){
            item.Account_Manager__c = mapAuction.get(item.Auction__c).Account_Manager__c;
            }    }

    }   
}

It is giving null pointer error : Attempt to de-reference a null object

Please help, Thanks
 
Hi All,

I am developing a website for aution on force.com and for that I  need a VF page. Which will be the homepage
Requirements:
1. This login  page should be divided in to two parts first for Sellers and second for Bidders
2. If they are new to the site there should be an option for Register as Seller or Register as Bidder
3. So when the people will click on it, they will be redirected to a new page, for which i already have a VF page for both Seller and Bidder
4. If already a member there has to be a process of authentication also. 
Basically normal fundamentals of a login page
Hi all ,

This is my code , I want to update Contact's description everytime I update opportunity's description.
This is not working somehow . please help me figure out my mistake

public class DESC_UpdateForum {
    public static void DESC_UpdateForumMethod (list<Opportunity> Opplist){
        
        Set<Id> idSet = new set<Id>();
        For(Opportunity Opp : Opplist){
            if(Opp.AccountId != null){
                idset.add(Opp.AccountId);
            }
        }
        List <Contact> con = [SELECT Id,
                                     AccountId,
                                     Description
                              From Contact
                              Where AccountId IN :idSet];
        Map<Id , String> Oppmap =  new Map<Id, String>();
            For(Opportunity Opp : Opplist){
                If(Opp.Account != null){
                    Oppmap.put(Opp.AccountId , Opp.Description);
                }
            }
        if(con.size()>0){
            For(Contact c :con){
                If(c.AccountId != null){
             c.Description = Oppmap.get(c.AccountId);
                }}
        }
        Update con;
    }}

Thanks
Hi All, 

I need to bulkify this code please help.

public class Move_Contact {
    public static void updateContact(List <Contact> conList){
        Map <Id,Id> conMap = new Map <Id,Id>();
        
        for(Contact myCon : conList){
            if(myCon.Email != null){
                string domain = myCon.Email.split('@').get(1);
               
                String MainDomain = domain;
                string website ='www.' +MainDomain;
                string httpWebsite ='http://www.' + MainDomain;
                string httpswebsite ='https://www.'+ MainDomain;
                string international = MainDomain + '.%';
                
                Account acc = [SELECT Id
                               FROM Account 
                               WHERE Website =:website
                               or Website =:httpWebsite
                               or Website =:httpswebsite
                               or Website =:international Limit 1];
                
                myCon.AccountId = acc.Id ;
            }
        }
        
       
    }
    
}
Thanks
Hi all,

Here is my code though its not showing any error but I am certain there is someting wrong with it. As it is not fulfilling the requirement.
Please help me rectifying it. and let me know where I am goung wrong.

public class Move_Contact {
    public static void updateContact(List <Contact> conList){
        String MainDomain = '';
        string website ='www' +MainDomain;
                string httpWebsite ='http://www' + MainDomain;
                string httpswebsite ='https://www'+ MainDomain;
                string international = MainDomain + '.%';
        for(Contact myCon : conList){
            if(myCon.Email != null){
                string domain = myCon.Email.split('@').get(1);
                MainDomain = domain;
            }}
                Map <Id,Id> conMap = new Map <Id,Id>();
        for(Contact myCon : conList){
            conMap.put(myCon.Id , mycon.AccountId);
        }
        
                List<Account> acc = [SELECT Id
                                     FROM Account 
                                     WHERE Website =:website
                                     or Website =:httpWebsite
                                     or Website =:httpswebsite
                                     or Website =:international];
                if(acc.size() == 1){
                    For(Contact c : conList){
                        acc.get(0).Id = conMap.get(c.Id);
                        c.AccountId = conMap.get(c.Id);
                    }
                }     
    }

}
Hi All,

I have written a code but the code is  not deploying as expected can somebody please help me rectify this code.
public class David_Update_desc {
    public static void updateContactMethod(List <Opportunity> OppList){
      Set <Id> IdCollect = new Set <Id>();
        For(Opportunity Opp : OppList){
            If(Opp.AccountId != null){
                IdCollect.add(Opp.AccountId);
            }
        }
        List<Contact> Con = [SELECT Id,
                                    Description
                             FROM Contact
                             WHERE AccountId IN :IdCollect];
        Map <Id, Id> OppMap = new Map<Id, Id>();
        For(Opportunity Opp : OppList){
            OppMap.put(Opp.AccountId , Opp.OwnerId);
        }
        
        If(Con.size() > 0){
            For(Contact c : Con){
                c.Description =  'the Creator is ' + OppMap.get(c.AccountId);
                 Update c;
            }
           
        }
    }}

Thanks.



 
Hello everyone,
This is my code, I wanted to write this class with all best practises recommended.
please help me to rectify this code also i want it to work if both account and contact have same country.

public class Update_Contact_Phone {
    public static void contactOtherPhone(List<Account> AccountList){
        set <id> IdCollect = new set <id>();
        List <Contact> Contacts = [SELECT Id,
                                    OtherPhone
                                   From Contact 
                                  WHERE AccountId IN :IdCollect];
        For(Account acc :AccountList){
            If (acc.Phone != null){
                IdCollect.add(acc.Id);
            }
        }
        Map <Id, string> conmap = new Map <Id, string>();
        For(Account acc : AccountList){
            conmap.put(acc.Id , acc.Phone);
             }
        For(Contact c : Contacts ){
            c.OtherPhone = conmap.get(c.AccountId);
        }
       Update Contacts;
    }}
Hi,

This is my Trigger but I want to make class instead of trigger and then call trigger with it. 

trigger caseClose on Case (before insert) {
    
    for (Case myCase : Trigger.new){
       
        List<Case> LatestCase =[SELECT Id
                          FROM Case
                          WHERE CreatedDate = Today
                          AND Contact.Id =:myCase.ContactId];
        if(LatestCase.size()>=2){
        myCase.Status = 'Closed';
        }
    }

}
Step 1: which displays a list of contacts with radio button
Step 2: so that when I select one, the related fields to that contact opens and are editable
Step 3:  the last step is to click save after editing.
and it all has to be covered up with a progress indicator
please help.
Hello Everyone,

I have a requirement wherein I need to make a Opportunity record read only when the opportunity stage reaches to Closed won or either Closed Lost.
Any help is much appreciated.

Thanks
Hi All,

I have a lightning component on a stanalone app which is a input form for creating a new record. But somehow it is not saving the record as expected.

component:
<aura:component controller="CreateCarRecord" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="newCar" type="Car__c"
     default="{ 'sobjectType': 'Car__c',
                     'Name': '',
                     'Build_Year__c': '',
                     'Mileage__c': '',
                      'Available_For_Rent__c': '',
                   }"/>

    
    
        <lightning:layout>
            <lightning:layoutItem size="4" padding="around-small">
              <lightning:input aura:id="carField" type="text" value="{!v.newCar.Name}" Name="Name" label ="Car Name"/>
       <lightning:input aura:id="carField" type="number" name="Build Year" label="Build Year"  value="{!v.newCar.Build_Year__c}" />
                 <lightning:input aura:id="carField" type="number"  value="{!v.newCar.Mileage__c}"  Name="Mileage" label="Mileage"/>
        <lightning:input aura:id="carField" type="checkbox"  value="{!v.newCar.Available_For_Rent__c}"  Name="Available" label="Available"/>
        
        <lightning:button aura:id="carField" label="Save Car" onclick="{!c.saveCar}"/>
            </lightning:layoutItem>
            </lightning:layout>
</aura:component>

controller:
({
	saveCar :  function(component, event) {
    var newAcc = component.get("v.newCar");
    var action = component.get("c.save");
    action.setParams({ 
        "con": newAcc
    });
    action.setCallback(this, function(a) {
           var state = a.getState();
        console.log("state--" +state);
            if (state === "SUCCESS") {
                var name = a.getReturnValue();
               alert("hello from here"+name);
            }else{
                alert("nothing");
            }
        });
    $A.enqueueAction(action)
}
})

Apex:
public class CreateCarRecord {

  
    @AuraEnabled
    public static Car__c save(Car__c con)
    {
     insert con;
        return con;
    }
}

​​​​​​​​​​​​​​
Add radio button to the account list in a lightning component and on selecting that particular radio button on account list it should open the related contacts to it. How to achieve this requirement
Hi All,

I have a scenario where I need to create a VF page with these details:
whenever a parent record from (Auctions__c) object is selected, automaically option for creating a child record in 
(SellerAuctionItem__c) object opens up in which Auction field(read only) (master detial relationship) is autopopulated with the parent record selected. And rest can be filled and saved
Hi All,

I am attemption to update a field of a child object of a master detail .

Here is the code:

public class SubmitApproval {

public static void createAccountManager(List<SellerAuctionItem__c> triggerNewList){
      
        List<string> AuctionSet = new List<String>();
        for (SellerAuctionItem__c item : triggerNewList) {
            if(item.Auction__c != null){
                AuctionSet.add(item.Auction__r.Name);
                system.debug('Name' +AuctionSet);
            }
        }
        
        Map<String, Auctions__c> mapAuction = new Map<String,Auctions__c>([Select Name , Account_Manager__c From Auctions__c  WHERE Name IN:AuctionSet ]);
        system.debug('Name and account manager' +mapAuction);
        for (SellerAuctionItem__c item : triggerNewList) {
            if(item.Account_Manager__c == Null){
            item.Account_Manager__c = mapAuction.get(item.Auction__c).Account_Manager__c;
            }    }

    }   
}

It is giving null pointer error : Attempt to de-reference a null object

Please help, Thanks
 
Hi all ,

This is my code , I want to update Contact's description everytime I update opportunity's description.
This is not working somehow . please help me figure out my mistake

public class DESC_UpdateForum {
    public static void DESC_UpdateForumMethod (list<Opportunity> Opplist){
        
        Set<Id> idSet = new set<Id>();
        For(Opportunity Opp : Opplist){
            if(Opp.AccountId != null){
                idset.add(Opp.AccountId);
            }
        }
        List <Contact> con = [SELECT Id,
                                     AccountId,
                                     Description
                              From Contact
                              Where AccountId IN :idSet];
        Map<Id , String> Oppmap =  new Map<Id, String>();
            For(Opportunity Opp : Opplist){
                If(Opp.Account != null){
                    Oppmap.put(Opp.AccountId , Opp.Description);
                }
            }
        if(con.size()>0){
            For(Contact c :con){
                If(c.AccountId != null){
             c.Description = Oppmap.get(c.AccountId);
                }}
        }
        Update con;
    }}

Thanks
Hi All, 

I need to bulkify this code please help.

public class Move_Contact {
    public static void updateContact(List <Contact> conList){
        Map <Id,Id> conMap = new Map <Id,Id>();
        
        for(Contact myCon : conList){
            if(myCon.Email != null){
                string domain = myCon.Email.split('@').get(1);
               
                String MainDomain = domain;
                string website ='www.' +MainDomain;
                string httpWebsite ='http://www.' + MainDomain;
                string httpswebsite ='https://www.'+ MainDomain;
                string international = MainDomain + '.%';
                
                Account acc = [SELECT Id
                               FROM Account 
                               WHERE Website =:website
                               or Website =:httpWebsite
                               or Website =:httpswebsite
                               or Website =:international Limit 1];
                
                myCon.AccountId = acc.Id ;
            }
        }
        
       
    }
    
}
Thanks
Hi all,

Here is my code though its not showing any error but I am certain there is someting wrong with it. As it is not fulfilling the requirement.
Please help me rectifying it. and let me know where I am goung wrong.

public class Move_Contact {
    public static void updateContact(List <Contact> conList){
        String MainDomain = '';
        string website ='www' +MainDomain;
                string httpWebsite ='http://www' + MainDomain;
                string httpswebsite ='https://www'+ MainDomain;
                string international = MainDomain + '.%';
        for(Contact myCon : conList){
            if(myCon.Email != null){
                string domain = myCon.Email.split('@').get(1);
                MainDomain = domain;
            }}
                Map <Id,Id> conMap = new Map <Id,Id>();
        for(Contact myCon : conList){
            conMap.put(myCon.Id , mycon.AccountId);
        }
        
                List<Account> acc = [SELECT Id
                                     FROM Account 
                                     WHERE Website =:website
                                     or Website =:httpWebsite
                                     or Website =:httpswebsite
                                     or Website =:international];
                if(acc.size() == 1){
                    For(Contact c : conList){
                        acc.get(0).Id = conMap.get(c.Id);
                        c.AccountId = conMap.get(c.Id);
                    }
                }     
    }

}
Hi All,

I have written a code but the code is  not deploying as expected can somebody please help me rectify this code.
public class David_Update_desc {
    public static void updateContactMethod(List <Opportunity> OppList){
      Set <Id> IdCollect = new Set <Id>();
        For(Opportunity Opp : OppList){
            If(Opp.AccountId != null){
                IdCollect.add(Opp.AccountId);
            }
        }
        List<Contact> Con = [SELECT Id,
                                    Description
                             FROM Contact
                             WHERE AccountId IN :IdCollect];
        Map <Id, Id> OppMap = new Map<Id, Id>();
        For(Opportunity Opp : OppList){
            OppMap.put(Opp.AccountId , Opp.OwnerId);
        }
        
        If(Con.size() > 0){
            For(Contact c : Con){
                c.Description =  'the Creator is ' + OppMap.get(c.AccountId);
                 Update c;
            }
           
        }
    }}

Thanks.



 
Hello everyone,
This is my code, I wanted to write this class with all best practises recommended.
please help me to rectify this code also i want it to work if both account and contact have same country.

public class Update_Contact_Phone {
    public static void contactOtherPhone(List<Account> AccountList){
        set <id> IdCollect = new set <id>();
        List <Contact> Contacts = [SELECT Id,
                                    OtherPhone
                                   From Contact 
                                  WHERE AccountId IN :IdCollect];
        For(Account acc :AccountList){
            If (acc.Phone != null){
                IdCollect.add(acc.Id);
            }
        }
        Map <Id, string> conmap = new Map <Id, string>();
        For(Account acc : AccountList){
            conmap.put(acc.Id , acc.Phone);
             }
        For(Contact c : Contacts ){
            c.OtherPhone = conmap.get(c.AccountId);
        }
       Update Contacts;
    }}
Step 1: which displays a list of contacts with radio button
Step 2: so that when I select one, the related fields to that contact opens and are editable
Step 3:  the last step is to click save after editing.
and it all has to be covered up with a progress indicator
please help.