• Parth Srivastava
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 7
    Replies
When a Transaction (Custom object) record is created, look to the Product object for that Product (Product Code maps to Item Number) and pull back the Product “Transaction_Count__c”  field and put it in the Transaction “Transaction_Item_Count__c” field.

public class LightningCustomLookupController{
     @AuraEnabled 
     public static List<sObject> fetchSobject(String searchKeyWord, String sObjectName,String condition) {
         
    
     String searchKey = '%'+searchKeyWord + '%';
     String query = 'SELECT Id, Name FROM '+sObjectName;
     system.debug('condition--------------------'+condition);
     if(sObjectName == 'Order'){
         query = 'SELECT Id, OrderNumber,Account.Name FROM '+sObjectName;
     }
      if(String.isNotBlank(condition)){
        query +=' WHERE '+condition+' LIMIT 100' ; 
      } else {
          query+=' LIMIT 100';
      }
      system.debug('query-----------------------'+query);
      List<sObject> returnList = Database.query(query);
      return returnList;
     }
    @AuraEnabled
    public static sObject getLookUpRecord(Id recordId, String objectName, Boolean isMediaSearch) {
        sObject sObj =  Schema.getGlobalDescribe().get(objectName).newSObject() ;
        if(recordId != null) {
            if(objectName == 'Order'){
                sObj = Database.query('SELECT Id, OrderNumber FROM '+objectName+' WHERE Id =:recordId ');
            } else{
                sObj = Database.query('SELECT Id, Name FROM '+objectName+' WHERE Id =:recordId ');

            }
        }
        return sObj;
    }
    
