• himanshu huske 7
  • NEWBIE
  • 95 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 58
    Questions
  • 22
    Replies
public class CSI_DeligationController {

    public static CSI_Response deligateUSer(String deligateeJson){
        if(String.isNotBlank(deligateeJson)){
            CSI_DataWrapper.DeligateeContact contactWrapper =(CSI_DataWrapper.DeligateeContact) JSON.deserialize(deligateeJson, CSI_DataWrapper.DeligateeContact.Class);
             
            if(contactWrapper != null){
                Contact contactRecord = new Contact();
                contactRecord.FirstName = contactWrapper.firstName;
                contactRecord.LastName = contactWrapper.lastName;
                contactRecord.Email = contactWrapper.email;
                contactRecord.AccountId = contactWrapper.accountId;
                
                RecordType recType = [SELECT Id, Name, DeveloperName 
                                      FROM RecordType 
                                      WHERE SObjectType = 'Contact' AND 
                                      		Name =: contactWrapper.recordType ];

                contactRecord.RecordTypeId = recType.id;
                
                try{
                    insert contactRecord;
                    //return CSI_Utils.createPortalUser(contactRecord);
                }catch(Exception ex){
                    System.debug('Exception '+ ex.getMessage());
                    return new CSI_Response(false, ex.getMessage(), '');
                }
            }
        }
        return new CSI_Response(false, '' , '');
    }
}

 
public class CSI_BankReferenceController {

/**
  * ───────────────────────────────────────────────────────────────────────────────────────────────┐
  * getApplicationRecord method is written to get ApplicationId of current Application.
  * CSIApplicationController.getApplicationRecord returns CSI_Response.
  * ────────────────────────────────────────────────────────────────────────────────────────────────
  * @return   CSI_Response     returns instance of CSI_Responce class.
  * ───────────────────────────────────────────────────────────────────────────────────────────────┘
  */    
@AuraEnabled
    public static CSI_Response getApplicationRecord(){
    	return CSI_ApplicationController.getApplicationRecord();
    }

/**
  * ───────────────────────────────────────────────────────────────────────────────────────────────┐
  * getBankReferences method is written to get Bank deteials of current Application.
  * ────────────────────────────────────────────────────────────────────────────────────────────────
  * @return   CSI_Response     returns instance of CSI_Responce class.
  * ───────────────────────────────────────────────────────────────────────────────────────────────┘
  */      
   @AuraEnabled
    public static CSI_Response getBankReferences(String applicationId){
        
        if(String.isNotEmpty(applicationId)){ 
                System.debug('applicationId '+ applicationId);
            Application_Member__c applicationMember;
            //Query to get List of Application Members of current Application where RecordType='Bank Reference'
            List<Application_Member__c> lstApplicationMember = [SELECT Id, Name,Phone__c, Mobile__c,Name__c,Phone_Type__c
                                                 FROM Application_Member__c 
                                                 WHERE Application__c =: applicationId AND RecordType.Name = 'Bank Reference' 
                                                 LIMIT 1];
				System.debug('lstApplicationMember '+ lstApplicationMember);
			if(!lstApplicationMember.isEmpty()){
            applicationMember=lstApplicationMember.get(0);
            }
            
            //Query to get List of Application Contract of current Application 
            List<Application_Contract__c> lstApplicationContract = [SELECT Bank_Institution__c, Account_Funding_Type__c,Reference_Bank_US_Ind__c
                                                                        FROM Application_Contract__c
                                                                        WHERE  Application__c =: applicationId LIMIT 1];
				Application_Contract__c applicationContract;
				if(!lstApplicationContract.isEmpty()){
					applicationContract = lstApplicationContract.get(0);
				
				return new CSI_Response(true, '', new CompanyInformationWrapper(applicationId,applicationContract,applicationMember));
			}
		}
		
		return new CSI_Response(false, 'Application not found', '');
    }
    
    /**
  * ───────────────────────────────────────────────────────────────────────────────────────────────┐
  * saveCompanyInformation method is written to save data entered on form/scrren of bankReference. 
  * ────────────────────────────────────────────────────────────────────────────────────────────────
  * @param  applicationId Type:String  Id of current Application.
  * @param  jsonData      Type:String  Data entered on screen convertd into json type string.
  * @return   CSI_Response     returns instance of CSI_Responce class.
  * ───────────────────────────────────────────────────────────────────────────────────────────────┘
  */ 
      @AuraEnabled
    public static CSI_Response saveCompanyInformation(String applicationId, String jsonData){
       System.debug('Save Method');
        System.debug('jsonData '+ jsonData);
            
        if(String.isNotBlank(applicationId) && String.isNotBlank(jsonData)){
            CompanyInformationWrapper companyInfo = (CompanyInformationWrapper) JSON.deserialize(jsonData, CompanyInformationWrapper.class);
            
            try{
                if(companyInfo.applicationMember != null){
                    upsert companyInfo.applicationMember;
                }
                
                if(companyInfo.applicationContract != null){
                    upsert companyInfo.applicationContract;
                }
                
                
                CSI_Response csiResp = getBankReferences(applicationId);
                CSI_ApplicationProgressHandler.updateApplicationProgress('Bank Reference', applicationId);
                csiResp.message = 'Saved Successfully!';
                return csiResp;
            }catch(Exception ex){
                System.debug('Exception : '+ ex.getMessage());
                return new CSI_Response(false, ex.getMessage(), '');
            }
        }
        
        return new CSI_Response(false, 'Something went wrong.' , '');
    }
  
    //Methode to create new Instance of Application_Member__c where Record Type is 'Bank Reference' & Application=applicationId
     public static Application_Member__c createNewApplicationMemberInstanceCmp(String applicationId){
         
        Id recordTypeId=Schema.SObjectType.Application_Member__c.getRecordTypeInfosByName().get('Bank Reference').getRecordTypeId();
        
        system.debug('recordTypeId ' + recordTypeId);
        
        Application_Member__c newAppMemberInstance = new Application_Member__c();
        newAppMemberInstance.Salutation__c = '';               
        newAppMemberInstance.Application__c = applicationId;
        newAppMemberInstance.Email__c = '';
        newAppMemberInstance.Mobile__c = '';
        newAppMemberInstance.Name__c = '';
        newAppMemberInstance.Phone__c = '';
        newAppMemberInstance.Phone_Type__c='';
        newAppMemberInstance.FirstName__c = 'te';
        newAppMemberInstance.LastName__c = '';
        newAppMemberInstance.Title__c = '';
        newAppMemberInstance.RecordTypeId = recordTypeId;
        newAppMemberInstance.Address_Line_1__c = '';
        //newAppMemberInstance.Address_Line_2__c = '';
        newAppMemberInstance.City__c = '';
        newAppMemberInstance.State__c = '';
        newAppMemberInstance.Zip_Code__c = '';
        newAppMemberInstance.Country__c = '';
        
       
        
        return newAppMemberInstance;
    }
    }

 
I have Account(parent) and Application(child) obj.
i want validation on account such that
if Application__c.status__c = 'inprogress'.
parent account record gets locked.
if we try to make changes in parent account record it will show error popup message
I have Account, Opportunity and Application Object.
Application is child to account, Application has picklist field status__c
if, Application Statas__c ='inProgress' , Account and Opportunity records should get locked, 
if status=='InProgress' records should get unlock.
I have 2 tabs in application.
first is application, second is summary.
application has some field in which we input data and save,
and summary shows all data entered in application,
Summary 
also has edit button, which redirect to application tab.
I want functionality such that, after redirecting to application tab.
whatever fields are empty in application should be highlited with some message below it
Hi Guys,
Please help me in code.
I have some fields like fName, lNmae,Email, DrivingLiscience etc and a status__c field(values: not opened, in progress, compleated ) .
if all fields are populated then status__c = 'compleated' 
else status__c ='inprogress';
Please provide any salesforce standard logic for state abbreviation.
eg: California - CA , Alaska - AL
for User state picklist
 
Hi,
I Have Fields First name, last name, and file upload.
file only get upload when firstname last name are populated.
so I want to show a message "enter first name and last name" when we try to upload file without first name and last name
in aura component
Only One contact should be primary under Account.If user makes other contact as primary then previous one should be made non- primary.Need to store the new and old primary contact value on 2 fields oldContact and newContact on Account.
 