    @AuraEnabled
    public static List<Account> getRecords(String searchKey) {
        String tempSearchKey = searchKey + '%';
        String ObjectName = 'Account';
        String soql = 'SELECT Name, Type, Phone FROM ' + ObjectName +' WHERE  Name LIKE ' +'\'' + tempSearchKey 
                  +'\'  limit 10';
        system.debug('Query-----------'+soql);
        List<Account> accounts = database.query(soql);
        System.debug( 'accounts->' + accounts);
        return accounts;
    }
}
public with sharing class NewOpportunityLTNGController {
  @AuraEnabled
  public static WrapperClass isContact(String contactId){
    
        String objectAPIName = '';
        String keyPrefix = contactId.substring(0,3);
        for( Schema.SObjectType obj : Schema.getGlobalDescribe().Values() ){
            String prefix = obj.getDescribe().getKeyPrefix();
            if(prefix == keyPrefix){
                objectAPIName = obj.getDescribe().getName();
                break;
            }
        }
    Contact objContact = [SELECT Id, Name,LeadSource,Lead_Source_Name__c, AccountId, Account.Name FROM Contact WHERE Id =:contactId];
    CampaignMember objCampaignMember = [SELECT Id, Name, contactId, CampaignId FROM CampaignMember WHERE ContactId =: contactId Order By CreatedDate DESC Limit 1];
    WrapperClass objWrapper = new WrapperClass();
    objWrapper.hasError = false;
    objWrapper.errorStr = ''; 
    objWrapper.objOpportunity = new Opportunity();
    objWrapper.recordTypes = getItems();
    objWrapper.types = getType();
    for(MapWrapper objRecordType : objWrapper.recordTypes){
      if(objRecordType.recordTypeName == 'Standard Opportunity'){
        objWrapper.objOpportunity.RecordTypeId = objRecordType.recordTypeId;
      }
    }
    objWrapper.objOpportunity.Name = objContact.Account.Name;
    objWrapper.objOpportunity.AccountId = objContact.AccountId;
    objWrapper.objOpportunity.FCRM__FCR_Admin_Originating_Contact__c = objContact.Id;
    objWrapper.objOpportunity.CampaignId = objCampaignMember.CampaignId;
    objWrapper.objOpportunity.LeadSource = objContact.LeadSource;
    objWrapper.objOpportunity.Lead_Source_Name__c = objContact.Lead_Source_Name__c; 
    if(objectAPIName == 'Contact'){
      objWrapper = checkPackageCode(contactId,objWrapper);
    }else{
      objWrapper.hasError = true;
      objWrapper.errorStr = 'Opportunities must be created from a Contact';
    }
    
        return objWrapper;
  }

  public static WrapperClass checkPackageCode(String contactId, WrapperClass objWrapper){
    // Required: If in Active Mode then opp must be created from a contact with an active response
        if(!FCRM.FCR_SupportAPI.IsPassiveMode()) {
      // Required: Contact must be part of an active campaign
            List<CampaignMember> activeResponses = FCRM.FCR_SupportAPI.GetActiveResponses(new List<Id>{contactId});
            if(activeResponses.size() == 0) {
        // Add custom code here to prevent user from creating the opportunity. 
        // You could display a message like "To create an opportunity the contact must have an active repsonse"
        // You could develop your page to show a JavaScript alert with a similar message
        // You could redirect user back to the Contact after showing the message
        objWrapper.hasError = true;
        objWrapper.errorStr = 'To create an opportunity the contact must have an active repsonse';
            }
    }
    return objWrapper;
  }

  public static List<MapWrapper> getItems(){
        List<MapWrapper> options = new List<MapWrapper>();
    String objectAPIName = 'Opportunity' ; //any object api
        Schema.DescribeSObjectResult sobjectResult = Schema.getGlobalDescribe().get(objectAPIName).getDescribe();
        List<Schema.RecordTypeInfo> recordTypeInfo = sobjectResult.getRecordTypeInfos();
        //Map<String,Id> mapofNameAndId = new Map<String,Id>();
        for(Schema.RecordTypeInfo info : recordTypeInfo){
            //mapofCaseRecordTypeNameandId.put(info.getName(),info.getRecordTypeId());
            if(info.getName() != 'Master' &&  info.getName() != 'PoC Opportunity'){
              //mapofNameAndId.put(info.getName(),info.getRecordTypeId());
        MapWrapper objMapWrapper = new MapWrapper();
        objMapWrapper.recordTypeId = info.getRecordTypeId();
        objMapWrapper.recordTypeName = info.getName();
        options.add(objMapWrapper);
            }
        }
        return  options;
    }

  public static List<MapWrapper>  getType(){
    String objectAPIName = 'Opportunity' ; //any object api
     List<MapWrapper> options = new List<MapWrapper>();
    Schema.DescribeSObjectResult sobjectResult = Schema.getGlobalDescribe().get(objectAPIName).getDescribe();
    Schema.DescribeFieldResult fieldResult = Opportunity.Type.getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
    for( Schema.PicklistEntry f : ple) {
      MapWrapper objMapWrapper = new MapWrapper();
      objMapWrapper.recordTypeId = f.getValue();
      objMapWrapper.recordTypeName = f.getLabel();
      options.add(objMapWrapper);
    }       
    return options;
  }

  public class WrapperClass{
    @AuraEnabled
    public Boolean hasError;
    @AuraEnabled
    public String errorStr;
    @AuraEnabled
    public Opportunity objOpportunity;
    @AuraEnabled
    public List<NewOpportunityLTNGController.MapWrapper> recordTypes;
    @AuraEnabled 
    public List<NewOpportunityLTNGController.MapWrapper> types;
    
  }
  public class MapWrapper{
    @AuraEnabled
    public String recordTypeId;
    @AuraEnabled
    public String recordTypeName;
  }
}
public with sharing class HotAccountController {
  public HotAccountController() {  
  }

  @AuraEnabled
  public static Boolean isAccountHot(String accId){
    Account objAccount = [Select Hot_Account__c, Id from Account WHERE Id =: accId];
    return objAccount.Hot_Account__c;
  }

  @AuraEnabled
  public static Boolean callApproval(String accId){
      try{
      UpdateAccount.callApproval(accId);
      return true;
    }catch(Exception excpt){
      return false;
    }
  }
}
There are two custom objects A and B.B is a parent of A object.
Now on insert event, i want to write a trigger that matches name field on both objects and then fill lookup field on basis of the name match
I need help with creating a field that auto-populates the “Standard Price” from the Product object into a field called “Base Price” in the Transactions custom object.
 
Use Case:
 
When a Transaction record is created, the Item Number should be looked up in the Product object "Product Code", then the "Standard Price" should be returned in the "Base Price" field
 
Example:
 
The transaction is created with item number 2200, we should look up the Product object and find the Product with Product code 2200.  Then we should return the standard price of $80.00 into the “Base Price” field.
public class ProcessStepListController {