update 1 parent 'contact info' text field with names of all the child contact related records names.
I want to create certain input field for account, if we populate those field and click on 'save' button, Account should get created of that values... 
Please Provide Me code for this scenerio..
acount record has child contact record, if status__c(picklist) field of contact record is 'open' update account description field of account record.
trigger x4 on Account (before update) {
    list<account> accList = new list<account>();
    set<id> idSet = new set<id>();
    for(account acc : trigger.new){
        idSet.add(acc.id);
    }
    list<contact> conList = [Select id, accountid, Status__c from contact where accountId in: idSet];
    map<id,contact> conMap = new map<id,contact>();
    for(contact con : conList){
        conMap.put(con.accountId, con);
    }
    for(account a : trigger.new){
        if(conmap.containsKey(a.id) || conmap.get(a.id).Status__c=='open'){
            a.description = 'account is updated from contact';
            accList.add(a);
        }
    }
    update acclist;
}


 
Consider there is 1 Lac Account record in the system. Each account record has 2 child Contact records. You have requirement as to update child records address same as parent address and if there is no address populate 'Not available' string in address.
Working as SystemAdmin,
No triggers are active,
public class S_4_ContactListController {
   @AuraEnabled
   public static List<Contact> getContactList(){
      list<Contact> contactList = new List<Contact>([Select Id, FirstName,LastName, Email, Phone From contact Where Email != null]);  
      // contactList = [Select Id, FirstName,LastName, Email, Phone From contact Where Email != null];
     return contactList;  
    }
}

 
i have objects Patient__c, Doctor__c, Appointment__c, Medications__c.
Appointment__c has field patient__c(lookup), doctor__c(lookup), AppointMentDate__c(Date)
Medications__c has field patient__c(lookup), doctor__c(lookup), description__c, NextVisit__c(date).
Patient__c has an Email__c field.
if medication record is created with NextVisit != Null, 
it should send email before 2 days To get Appointment.
if appointment is made before NextVisit__c date, email should not get sent.
public class Claim_Property_from_Sales_Region {

    public contact con {get;set;}
  
    public PageReference Cancel() {
    PageReference prf = new PageReference('https://ap8.salesforce.com/a0H/o');
        return prf;
    }


    public PageReference claimAndCountinue() {
    updateSearchItemsMap();
    SetStatusWorking();
        return null;
    }

    public void SetStatusWorking(){
     List<Property__c> pt = new List<Property__c>();
      set<id> idSet = mapHoldingSelectedRecords.keySet();
     List<Property__c> prplist = [Select id,Status__c from Property__c where id in : idSet];
        for(Property__c prp : prplist){
        Property__c property = new Property__c();
        property.id =  prp.id;
     //   property.Agent__c = UserInfo.getUserId();
        property.Status__c  = 'Working';
        pt.add(property);
        update pt;
        }
}
     
    
    public PageReference claimProp() {
    updateSearchItemsMap();
    SetStatusWorking();
    PageReference pf = new PageReference('https://ap8.salesforce.com/a0H/o');
        return pf;
    }


    public Claim_Property_from_Sales_Region() {
     mapHoldingSelectedRecords = new Map<Id, WrapperClass>();
     init();
    }

   
   Public Integer size{get;set;}
 Public Integer noOfRecords{get; set;}
 public List <WrapperClass> wrapperRecordList{get;set;}
 Map<Id, WrapperClass> mapHoldingSelectedRecords{get;set;}
 
 
 public void init() {
 wrapperRecordList = new List<WrapperClass>();
 for (Property__c p : (List<Property__c>)setCon.getRecords()) {
 if(mapHoldingSelectedRecords != null && mapHoldingSelectedRecords.containsKey(p.id)){
 wrapperRecordList.add(mapHoldingSelectedRecords.get(p.id));
 
 }
 else{
   wrapperRecordList.add(new WrapperClass(p, false));
 }
 }
 } 
 