  @AuraEnabled
  public static List<Process_Step__c> getSteps(String crntOppId) {
    
    String crntOppStage;
    for(Opportunity opp : [Select StageName 
                          From Opportunity 
                          Where Id =: crntOppId]){
      crntOppStage = opp.StageName;
    }
    
    list<Process_Step__c> stepsList = [SELECT Id, Name, Process_Step_Name__c, Stage__c, Date__c, Complete__c, Note__c 
                                      FROM Process_Step__c 
                                      Where Opportunity__c =: crntOppId
                                      AND Stage__c =: crntOppStage
                                      order by createdDate asc];
    return stepsList;
  }
    
  @AuraEnabled
  public static void updateSteps (list<Process_Step__c> stepsList){
    try{
      for(Process_Step__c step : stepsList){
        if(step.Complete__c){
          step.Date__c = date.today();
        }
        else{
          step.Date__c = null;
          }
      }
             
      Database.update(stepsList);
    }catch(exception ex){
      system.debug('An error occurred---:' + ex);
    }
    
  }
}
please help me as i am new in apex triggers ....My requirement :
When user selects any contact through Add Contact lookup and save account then attach selected contact under Account and update “xyz ” text type field on Account with newly added contact’s rank.  (for example, if there are two contacts already under an account with rank 1 and 4 & you added a contact of rank 7 then account's sequenece will be 1,4,7. Trigger will be on account and event will be before update.Suggest
public class ShowRelatedDataClass {

    // Properties
    private ID CaseId ;
    public List<String> items {get;set;}
    static Map<String,Map<Id,List<sObject>>> allvalues;
    public List<HealthCloudGA__EhrCondition__c> EHRConditions {get;set;}
    public List<HealthCloudGA__EhrObservation__c> EHRObservations {get;set;}
    public List<HealthCloudGA__EhrMedicationPrescription__c> EHRMedicationPrescriptions {get;set;}
    public List<HealthCloudGA__EhrMedicationStatement__c> EHRMedicationStatements {get;set;}
    
    // Constructor
    public ShowRelatedDataClass(ApexPages.StandardController controller) {
        caseId = ((Case)controller.getRecord()).Id;        
        case CaseRecord = [Select AccountId From Case Where Id = : caseId];
        
        EHRConditions = new List<HealthCloudGA__EhrCondition__c>();
        EHRConditions  = [Select Name From HealthCloudGA__EhrCondition__c Where HealthCloudGA__Account__c =: CaseRecord.AccountId];
        
        
        EHRObservations = new List<HealthCloudGA__EhrObservation__c>();
        EHRObservations = [Select Name From HealthCloudGA__EhrObservation__c Where HealthCloudGA__Account__c =: CaseRecord.AccountId];
        
        EHRMedicationPrescriptions  = new List<HealthCloudGA__EhrMedicationPrescription__c>();
        EHRMedicationPrescriptions  = [Select Name From HealthCloudGA__EhrMedicationPrescription__c Where HealthCloudGA__Account__c =: CaseRecord.AccountId];

        EHRMedicationStatements = new List<HealthCloudGA__EhrMedicationStatement__c>();
        EHRMedicationStatements = [Select Name From HealthCloudGA__EhrMedicationStatement__c Where HealthCloudGA__Account__c =: CaseRecord.AccountId];


    }
    
    // Method to create map of Data of different tables
    static  Map<Id,List<sObject>> parentmap(String object_name){
        String FieldSet = '';
        if(object_name == 'HealthCloudGA__CarePlanProblem__c')
            FieldSet = ' id,Name , HealthCloudGA__CarePlan__c ';
        if(object_name == 'HealthCloudGA__CarePlanGoal__c')
            FieldSet = ' Id, Name, HealthCloudGA__CarePlanProblem__c ';
        if(object_name  == 'Task')
            FieldSet = ' Id, Subject, HealthCloudGA__CarePlanGoal__c ';
        
        List<sObject> c2 =  Database.query('select '+FieldSet +' from ' + object_name );    
        Map<Id,List<sObject>> m2 = new  Map<Id,List<sObject>>();
        String parentid = '';
        for (sObject o2:c2) {
            parentid = null;
            if (object_name == 'HealthCloudGA__CarePlanProblem__c') {
                parentid = ((HealthCloudGA__CarePlanProblem__c) o2).HealthCloudGA__CarePlan__c;
            } 
            if (object_name == 'HealthCloudGA__CarePlanGoal__c') {
                parentid = ((HealthCloudGA__CarePlanGoal__c) o2).HealthCloudGA__CarePlanProblem__c;
            } 
            if (object_name == 'Task') {
                parentid = ((Task) o2).HealthCloudGA__CarePlanGoal__c ;
            }             
            if (parentid == null) continue;
            if (m2.containsKey(parentid)) {
                ((List<sObject>) m2.get(parentid)).add(o2);
            } else {
                m2.put(parentid, new List<sObject>{o2});
            }
        }
        return m2;
    }
    
    // Method to build pageblock Tables
    public  Component.Apex.PageBlockTable getHierarchy() {
        
        Map<Id,Case> c1 = new  Map<Id,Case>([select id, CaseNumber from Case Where Id = : caseId ]);      
        allvalues = new  Map<String,Map<Id,List<sObject>>>(); 
        allvalues.put('HealthCloudGA__CarePlanProblem__c',parentmap('HealthCloudGA__CarePlanProblem__c'));
        allvalues.put('HealthCloudGA__CarePlanGoal__c',parentmap('HealthCloudGA__CarePlanGoal__c'));
        allvalues.put('Task',parentmap('Task'));
        
        items = new List<String>();
        Component.Apex.PageBlockTable myTable = new  Component.Apex.PageBlockTable(var='item');
        myTable.expressions.value = '{!items}';
        
        Component.Apex.column clm = new Component.Apex.column(headerValue= 'Name'); 
        myTable.childComponents.add( clm );
        Component.Apex.OutputText outText = new Component.Apex.OutputText( );           
        outText.expressions.value = '{!item}';   
        outText.escape = false;   
        clm.childComponents.add( outText );     
        
        for (Id id1 :c1.keyset()) {
            Case o1 = (Case) c1.get(id1);
            items.add(o1.CaseNumber);
            getNodes('HealthCloudGA__CarePlanProblem__c',o1.id);
        }            
        return myTable;
    }
    
    // Method to add child data. 
    public void getNodes(String object_name,String parentid) {        
        String name = '';
        String id = '';        
        Map<Id,List<sObject>> map1 = (Map<Id,List<sObject>>) allvalues.get(object_name);      
        if (object_name == 'HealthCloudGA__CarePlanProblem__c') {
            if (map1.containsKey(parentid)) {
                List<HealthCloudGA__CarePlanProblem__c> lcob = (List<HealthCloudGA__CarePlanProblem__c>) map1.get(parentid);
                for (HealthCloudGA__CarePlanProblem__c cob:lcob) {
                    name = cob.name;
                    items.add('&nbsp;&nbsp;' + name);
                    getNodes('HealthCloudGA__CarePlanGoal__c',cob.id);
                    
                }
            }     
        } else if (object_name == 'HealthCloudGA__CarePlanGoal__c') {
                if (map1.containsKey(parentid)) {
                    List<HealthCloudGA__CarePlanGoal__c> lcob = (List<HealthCloudGA__CarePlanGoal__c>) map1.get(parentid);
                    for (HealthCloudGA__CarePlanGoal__c cob:lcob) {
                        name = cob.name;
                        items.add('&nbsp;&nbsp;&nbsp;&nbsp;' + name);
                        getNodes('Task',cob.id);
                    }
                }   
            } else if (object_name == 'Task') {
                if (map1.containsKey(parentid)) {
                    List<Task> lcob = (List<Task>) map1.get(parentid);
                    for (Task cob:lcob) {
                        name = cob.Subject;
                        items.add('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+name);
    }} } }}
If we have one related custom object(Folder) on lead which has industry picklist different values. We create custom setting and different records of custom setting and now one field checkbox -isactive.if industry value = technology on Folder object, records should be created automatically  with name of custom setting values where checkbox true and industry value should be associated with records
public class ProjectDashboardClass {

Public List<Order__c> OrderList{
    get {
    return [Select id, Project__r.Project_Name__c,Actual_Production_Start_Date__c, Actual_Production_End_Date__c, Italian_Port_Arrival_Date__c, USA_Port_Arrival_Date__c, Marine_Broker_Arrival_Date__c, Cust_Delivery_Date__c, Name From Order__c];     
    }}
    
}

Please suggest as i am unable to get 100% code coverage
I want that when Json is getting created it has all data for account object .Bt in account Shipping address and billing address creates seperate JSON.Now i want to display account record in field type.Ex-City,street etc

Sharing Code for reference
Input: {"SFObject":"Account","PrimaryKey":"Id","PrimaryKeyValue":"0016F00002Pn55b"}

Output:"[{\"attributes\":{\"type\":\"Account\",\"url\":\"/services/data/v43.0/sobjects/Account/0016F00002Pn55bQAB\"},\"Id\":\"0016F00002Pn55bQAB\",\"IsDeleted\":false,\"Name\":\"Edge Communications\",\"Type\":\"Customer - Direct\",\"BillingStreet\":\"312 Constitution Place\\nAustin, TX 78767\\nUSA\",\"BillingCity\":\"Austin\",\"BillingState\":\"TX\",\"BillingAddress\":{\"city\":\"Austin\",\"country\":null,\"geocodeAccuracy\":null,\"latitude\":null,\"longitude\":null,\"postalCode\":null,\"state\":\"TX\",\"street\":\"312 Constitution Place\\nAustin, TX 78767\\nUSA\"},\"ShippingStreet\":\"312 Constitution Place\\nAustin, TX 78767\\nUSA\",\"ShippingAddress\":{\"city\":null,\"country\":null,\"geocodeAccuracy\":null,\"latitude\":null,\"longitude\":null,\"postalCode\":null,\"state\":null,\"street\":\"312 Constitution Place\\nAustin, TX 78767\\nUSA\"},\"Phone\":\"(512) 757-6000\",\"Fax\":\"(512) 757-9000\",\"AccountNumber\":\"CD451796\",\"Website\":\"http://edgecomm.com\",\"PhotoUrl\":\"/services/images/photo/0016F00002Pn55bQAB\",\"Sic\":\"6576\",\"Industry\":\"Electronics\",\"AnnualRevenue\":139000000,\"NumberOfEmployees\":1000,\"Ownership\":\"Public\",\"TickerSymbol\":\"EDGE\",\"Description\":\"Edge, founded in 1998, is a start-up based in Austin, TX. The company designs and manufactures a device to convert music from one digital format to another. Edge sells its product through retailers and its own website.\",\"Rating\":\"Hot\",\"OwnerId\":\"0056F00000999WQQAY\",\"CreatedDate\":\"2018-07-19T12:39:10.000+0000\",\"CreatedById\":\"0056F00000999WQQAY\",\"LastModifiedDate\":\"2018-07-19T12:39:10.000+0000\",\"LastModifiedById\":\"0056F00000999WQQAY\",\"SystemModstamp\":\"2018-07-19T12:39:10.000+0000\",\"LastViewedDate\":\"2018-07-28T12:57:30.000+0000\",\"LastReferencedDate\":\"2018-07-28T12:57:30.000+0000\",\"CleanStatus\":\"Pending\",\"CustomerPriority__c\":\"Medium\",\"SLA__c\":\"Silver\",\"Active__c\":\"Yes\",\"NumberofLocations__c\":2,\"UpsellOpportunity__c\":\"Maybe\",\"SLASerialNumber__c\":\"2657\",\"SLAExpirationDate__c\":\"2018-08-13\"}]"

public class LightningCustomLookupController{
     @AuraEnabled 
     public static List<sObject> fetchSobject(String searchKeyWord, String sObjectName,String condition) {
         
    
     String searchKey = '%'+searchKeyWord + '%';
     String query = 'SELECT Id, Name FROM '+sObjectName;
     system.debug('condition--------------------'+condition);
     if(sObjectName == 'Order'){
         query = 'SELECT Id, OrderNumber,Account.Name FROM '+sObjectName;
     }
      if(String.isNotBlank(condition)){
        query +=' WHERE '+condition+' LIMIT 100' ; 
      } else {
          query+=' LIMIT 100';
      }
      system.debug('query-----------------------'+query);
      List<sObject> returnList = Database.query(query);
      return returnList;
     }
    @AuraEnabled
    public static sObject getLookUpRecord(Id recordId, String objectName, Boolean isMediaSearch) {
        sObject sObj =  Schema.getGlobalDescribe().get(objectName).newSObject() ;
        if(recordId != null) {
            if(objectName == 'Order'){
                sObj = Database.query('SELECT Id, OrderNumber FROM '+objectName+' WHERE Id =:recordId ');
            } else{
                sObj = Database.query('SELECT Id, Name FROM '+objectName+' WHERE Id =:recordId ');

            }
        }
        return sObj;
    }
    
    @AuraEnabled
    public static List<Account> getRecords(String searchKey) {
        String tempSearchKey = searchKey + '%';
        String ObjectName = 'Account';
        String soql = 'SELECT Name, Type, Phone FROM ' + ObjectName +' WHERE  Name LIKE ' +'\'' + tempSearchKey 
                  +'\'  limit 10';
        system.debug('Query-----------'+soql);
        List<Account> accounts = database.query(soql);
        System.debug( 'accounts->' + accounts);
        return accounts;
    }
}
I need help with creating a field that auto-populates the “Standard Price” from the Product object into a field called “Base Price” in the Transactions custom object.
 
Use Case:
 
When a Transaction record is created, the Item Number should be looked up in the Product object "Product Code", then the "Standard Price" should be returned in the "Base Price" field
 
Example:
 
The transaction is created with item number 2200, we should look up the Product object and find the Product with Product code 2200.  Then we should return the standard price of $80.00 into the “Base Price” field.
public class ShowRelatedDataClass {

    // Properties
    private ID CaseId ;
    public List<String> items {get;set;}
    static Map<String,Map<Id,List<sObject>>> allvalues;
    public List<HealthCloudGA__EhrCondition__c> EHRConditions {get;set;}
    public List<HealthCloudGA__EhrObservation__c> EHRObservations {get;set;}
    public List<HealthCloudGA__EhrMedicationPrescription__c> EHRMedicationPrescriptions {get;set;}
    public List<HealthCloudGA__EhrMedicationStatement__c> EHRMedicationStatements {get;set;}
    
    // Constructor
    public ShowRelatedDataClass(ApexPages.StandardController controller) {
        caseId = ((Case)controller.getRecord()).Id;        
        case CaseRecord = [Select AccountId From Case Where Id = : caseId];
        
        EHRConditions = new List<HealthCloudGA__EhrCondition__c>();
        EHRConditions  = [Select Name From HealthCloudGA__EhrCondition__c Where HealthCloudGA__Account__c =: CaseRecord.AccountId];
        
        
        EHRObservations = new List<HealthCloudGA__EhrObservation__c>();
        EHRObservations = [Select Name From HealthCloudGA__EhrObservation__c Where HealthCloudGA__Account__c =: CaseRecord.AccountId];
        
        EHRMedicationPrescriptions  = new List<HealthCloudGA__EhrMedicationPrescription__c>();
        EHRMedicationPrescriptions  = [Select Name From HealthCloudGA__EhrMedicationPrescription__c Where HealthCloudGA__Account__c =: CaseRecord.AccountId];

        EHRMedicationStatements = new List<HealthCloudGA__EhrMedicationStatement__c>();
        EHRMedicationStatements = [Select Name From HealthCloudGA__EhrMedicationStatement__c Where HealthCloudGA__Account__c =: CaseRecord.AccountId];


    }
    
    // Method to create map of Data of different tables
    static  Map<Id,List<sObject>> parentmap(String object_name){
        String FieldSet = '';
        if(object_name == 'HealthCloudGA__CarePlanProblem__c')
            FieldSet = ' id,Name , HealthCloudGA__CarePlan__c ';
        if(object_name == 'HealthCloudGA__CarePlanGoal__c')
            FieldSet = ' Id, Name, HealthCloudGA__CarePlanProblem__c ';
        if(object_name  == 'Task')
            FieldSet = ' Id, Subject, HealthCloudGA__CarePlanGoal__c ';
        
        List<sObject> c2 =  Database.query('select '+FieldSet +' from ' + object_name );    
        Map<Id,List<sObject>> m2 = new  Map<Id,List<sObject>>();
        String parentid = '';
        for (sObject o2:c2) {
            parentid = null;
            if (object_name == 'HealthCloudGA__CarePlanProblem__c') {
                parentid = ((HealthCloudGA__CarePlanProblem__c) o2).HealthCloudGA__CarePlan__c;
            } 
            if (object_name == 'HealthCloudGA__CarePlanGoal__c') {
                parentid = ((HealthCloudGA__CarePlanGoal__c) o2).HealthCloudGA__CarePlanProblem__c;
            } 
            if (object_name == 'Task') {
                parentid = ((Task) o2).HealthCloudGA__CarePlanGoal__c ;
            }             
            if (parentid == null) continue;
            if (m2.containsKey(parentid)) {
                ((List<sObject>) m2.get(parentid)).add(o2);
            } else {
                m2.put(parentid, new List<sObject>{o2});
            }
        }
        return m2;
    }
    
    // Method to build pageblock Tables
    public  Component.Apex.PageBlockTable getHierarchy() {
        
        Map<Id,Case> c1 = new  Map<Id,Case>([select id, CaseNumber from Case Where Id = : caseId ]);      
        allvalues = new  Map<String,Map<Id,List<sObject>>>(); 
        allvalues.put('HealthCloudGA__CarePlanProblem__c',parentmap('HealthCloudGA__CarePlanProblem__c'));
        allvalues.put('HealthCloudGA__CarePlanGoal__c',parentmap('HealthCloudGA__CarePlanGoal__c'));
        allvalues.put('Task',parentmap('Task'));
        
        items = new List<String>();
        Component.Apex.PageBlockTable myTable = new  Component.Apex.PageBlockTable(var='item');
        myTable.expressions.value = '{!items}';
        
        Component.Apex.column clm = new Component.Apex.column(headerValue= 'Name'); 
        myTable.childComponents.add( clm );
        Component.Apex.OutputText outText = new Component.Apex.OutputText( );           
        outText.expressions.value = '{!item}';   
        outText.escape = false;   
        clm.childComponents.add( outText );     
        
        for (Id id1 :c1.keyset()) {
            Case o1 = (Case) c1.get(id1);
            items.add(o1.CaseNumber);
            getNodes('HealthCloudGA__CarePlanProblem__c',o1.id);
        }            
        return myTable;
    }
    
    // Method to add child data. 
    public void getNodes(String object_name,String parentid) {        
        String name = '';
        String id = '';        
        Map<Id,List<sObject>> map1 = (Map<Id,List<sObject>>) allvalues.get(object_name);      
        if (object_name == 'HealthCloudGA__CarePlanProblem__c') {
            if (map1.containsKey(parentid)) {
                List<HealthCloudGA__CarePlanProblem__c> lcob = (List<HealthCloudGA__CarePlanProblem__c>) map1.get(parentid);
                for (HealthCloudGA__CarePlanProblem__c cob:lcob) {
                    name = cob.name;
                    items.add('&nbsp;&nbsp;' + name);
                    getNodes('HealthCloudGA__CarePlanGoal__c',cob.id);
                    
                }
            }     
        } else if (object_name == 'HealthCloudGA__CarePlanGoal__c') {
                if (map1.containsKey(parentid)) {
                    List<HealthCloudGA__CarePlanGoal__c> lcob = (List<HealthCloudGA__CarePlanGoal__c>) map1.get(parentid);
                    for (HealthCloudGA__CarePlanGoal__c cob:lcob) {
                        name = cob.name;
                        items.add('&nbsp;&nbsp;&nbsp;&nbsp;' + name);
                        getNodes('Task',cob.id);
                    }
                }   
            } else if (object_name == 'Task') {
                if (map1.containsKey(parentid)) {
                    List<Task> lcob = (List<Task>) map1.get(parentid);
                    for (Task cob:lcob) {
                        name = cob.Subject;
                        items.add('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+name);
    }} } }}
If we have one related custom object(Folder) on lead which has industry picklist different values. We create custom setting and different records of custom setting and now one field checkbox -isactive.if industry value = technology on Folder object, records should be created automatically  with name of custom setting values where checkbox true and industry value should be associated with records
Hi Friends thanks in  advance,
I have 3 custom objects named ( object1__c, Object2__c, Object3__c) with the controller named (Checking). I had wrote  a code for dynamically adding of text fields when user enter add button on vfpage. I need  object1__c+Object2__c should be displayed in Object3__c . I have used jquery and javascript but it is not reflecting in new fields when I Click add button.
Thanks,
Swetha