   public ApexPages.StandardSetController setCon {
 get {
 if(setCon == null) {
   setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT id, Property_Name__c,Property_City__c, Listing_Price__c, Status__c,createdDate FROM Property__c where Status__c = 'open']));
   setCon.setPageSize(5);
 }
   return setCon;
 }
 set;
 }
 public Boolean hasNext {
 get {
   return setCon.getHasNext();
 }
 set;
 }
 
 public Boolean hasPrevious {
 get {
   return setCon.getHasPrevious();
 }
 set;
 }
 
 public Integer pageNumber {
 get {
   return setCon.getPageNumber();
 }
 set;
 }
   Public Integer getTotalPages(){
     Decimal totalSize = setCon.getResultSize();
     Decimal pageSize = setCon.getPageSize();
     Decimal pages = totalSize/pageSize;
     return (Integer)pages.round(System.RoundingMode.CEILING);
 }
 
 public void first() {
   updateSearchItemsMap();
   setCon.first();
   init();
 }
 
 public void last() {
   updateSearchItemsMap();
   setCon.last();
   init();
 }
 public void previous() {
   updateSearchItemsMap();
   setCon.previous();
   init();
 }
 
 public void next() {
   updateSearchItemsMap();
   setCon.next();
   init();
 }

 private void updateSearchItemsMap() {
 for(WrapperClass wrp : wrapperRecordList){
  if(wrp.isSelected){
     mapHoldingSelectedRecords.put(wrp.prop.id, wrp);
  }
  if(wrp.isSelected == false && mapHoldingSelectedRecords.containsKey(wrp.prop.id)){
     mapHoldingSelectedRecords.remove(wrp.prop.id);
  }
 }
 }
 public class WrapperClass {
 public Boolean isSelected {get;set;}
 public Property__c prop {get;set;}
 public WrapperClass(Property__c prop, Boolean isSelected) {
    this.prop = prop;
    this.isSelected = isSelected;
 }
 }
}

 
Objects: Contact and Property_c  
Property__c has Agent__c(lookUp to Contact)
1)   Contact has Default_commission_split__c field and Property has Agent_Commission_Per__c field
Whenever Default_commission_split__c get updated, Agent_Commission_Per__c should also get updated.
2)  Contact has Year_To_date_Total_Sales__c field and Property has Sales_price__c field
Year_To_date_Total_Sales__c should b sum of all Property record Sales_price__c field(Same as rollUp Summary
//trigger
trigger Pupulate_Agent_And_AgentCommission on Property__c (before update,after update) {

    if(trigger.isbefore){
        Populate_Agent_Commision pA = new Populate_Agent_Commision();
        pA.Agent_Commission(trigger.new, trigger.new);
    }
  
    if(trigger.isafter){
        Calculate_YearToSaleDate_From_SalesPrice cY = new Calculate_YearToSaleDate_From_SalesPrice();
        cY.YearToSaleDate_Updation(trigger.new);
    }
}


public class Populate_Agent_Commision {
    public  void Agent_Commission(List<Property__c> prop1,List<Property__c> prop2) {
          list<contact> contactlist = new list<contact>();
   set<id> pset = new set<id>();
       for (Property__c p1 : prop1){
           pset.add(p1.Agent__c);
        }
        map<id,contact> conmap = new map<id,contact>();
   list<contact> conlist = [select id,name,Default_commission_split__c,Year_To_date_Total_Sales__c from contact where id in: pset];
    for(contact c : conlist){
           conmap.put(c.id, c);
    }
    for(property__c p2: prop2){
        if(p2.status__C =='Closed Pending Approval'|| p2.Status__c =='Closed Approved'){
          p2.Agent_Commission_Per__c = conmap.get(p2.Agent__c).Default_commission_split__c;
    
    }
}
}
}

public class Calculate_YearToSaleDate_From_SalesPrice {
    public void YearToSaleDate_Updation(list<Property__c> propList){
        Set<id> AgentId = new Set<id>();
    for(Property__c p1 : propList){
       AgentId.add(p1.Agent__c);
    }
   list<Property__c> pList =  [Select id, Agent__c, Property_Name__c, Sales_price__c From Property__c Where Agent__c IN: AgentId];
    map<Id,list<Property__c>> conMap = new map<Id,list<Property__c>>();
    for(Property__c pr_1 : pList){
       conMap.put(pr_1.Agent__c, new list<Property__c>()); 
       conMap.get(pr_1.Agent__c).add(pr_1);
    }
   list<Contact> conList = [Select id, Name, Year_To_date_Total_Sales__c from Contact Where id IN: conMap.keySet()];
    decimal amount = 0;
    for(Contact c1 : conList){
        for(Property__c pr_2: conMap.get(c1.Id)){
         amount += pr_2.Sales_price__c;  
        }
       c1.Year_To_date_Total_Sales__c = amount;
    }    
   update conList;
    }
}

)



 
trigger Trg_Property_Contact on Property__c (before update,after update) {
   String UserID = UserInfo.getUserId();
   list<contact> contactlist = new list<contact>();
   set<id> pset = new set<id>();
   map<id,contact> conmap = new map<id,Contact>();
       for (Property__c p : trigger.new){
           pset.add(p.Agent__c);
        }
   list<contact> conlist = [select id,name,Default_commission_split__c,Year_To_date_Total_Sales__c from contact where id in: pset];
    for(contact c : conlist){
           conmap.put(c.id, c);
    }
if(trigger.isbefore){
    for(property__c p1: trigger.new){
        if(p1.status__C =='Closed Pending Approval'|| p1.Status__c =='Closed Approved'){
          p1.Agent_Commission_Per__c = conmap.get(p1.Agent__c).Default_commission_split__c;
    }
}
   
}
if(trigger.isafter){
      set<id> myset = new set<id>();
      map<id,contact> cmap = new map<id,Contact>();
      list<contact> contactlist = new list<contact>();
          for (Property__c p : trigger.old){
               myset.add(p.Agent__c);
          }
   list<contact> conlist = [select id,name,Default_commission_split__c,Year_To_date_Total_Sales__c from contact where id in: myset];
       for(contact ct : conlist){
           cmap.put(ct.id, ct);
          }
       for(property__c p3: trigger.old){
        if(p3.status__C =='Closed Pending Approval'){
            if(cmap.containskey(p3.Agent__c)){
               contact c1 = cmap.get(p3.Agent__c); 
               c1.Year_To_date_Total_Sales__c = c1.Year_To_date_Total_Sales__c + p3.Sales_price__c;
            }
    }
  }
    update contactlist;
}
}

 
There are two Objects:
1.Property__c(obj) with fields Status__c(Picklist) and Ajent__c(lookUp to Contact)
2.Contact (obj)
Scenerio:
Contact obj has some records 
if user change status__c of property form 'open' to 'working' the, If that user have a contact record, Agent__c field should get populated with that Contact Name field.  
this page i wanna create, please correct the  codeUser-added image
 
<apex:page standardController="Sales_Office__c"  docType="html-5.0" tabStyle="Sales_Office__c" extensions="Claim_Property_from_Sales_Region" recordSetVar="wrapperRecordList">
  <apex:sectionHeader title="Sales Office" subtitle="{!Sales_Office__c.Sales_Office_Name__c}" />
   <apex:form title="{!Sales_Office__c.Sales_Office_Name__c}"> 
   <apex:pageBlock title="Sales Office" rendered="{!wrapperRecordList.size!=0}" id="pbId" >
   <apex:commandButton label="Calim Property" value={!claimProp}/>>
    <apex:commandButton label="Calim and countinue" value={!claimAndCountinue}/>>
     <apex:commandButton label="Cancel" value={!Cancel}/>>
    <apex:pageBlockTable value="{!wrapperRecordList}" var="cont">
           <apex:column headerValue="Select">
             <apex:inputCheckbox value="{!p.isSelected}"/>
           </apex:column>
           <apex:column headerValue="Property">
             <apex:outputField value="{!p.prop.Property_Name__c}"/>
           </apex:column>
           <apex:column headerValue="Property City">
             <apex:outputField value="{!p.prop.Property_City__c}"/>
           </apex:column>
           <apex:column headerValue="List Price">
            <apex:outputField value="{!p.pop.Listing_Price__c}"/>
           </apex:column>
           <apex:column headerValue="Status">
            <apex:outputField value="{!p.pop.Status__c}"/>
           </apex:column>
           <apex:column headerValue="Date Added">
            <apex:outputField value="{!p.pop.createdDate}"/>
           </apex:column>
       </apex:pageBlockTable>       
    <apex:outputPanel style="text-align:center;" layout="block">
          <apex:commandButton value="First" reRender="pbId" action="{!first}" disabled="{!NOT(hasPrevious)}" status="paginationStatus"/>
          <apex:commandButton value="Previous" rerender="pbId" action="{!previous}" disabled="{!NOT(hasPrevious)}" status="paginationStatus"/>&nbsp;Page {!pageNumber} of {!totalPages}&nbsp;
          <apex:commandButton value="Next" rerender="pbId" action="{!next}" disabled="{!NOT(hasNext)}" status="paginationStatus"/>
          <apex:commandButton value="Last" rerender="pbId" action="{!last}" disabled="{!NOT(hasNext)}" status="paginationStatus"/>
          <apex:actionStatus id="paginationStatus">
             <apex:facet name="start">
                 Please wait...<img src="/img/loading32.gif" style="width: 18px;"/>
             </apex:facet>
          </apex:actionStatus>
          </apex:outputPanel>
     </apex:pageBlock>
   </apex:form>
</apex:page>



public class Claim_Property_from_Sales_Region {
   
   Public Integer size{get;set;}
 Public Integer noOfRecords{get; set;}
 public List<SelectOption> paginationSizeOptions{get;set;}
 public static final Integer QUERY_LIMIT = 10000;
 public static final Integer PAGE_SIZE = 5;
 public List <WrapperClass> wrapperRecordList{get;set;}
 Map<Id, WrapperClass> mapHoldingSelectedRecords{get;set;}
 
 public Claim_Property_from_Sales_Region (ApexPages.StandardSetController con){
 }
 
 public Claim_Property_from_Sales_Region(){
   mapHoldingSelectedRecords = new Map<Id, WrapperClass>();
   init();

//Init method which queries the records from standard set controller.
 public void init() {
 wrapperRecordList = new List<WrapperClass>();
 for (Property__c p : (List<Property__c>)setCon.getRecords()) {
 if(mapHoldingSelectedRecords != null && mapHoldingSelectedRecords.containsKey(p.id)){
 wrapperRecordList.add(mapHoldingSelectedRecords.get(p.id));
 
 }
 else{
   wrapperRecordList.add(new WrapperClass(p, false));
 }
 }
 } 
 
   /** Instantiate the StandardSetController from a query locater*/  
   public ApexPages.StandardSetController setCon {
 get {
 if(setCon == null) {
   setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Property_Name__c,Property_City__c, Listing_Price__c, Status__c,createdDate FROM Property__c where Status__c = 'open' LIMIT : QUERY_LIMIT ]));
 // sets the number of records to show in each page view
   setCon.setPageSize(PAGE_SIZE);
 }
   return setCon;
 }
 set;
 }
 public Boolean hasNext {
 get {
   return setCon.getHasNext();
 }
 set;
 }
 
 /** indicates whether there are more records before the current page set.*/
 public Boolean hasPrevious {
 get {
   return setCon.getHasPrevious();
 }
 set;
 }
 
 /** returns the page number of the current page set*/
 public Integer pageNumber {
 get {
   return setCon.getPageNumber();
 }
 set;
 }
 /** return total number of pages for page set*/
   Public Integer getTotalPages(){
     Decimal totalSize = setCon.getResultSize();
     Decimal pageSize = setCon.getPageSize();
     Decimal pages = totalSize/pageSize;
     return (Integer)pages.round(System.RoundingMode.CEILING);
 }
 
 /** returns the first page of the page set*/
 public void first() {
   updateSearchItemsMap();
   setCon.first();
   init();
 }
 
 /** returns the last page of the page set*/
 public void last() {
   updateSearchItemsMap();
   setCon.last();
   init();
 }
 /** returns the previous page of the page set*/
 public void previous() {
   updateSearchItemsMap();
   setCon.previous();
   init();
 }
 
 /** returns the next page of the page set*/
 public void next() {
   updateSearchItemsMap();
   setCon.next();
   init();
 }
 //This is the method which manages to remove the deselected records, and keep the records which are selected in map.
 private void updateSearchItemsMap() {
 for(WrapperClass wrp : wrapperRecordList){
  if(wrp.isSelected){
     mapHoldingSelectedRecords.put(wrp.prop.id, wrp);
  }
  if(wrp.isSelected == false && mapHoldingSelectedRecords.containsKey(wrp.prop.id)){
     mapHoldingSelectedRecords.remove(wrp.prop.id);
  }
 }
 }
 public class WrapperClass {
 public Boolean isSelected {get;set;}
 public Property__c prop {get;set;}
 public WrapperClass(Property__c prop, Boolean isSelected) {
    this.prop = prop;
    this.isSelected = isSelected;
 }
 }
}



 
I have Account, Opportunity and Application Object.
Application is child to account, Application has picklist field status__c
if, Application Statas__c ='inProgress' , Account and Opportunity records should get locked, 
if status=='InProgress' records should get unlock.
Hi Guys,
Please help me in code.
I have some fields like fName, lNmae,Email, DrivingLiscience etc and a status__c field(values: not opened, in progress, compleated ) .
if all fields are populated then status__c = 'compleated' 
else status__c ='inprogress';
Please provide any salesforce standard logic for state abbreviation.
eg: California - CA , Alaska - AL
for User state picklist
 
update 1 parent 'contact info' text field with names of all the child contact related records names.
Consider there is 1 Lac Account record in the system. Each account record has 2 child Contact records. You have requirement as to update child records address same as parent address and if there is no address populate 'Not available' string in address.
Working as SystemAdmin,
No triggers are active,
public class S_4_ContactListController {
   @AuraEnabled
   public static List<Contact> getContactList(){
      list<Contact> contactList = new List<Contact>([Select Id, FirstName,LastName, Email, Phone From contact Where Email != null]);  
      // contactList = [Select Id, FirstName,LastName, Email, Phone From contact Where Email != null];
     return contactList;  
    }
}

 
There are two Objects:
1.Property__c(obj) with fields Status__c(Picklist) and Ajent__c(lookUp to Contact)
2.Contact (obj)
Scenerio:
Contact obj has some records 
if user change status__c of property form 'open' to 'working' the, If that user have a contact record, Agent__c field should get populated with that Contact Name field.  
Hi mighty developers,
I m a beginner, please correct my code.
i have Country__c Object with all Text fields  Name__c,Capital_City__c,Region__c,Sub_Region__c,Regional_Block__c,Country_ISO_Code_2__c,Country_ISO_Code_3__c from Country__c.
this is the Url for integration:  https://restcountries.eu/
I want to create records for each country and populate all fiels in records for JSON
also provide testing code if possible
public class CountryNameWrapper{
	public string name{get;set;}
	public string alpha2Code{get;set;}
	public string alpha3Code{get;set;}
	public string capital{get;set;}
	public string region{get;set;}
	public string subregion{get;set;}
	public List<CountryNameWrapper.RegionalBlocsWrapper> regionalBlocs{get;set;}
	
	public class RegionalBlocsWrapper{
		public String acronym{get;set;}
		public String name{get;set;}
		public List<String> otherAcronyms{get;set;}
		public List<String> otherNames{get;set;}
	}
}


global class Load_Countries_RestApi implements Database.Batchable<sObject>,Database.AllowsCallouts {
 global String query ;
    
 global Database.QueryLocator start(Database.BatchableContext BC) {
     query = 'Select Name__c,Capital_City__c,Region__c,Sub_Region__c,Country_ISO_Code_2__c,Country_ISO_Code_3__c from Country__c';     
        //Query all countries from Country object
        return DataBase.getQueryLocator(query);                                    
    }
    
 global void execute(Database.BatchableContext BC , List <Country__c> contlist) {
     Boolean hasChanged = false;
     Http http = new Http();
     HttpRequest request = new HttpRequest();
     request.setEndpoint('https://restcountries.eu/rest/v2/all');
     request.setMethod('GET');
     HttpResponse response = http.send(request);
     if (response.getStatusCode() == 299) {
     System.debug('response--->'+(List<CountryNameWrapper>)JSON.deserialize(response.getBody(),List<CountryNameWrapper>.class));
     List<CountryNameWrapper> abc = (List<CountryNameWrapper>)JSON.deserialize(response.getBody(),List<CountryNameWrapper>.class);
     List<Country__c> cntList = new List<Country__c>();
     for(CountryNameWrapper cw : abc){
     Country__c cnt = new Country__c();
     cnt.Name__c = cw.name;
     cnt.Capital_City__c = cw.name;
     cnt.Region__c = cw.region;
     cnt.Sub_Region__c = cw.subregion;
  //   cnt.Regional_Block__c = cw.regionalBlocs;
     cnt.Country_ISO_Code_2__c = cw.alpha2Code;
     cnt.Country_ISO_Code_3__c = cw.alpha3Code;
     cntList.add(cnt);
}
insert cntList;
     //Give call to https://restcountries.eu/rest/v2/name/AF
     //AF is country name. It will return you the iterate over the list //(List<CountryNameWrapper>) and see if the information in country is same //as that of object returned from API. If it is not same then set boolean
     //hasChanged to true.
     
     //If has changed is true, then update country object
     }    
 }
 global void finish(Database.BatchableContext BC){
 }   
}

 
In Account object there is a checkbox IsPrimary__c, and in Contact there is PickList Status__c(values: 'IsPrimary', 'IsSecondery').
for an account record if two contact record are created with one as Status__c = IsPrimary and another Status__c = IsSecondery.
1. If in Account IsPrimary__c checkbox is checked then.
Account Discription = Discription in contact having Status__c = IsPrimary. 
2. If in Account IsPrimary__c checkbox is Unchecked then.
Account Discription = Discription in contact having Status__c = IsSecondery.
Please Provide Trigger Using Map
I Have customer obj with field IsPrimary(checkbox) and addrText(textarea)
I also have an obj Addresses with field Addr_type(picklist with valuse 'Primery' and 'Secondery') and Addr_Line_1
if IspPrimary is checked, addrText should get populated with Addresses record Addr_Line_1 having  having picklist value as primary 
else adresses record with secondery value of addressLine_1
I want to create Visualforce Page in which their is a timer for Hour,Minute,Seconds which should start when we click on 'START' button and stop When 'STOP' button is clicked
Account and Contact One Custom fiedl - "Status"
one Account having multiple contact - if all contact Status fiedl is Active then only update "Active" in Account page. Even if 1 contact inactive then Account also inactive - 
I have written trigger. but it working fine only with 1 record. I mean when user insert new contatc at that whatever status I have given based on that it update on contact. but how to check for All contact ? 
I have customer__c object with FirstName_c, LastName_c, DOB_c fields.
First VF page has  FirstName_c, LastName_c, DOB_c  InputFields and a "save" button which save record in Object
And "List" Button show that record fields with that values of input field in Second VF page.
 

Hi developers,
Please fix th issue for thisUser-added imagetrigger TotalAmt_Child_paraent on Child__c (after insert,after update, after delete,after undelete) {
    set<id> idSet = new  set<id>();
    List<Child__c> cList = new List<Child__c>();
    List<Parent__c> pList = new List<Parent__c>();
    if(trigger.isinsert ||trigger.isupdate ||trigger.isundelete){
        for(Child__c c : trigger.new){
            if(c.ParentMD__c != null)
                idSet.add(c.ParentMD__c);
        }
    }
    if(trigger.isdelete){
        for(Child__c c : trigger.old){
            if(c.ParentMD__c != null)
                idSet.add(c.ParentMD__c);
        }
    }    
    if(idSet.size()>0){
    decimal amt = 0;
    cList = [Select id, ParentMD__c from Child__c where ParentMD__c in: idSet];
    Map<id,List<Child__c>> prMap = new Map<id,List<Child__c>>();
    for(Child__c c : cList){
        prMap.put(c.ParentMD__c, new List<Child__c>());
        prMap.get(c.ParentMD__c).add(c);
    }
    pList = [Select id,TotalAmt__c from Parent__c where id in: prMap.keySet()];
        for(Parent__c p : pList){
            for(Child__c ch : prMap.get(p.id)){
                if(ch.MyAmt__c != null)
                    amt +=  ch.MyAmt__c; 
            }
            p.TotalAmt__c = amt;
        }
        update pList;
    }
    }
Write a trigger to auto calculate sum of amount when ever record is inserted update deleted in opportunity object using rollup summary fields
1.customer__c(master obj) and address__c(detail obj).
address__c has has 2 checkbox field Nagpur__c and Pune__c and customer__c has TextField Hometown__c 
if Nagpur__c is checked, Hometown__c = 'nagpur';
if Pune__c is checked, Hometown__c = 'pune';
2. is it true, that master-detail relation trigger like above wont require query ?
 
Please Help Me With Code.
I want to create a page in which,
we use <apex:inputField> or <apex:inputText> for FirstName, LastName, DateOfBirth,Gender(PickList).
There will be a button on page, after insert value in each field and clicking on button, next page will get display, wich will show list of output. which we have entered in inputField or input text.
please give me a code using following methods,
PageReference Px = page.PageName;
    Px.getParameters().put();
ApexPages.currentPage().getParameters().get();