• Deepak Singh 116
  • NEWBIE
  • 90 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 13
    Replies
I have an existing Salesforce custom object that I need to add 200 custom fields to.  The list of Field Label and Field Names are in a CSV file.  Is it possible to import and create the custom fields?  They will all be date fields.  I am a .NET developer.  I have not been able to find anything how to dynamically add a custom field to an object using the tooling API with C#.
I am having issue with the lightning component.
I am submitng to third party server using javascipt controller and my form response target is a IFRAME. This component is place on contact record page.
This working fine as expected when we hard reload the page every time but when i navigate to different contact without hard reloading the record page then IFRAME hasn't show the response.I have checked the the form has posted successfully every time but iframe not get updated.

Thanks in advance.  
Hi Experts ,
I want to show  "no item to display" in lightning Datatable when there is no data returns from controller.

 
Hi Experts,
Below is my code snippet. I am Passing Account as object when calliing this below batch . I want to optimize it becuase the update DML is repeated vey time for different objcet. Is there any way to just get the record as per objects passed and updated uing only one DML .
public with sharing class BatchApex implements Database.Batchable<SObject>,Database.stateful {
    String ObjectName=null;
    public BatchApex(String ObjectName) {
        this.ObjectName=ObjectName;    
    }
    public Database.QueryLocator start(Database.BatchableContext BC){
        String Query=null;
        if(ObjectName!=null && ObjectName=='Account'){
            Query='select Id,Name,abc__c from '+ObjectName+' Where abc__c=null';
        }else If(ObjectName!=null && ObjectName=='Contact'){
            Query='select Id,FirstName,LastName,abc__c,abcLn__c from '+ObjectName+' Where  ((abc__c=null and FirstName!=null) or (abcLn__c=null and LastName!=null))';  
        }else If(ObjectName!=null && ObjectName=='Lead'){
            Query='select Id,FirstName,LastName,abc__c,abcLn__c from '+ObjectName+' Where ((abc__c=null and FirstName!=null) or (abcLn__c=null and LastName!=null))';  
        }
        else If(ObjectName!=null && ObjectName=='opportunity'){
            Query='select id,Account.name,Name,abc__c,abcAn__c from '+ObjectName+' Where (abcAn__c=null and Accountid!=null) or abc__c=null';  
        }
        return Database.getQueryLocator(Query);
    }
    
    public void execute(Database.BatchableContext BC,List<SObject> Scope){
        if(ObjectName!=null && ObjectName=='Account'){
            List<Account> AccountList=(List<Account>)Scope; 
            List<Account> AccounttoUpdate= New List<Account>();
            for(Account acc:AccountList){
                if(acc.Name!=null && acc.abc__c==null){
                    acc.abc__c=generatorClass.getvalue(acc.Name);
                    AccounttoUpdate.add(acc);
                }
            }
            if(AccounttoUpdate.size()>0){
                Database.SaveResult[] results = Database.Update(AccounttoUpdate, false);
                for (database.SaveResult SR:results){
                    if(SR.isSuccess()){
                        
                        System.debug(sr.getId());
                        
                    }else {
                        for(Database.Error err:SR.errors){
                            System.debug(sr.getId());
                            System.debug(err.getFields());
                            System.debug(err.getMessage());
                            
                        }
                    } 
                }
            }
        }else if(ObjectName!=null && ObjectName=='Contact'){
            List<Contact> ContactList=(List<Contact>)Scope; 
            List<Contact> ContacttoUpdate= New List<Contact>();
            for(Contact con:ContactList){
                if(con.FirstName!=null && con.abc__c==null){
                    con.abc__c=generatorClass.getvalue(con.FirstName);
                }
                if(con.LastName!=null &&  con.abcLn__c==null){
                    con.abcLn__c=generatorClass.getvalue(con.LastName);
                }   
                ContacttoUpdate.add(con);
            }
            system.debug(ContacttoUpdate.size());
            if(ContacttoUpdate.size()>0){
                Database.SaveResult[] results = Database.Update(ContacttoUpdate, false);
                for (database.SaveResult SR:results){
                    if(SR.isSuccess()){
                        
                        System.debug(sr.getId());
                        
                    }else {
                        for(Database.Error err:SR.errors){
                            System.debug(sr.getId());
                            System.debug(err.getFields());
                            System.debug(err.getMessage());
                            
                        }
                    }
                } 
            }
        } else if(ObjectName!=null && ObjectName=='Lead'){
            List<Lead> LeadList=(List<Lead>)Scope; 
            List<Lead> LeadtoUpdate= New List<Lead>();
            for(Lead lead:LeadList){
                if(lead.FirstName!=null && lead.abc__c==null){
                    lead.abc__c=generatorClass.getvalue(lead.FirstName);
                }
                if(lead.LastName!=null && lead.abcLn__c==null){
                    lead.abcLn__c=generatorClass.getvalue(lead.LastName);
                }
                LeadtoUpdate.add(lead);
            }
            if(LeadtoUpdate.size()>0){
                Database.SaveResult[] results = Database.Update(LeadtoUpdate, false);
                for (database.SaveResult SR:results){
                    if(SR.isSuccess()){
                        
                        System.debug(sr.getId());
                        
                    }else {
                        for(Database.Error err:SR.errors){
                            System.debug(sr.getId());
                            System.debug(err.getFields());
                            System.debug(err.getMessage());
                        }
                    }
                    
                } 
            }
        }else if(ObjectName!=null && ObjectName=='opportunity'){
            List<opportunity> opportunityList=(List<opportunity>)Scope; 
            List<opportunity> opportunitytoUpdate= New List<opportunity>();
            for(opportunity op:opportunityList){
                if(op.Name!=null && op.abc__c==null){
                    op.abc__c=generatorClass.getvalue(op.Name);  
                }
                if(op.AccountId!=null && op.abcAn__c==null){
                    op.abcAn__c=generatorClass.getvalue(op.Account.name);
                }
                opportunitytoUpdate.add(op);
            }
            if(opportunitytoUpdate.size()>0){
                Database.SaveResult[] results = Database.Update(opportunitytoUpdate, false);
                for (database.SaveResult SR:results){
                    if(SR.isSuccess()){
                        
                        System.debug(sr.getId());
                        
                    }else {
                        for(Database.Error err:SR.errors){
                            System.debug(sr.getId());
                            System.debug(err.getFields());
                            System.debug(err.getMessage());
                            
                        }
                    }
                } 
            }
        }
        
    }
    public void finish(Database.BatchableContext BC){
        if(ObjectName!=null && ObjectName=='Account'){
            BatchApex SBA=new BatchApex('Contact');
            database.executeBatch(SBA,1500);
        }
        else if(ObjectName!=null && ObjectName=='Contact'){
            BatchApex SBA=new BatchApex('Lead');
            database.executeBatch(SBA,1500);
        }
        else if(ObjectName!=null && ObjectName=='Lead'){
            BatchApex SBA=new BatchApex('opportunity');
            database.executeBatch(SBA,1500);
        } else{
            system.debug('Values Account,COntact,Opportunity,Lead has been updated');
        }
        
    }
}
Please find my below batcjh class.In this batch i calling a future method from finish method which make a callout to external system.I read from the documentation that We can calll future method from finish method But while i call the future methid i get the error:
First error: Too many future calls: 1
global with sharing class errorinBatch implements Database.Batchable<SObject>,Database.stateful {
global set <String> log;
global database.QueryLocator start(Database.BatchableContext bc){
string query='select id,name,Description,CurrentGenerators__c from opportunity';
system.debug(database.getQueryLocator(query));
return database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc,List<SObject> scope){
System.debug(scope);
System.debug('====>>>>>'+scope.size());
//List<Opportunity> opp=new List<Opportunity>();
if(scope.size()>0){
for(Opportunity op:(List<Opportunity>)scope){
System.debug(op.Name);
op.Description=op.CurrentGenerators__c;
// opp.add(op);
}
}
database.SaveResult[] result=database.update(scope,false);
System.debug('====>Result'+result);
Integer rsize=result.size();
for(integer i=0;i<rsize;i++){
System.debug('for loop Block');
System.debug('====>Result[0]'+result[0]);
System.debug('=====>'+i);
System.debug('+++++>>'+scope[i].Id);
if(!result[i].isSuccess()){
log=new Set<String>();
log.add('Error in Opportunity'+scope[i].Id+'Error Message'+result[i].getErrors()[0].getMessage());
System.debug(log);
}
else {
system.debug('+++++>>> updated successfully');
}
}
}
global void finish (Database.BatchableContext bc){
Future_Schedule_Call_Example.show('cdeeuhwidhi');
}
}

Please help.

Thanks,
Deepak​​​​​​​
Hi ,
I have written the following batch which update the description from o field CurrentGenerators__c both the fields are on opportunity but when i execute this batch i get the error First error: List index out of bounds: 34.
Please help.

global with sharing class errorinBatch implements Database.Batchable<SObject>,Database.stateful {
global set <String> log;
global database.QueryLocator start(Database.BatchableContext bc){
string query='select id,name,Description,CurrentGenerators__c from opportunity';
system.debug(database.getQueryLocator(query));
return database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc,List<SObject> scope){
System.debug(scope);
System.debug('====>>>>>'+scope.size());
//List<Opportunity> opp=new List<Opportunity>();
if(scope.size()>0){
for(Opportunity op:(List<Opportunity>)scope){
System.debug(op.Name);
op.Description=op.CurrentGenerators__c;
// opp.add(op);
}
}
database.SaveResult[] result=database.update(scope,false);
System.debug('====>Result'+result);
Integer rsize=result.size();
for(integer i=0;i<=rsize;i++){
System.debug('for loop Block');
System.debug('====>Result[0]'+result[0]);
System.debug('=====>'+i);
System.debug('+++++>>'+scope[i].Id);
if(!result[i].isSuccess()){
log=new Set<String>();
log.add('Error in Opportunity'+scope[i].Id+'Error Message'+result[i].getErrors()[0].getMessage());
System.debug(log);
}
else {
system.debug('+++++>>> updated successfully');
}
}
}
global void Finish(Database.BatchableContext bc){
//System.debug(log);
}
}
 
I am getting error:-

Error: Jsonwrapclass Compile Error: Method does not exist or incorrect signature: void add(Jsonwrapclass.conlist) from the type List<Contact> at line 20 column 9

Controller
public with sharing class Jsonwrapclass {
public String jsonString {get;set;}
 public  Jsonwrapclass(){
 jsonString = prepareData();
 }
 private string prepareData()
{
acc a=new acc();
account acou=[select name,industry from account where id='0010K00001px8HpQAI'];
list<contact> conl=[select id,lastname from contact where accountid='0010K00001px8HpQAI'];
a.name=acou.name;
a.industry=acou.industry;
List<contact> lcllist=null;
for(contact co:conl){
conlist c=new conlist();
c.id=co.id;
c.lastname=co.lastname;
system.debug(c);
lcllist=new list<contact>();
lcllist.add(c);
}
system.debug(lcllist);

/* if(lcllist==null){
lcllist=new list<contact>();
lcllist.add(c);
}*/

//a.conlist=lcllist;
string s=system.JSON.serialize(a);
return s;
}

Public class acc{
string name {get; set;}
string industry {get; set;}
list<contact> conlist{get;set;}
}
public class conlist{
string id {get; set;}
string lastname{get; set;}

}
}
Hi,
Please suggest how to handle this type error in Apex.when a received blank value in response i get the error which is pasted below:-
Controller:-
public class Railway {
public string city            {get; set;}
public string result          {get; set;}
public JsonParser resset      {get; set;}

Public void invoke(){
string endpoint='https://indianrailways.p.rapidapi.com/findstations.php?station='+city;
Http http=new Http();
HttpRequest req=new HttpRequest ();
Req.setHeader('X-RapidAPI-Host', 'indianrailways.p.rapidapi.com');
Req.setHeader('X-RapidAPI-Key', 'b6aaeccc96msh12c221cffd99255p151d80jsn32a04d0da645');
req.setEndpoint(endpoint);
req.setMethod('GET');
HttpResponse res=http.send(req);
result=res.getBody();
if(result!=null || result!=''){
resset =(JsonParser)system.JSON.deserialize(result,JsonParser .class);
}
else
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter correct value'));
}
}

public class JsonParser{
        public list<stations> stations{get;set;}
    
    }
    public class stations{
        public String stationCode{get;set;}
        public String stationName{get;set;}
}
}

VF PAGE:-
<apex:page controller="Railway">
<apex:form >
<apex:inputText value="{!city}"/>
<apex:commandButton action="{!invoke}" value="Invoke" rerender="i"/> <br></br>
</apex:form>
<apex:pageBlock title="STATION NAMAE AND CODES" id="i">
<apex:pageBlockSection title="STATION NAMAE AND CODES" columns="4">
<apex:pageBlockTable value="{!resset.stations}" var="a"  rendered="{! !ISNULL(resset)}">
<apex:column headerValue="stationName" value="{!a.stationName}" />
<apex:column headerValue="stationCode" value="{!a.stationCode}"   />
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock> <br></br><br></br>
{!result} <br></br><br></br>
</apex:page>














ERROR:-
ystem.JSONException: Expected List<Railway.stations> but found "" at [line:1, column:2]
Error is in expression '{!invoke}' in component <apex:commandButton> in page irailway: Class.System.JSON.deserialize: line 15, column 1
Class.Railway.invoke: line 17, column 1
 
Hi,
I am unable to print array return by controller on VF page:-
Controller:-
public with sharing class generateStringArray {
    public list<String> generateStringArray{ get; set; }
    public static list<string> getgenerateStringArray(){
        Integer n=10;    
        list<string> myarray=new list<string>();
        for(integer i=0;i<=n;i++){
            myarray.add('Test'+i);
        }
        return myarray;
    } 
}

VF page:-
<apex:page Controller="generateStringArray" showHeader="true" sidebar="false">
    <h1>List</h1>
    
        <apex:repeat value="{!generateStringArray}" var="string" id="theRepeat">
        <apex:outputText value="{!string}" id="theValue"/><br/>
        </apex:repeat>

  
</apex:page>

 
I am new in integration. Please find the below JSON sample request.I need to create JSON like this and send request to external system and need to save the reponse from external system.Pleae Help.
-------------------------------------------------------
 REQUEST DATA
-------------------------------------------------------
{
  "userCredentials": {
    "userId": "Sample USer",
    "userPassword": "PAssword",
    "source": "MOBILE",
    "sourceId": "358156078472543",
    "initiatedBy": "ADMIN",
    "deviceName": "SM-J200G",
    "deviceVersion": "22",
    "sourceVersion": "6.0.0.1",
    "latitude": "28.61929",
    "longitude": "77.3784",
    "address": "A-118, A Block"
  },
  "stageLeadDetails": {
    "txnType": "LEAD",
    "loanType": "NEW",
    "loanSubType": "NOR_NA",
    "operationType": "LEAD",
    "monthlyIncome": 25000,
    "obligation": 0,
    "dafaultEmi": 0,
    "dafaultLoanAmount": 50000,
    "dafaultFoir": 0,
    "mobileAppVersion": "6.0.0.1",
    "salesId": "MADMIN911",
    "salesSequenceNo": 911,
    "loanPurpose": "HL",
    "loanPurposeDesc": "Home Loan",
    "lifeInsurance": "Y",
    "loanProductsInsurance": "Y",
    "propertyInsurance": "Y",
    "leadFinalScore": 0,
    "mobileDealId": 911,
    "imeiNumber": "860998036081713",
    "amountRequired": 50000,
    "finalRate": 15,
    "longitude": "28.6192979",
    "latitude": "77.3784688",
    "locationAddress": "A-118, A Block, Sector 63, Noida, Uttar Pradesh 201307, India Noida Uttar Pradesh India 201307 A-118",
    "tenure": 120,
    "product": "HC",
    "productDesc": "HOME CONSTRUCTION LOAN",
    "scheme": 6,
    "schemeDesc": "HOME CONSTRUCTION DOCUMENTED INCOME",
    "rateType": "E",
    "branchId": "7",
    "leadGenerationCity": "UDAIPUR",
    "apf_napf": "",
    "iir": 3.23,
    "foir": 3.23,
    "emi": 807,
    "nearestBranch": 1,
    "leadMakerId": "ADMIN",
    "leadGenerationDate": "2018-10-16",
    "leadMakerDate": "2018-10-16",
    "leadGeneratedRm": "ADMIN",
    "dealSourceType": "ADVERTISE",
    "dealSourceName": "HGCH",
    "makerDate": "2018-10-16",
    "propertyCurrentStatus": "",
    "householdMonthlyIncome": 0,
    "customerRoleList": [
      {
        "salesId": "MADMIN911",
        "customerRole": "PRAPPL",
        "makerDate": "2018-10-16",
        "customerDtl": {
          "salesCustomerId": "3",
          "salesId": "MADMIN911",
          "existingCustomerId": 0,
          "customerExistingType": "N",
          "salutation": "DR",
          "cibilId": "",
          "lastBureau": "NA",
          "photoStream": "",
          "customerConstitution": "SEASDINCO",
          "customerConstitutionDesc": "SELF EMPLOYED ASSESSED INCOME",
          "residentialStatus": "RESIDENT",
          "castCategory": "ST",
          "castCategoryDesc": "SCHEDULE TRIBE(ST)",
          "firstName": "ABHI",
          "middleName": "",
          "lastName": "SINGH",
          "gender": "MALE",
          "genderDesc": "MALE",
          "emailId": "",
          "alternateEmailId": "",
          "customerDOB": "1978-01-07",
          "customerCategory": "GOLD",
          "customerCategoryDesc": "GOLD",
          "maritalStatus": "S",
          "maritalStatusDesc": "SINGLE",
          "community": "",
          "husbandName": "",
          "naregaNo": "",
          "educationDetail": "PRO",
          "educationDetailDesc": "PROFESSIONAL",
          "isMobileVerified": "N",
          "isEmailVerified": "N",
          "isPanVerified": "",
          "pan": "BODPM4246E",
          "drivingLicense": "",
          "voterId": "",
          "passportNumber": "",
          "aadharNumber": "",
          "customerType": "I",
          "turnover": 0,
          "monthlyIncome": 25000,
          "fatherHusbandName": "FATHER",
          "motherName": "MOTHER",
          "guaranteeAmount": 0,
          "numberOfDependent": 0,
          "makerDate": "2018-10-16",
          "stageAddressDtlList": [
            {
              "salesId": "MADMIN911",
              "bpType": "CS",
              "addressType": "REI",
              "addressTypeDesc": "CURRENT RESIDENCE",
              "addressLine1": "ADDRESS",
              "addressLine2": "",
              "addressLine3": "",
              "pincode": "110011",
              "tehsil": 32574,
              "tehsilDesc": "Udyog Bhawan S.O",
              "district": 122,
              "districtDesc": "CENTRAL DELHI",
              "state": 10,
              "stateDesc": "DELHI",
              "country": 1,
              "countryDesc": "INDIA",
              "stayingTogether": "",
              "addressDetail": "REL",
              "monthlyRent": 0,
              "stdCode": "",
              "phoneNo": "",
              "mobileNo": "8802738748",
              "communicationAddress": "Y",
              "landmark": "LANDMARK",
              "areaName": "",
              "noOfRooms": 0,
              "periodStay": 0,
              "noOfYears": 5,
              "noOfMonths": 0,
              "plotNo": "",
              "floorNo": "",
              "makerDate": "2018-10-16"
            }
          ],
          
        }
      }
    ],
   
    "deviceName": "SM-J200G",
    "deviceVersion": "22"
  },
  "leadSubmissionType": "LEAD"
}
------------------------------------------------------
 RESPONSE DATA 
-------------------------------------------------------
{"operationStatus":"1","operationMessage":"Operation Completed Successfully. ","salesLeadId":"19761","applicationForm":null,"loanPurposeMakerDate":"2019-01-07 16:40:50"}
can we use formula field in SOQL query?If yes, please give a example. 
Thanks.
Hi,
I have to two custom object Building__c and lease__c bothe objects have a firld name Expiry date.Building__c is parent and lease__c is child in look relatioship.I can not create MD relatioship between them because of some reason.now i want a process builder which pick the minimum expiry date from the lease records and upadte by building__c expiry date.

​Thanks in advence!
Hi,
I have to two custom object Building__c and lease__c bothe objects have a firld name Expiry date.Building__c is parent and lease__c is child in look relatioship.I can not create MD relatioship between them because of some reason.now i want a trigger which pick the minimum expiry date from the lease records and upadte by building__c expiry date.

Thanks in advence!
I have two status picklist field one at contact and one at account.Both the picklist have the same value (Active,Inactive,closed).Now i want when i update the status on account then the contactstatus is automatically update as account. 
i have already a trigger on customer_project_c which is follows-

public with sharing class RBI_CustomerProjectTriggerHandler {
  public static boolean firstRun = true;
  public ID  CusRecType = [SELECT Id FROM RecordType WHERE DeveloperName = 'Customer'].Id;
  public ID RbiRecType = [SELECT Id FROM RecordType WHERE DeveloperName = 'RBI'].Id;
  public list<Account> Acclist=[Select Id , Weightage_Electrification_Sanitation__c,Weightage_Basement__c,
                      Weightage_Excavaton_of_Footings__c, Weightage_Finishing__c,
                      Weightage_RCC_Slab_Casting__c,RecordTypeId,Weightage_Masonary__c from Account WHERE RecordTypeId=:RbiRecType OR RecordTypeId=:CusRecType];
       
                    
  // Before Insert Trigger
  public void OnBeforeInsert(list<Customer_Projects__c> Cusprojectlist){ 
    if(Cusprojectlist!=null && Cusprojectlist.size()>0){
      for(Customer_Projects__c cusproj : Cusprojectlist){
          for(Account Acc : Acclist){
            if((cusproj.Weightage_Type__c == 'Realty BI') && (Acc.RecordTypeId==RbiRecType)) {
              cusproj.Weightage_Basement__c=Acc.Weightage_Basement__c;
                cusproj.Weightage_Electrification_Sanitation__c=Acc.Weightage_Electrification_Sanitation__c;
                cusproj.Weightage_Excavaton_of_Footings__c=Acc.Weightage_Excavaton_of_Footings__c;
                cusproj.Weightage_Finishing__c=Acc.Weightage_Finishing__c; 
                cusproj.Weightage_RCC_Slab_Casting__c=Acc.Weightage_RCC_Slab_Casting__c;
                cusproj.Weightage_Masonary__c=Acc.Weightage_Masonary__c; 
          }
                else if((cusproj.Weightage_Type__c == 'Customer') && (Acc.RecordTypeId ==CusRecType) && (Acc.Id == cusproj.AccountId__c)) { 
                  cusproj.Weightage_Basement__c=Acc.Weightage_Basement__c;
                cusproj.Weightage_Electrification_Sanitation__c=Acc.Weightage_Electrification_Sanitation__c;
                cusproj.Weightage_Excavaton_of_Footings__c=Acc.Weightage_Excavaton_of_Footings__c;
                cusproj.Weightage_Finishing__c=Acc.Weightage_Finishing__c; 
                cusproj.Weightage_RCC_Slab_Casting__c=Acc.Weightage_RCC_Slab_Casting__c;
                cusproj.Weightage_Masonary__c=Acc.Weightage_Masonary__c;
                }
            }
        }
    }
  }
  //OnBeforeUpdate trigger
  public void OnBeforeUpdate(list<Customer_Projects__c> CusprojectNew, list<Customer_Projects__c> CusprojectOld, Map<Id, Customer_Projects__c> ObjectMap){
    for(Customer_Projects__c cusprj : CusprojectNew){
      if(cusprj.Id == ObjectMap.get(cusprj.Id).Id && ObjectMap.get(cusprj.Id).Weightage_Type__c != cusprj.Weightage_Type__c){
        for(Account Acc1 : Acclist){
            if((cusprj.Weightage_Type__c == 'Customer') && (cusprj.AccountId__c==Acc1.Id) && (Acc1.RecordTypeId ==CusRecType) ) { 
              cusprj.Weightage_Basement__c=Acc1.Weightage_Basement__c;
                cusprj.Weightage_Electrification_Sanitation__c=Acc1.Weightage_Electrification_Sanitation__c;
                cusprj.Weightage_Excavaton_of_Footings__c=Acc1.Weightage_Excavaton_of_Footings__c;
                cusprj.Weightage_Finishing__c=Acc1.Weightage_Finishing__c; 
                cusprj.Weightage_RCC_Slab_Casting__c=Acc1.Weightage_RCC_Slab_Casting__c;
                cusprj.Weightage_Masonary__c=Acc1.Weightage_Masonary__c;
              }
              else if((cusprj.Weightage_Type__c == 'Realty BI') && (Acc1.RecordTypeId==RbiRecType)) {
                cusprj.Weightage_Basement__c=Acc1.Weightage_Basement__c;
                  cusprj.Weightage_Electrification_Sanitation__c=Acc1.Weightage_Electrification_Sanitation__c;
                  cusprj.Weightage_Excavaton_of_Footings__c=Acc1.Weightage_Excavaton_of_Footings__c;
                  cusprj.Weightage_Finishing__c=Acc1.Weightage_Finishing__c; 
                  cusprj.Weightage_RCC_Slab_Casting__c=Acc1.Weightage_RCC_Slab_Casting__c;
                  cusprj.Weightage_Masonary__c=Acc1.Weightage_Masonary__c;
              }
            }
      }
    }
  }
}
now i want to modify this and email trigger  functionality which fired a mail when a customer project created under account and its project_status__c='PMR' (this status of  project is custom field on customer_project__c). I have a textbox of group mail where , emails are inserted and seprated by comma ",". so i need a trigger which fire mail to group mail of particular customer which is linked to project.:-

Project Object: customer_project__c
Relation with Account is Mater-Detail
Custom Field on contacts: Group_email and a check box "Primary"   this group mail is entered where primary check box is checked.
this both contact and customer project is under accont

It urgent please help me  soon a possible.
Hi,  I am very new in salesforce developement . I need a trigger which fired a mail when a customer project created under account. I have a text of group mail where , emails are inserted seprated by comma ",". so i need a trigger which fire mail to group mail of particular customer which is linked to project.
Hi ,
I have written the following batch which update the description from o field CurrentGenerators__c both the fields are on opportunity but when i execute this batch i get the error First error: List index out of bounds: 34.
Please help.

global with sharing class errorinBatch implements Database.Batchable<SObject>,Database.stateful {
global set <String> log;
global database.QueryLocator start(Database.BatchableContext bc){
string query='select id,name,Description,CurrentGenerators__c from opportunity';
system.debug(database.getQueryLocator(query));
return database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc,List<SObject> scope){
System.debug(scope);
System.debug('====>>>>>'+scope.size());
//List<Opportunity> opp=new List<Opportunity>();
if(scope.size()>0){
for(Opportunity op:(List<Opportunity>)scope){
System.debug(op.Name);
op.Description=op.CurrentGenerators__c;
// opp.add(op);
}
}
database.SaveResult[] result=database.update(scope,false);
System.debug('====>Result'+result);
Integer rsize=result.size();
for(integer i=0;i<=rsize;i++){
System.debug('for loop Block');
System.debug('====>Result[0]'+result[0]);
System.debug('=====>'+i);
System.debug('+++++>>'+scope[i].Id);
if(!result[i].isSuccess()){
log=new Set<String>();
log.add('Error in Opportunity'+scope[i].Id+'Error Message'+result[i].getErrors()[0].getMessage());
System.debug(log);
}
else {
system.debug('+++++>>> updated successfully');
}
}
}
global void Finish(Database.BatchableContext bc){
//System.debug(log);
}
}
 
I am getting error:-

Error: Jsonwrapclass Compile Error: Method does not exist or incorrect signature: void add(Jsonwrapclass.conlist) from the type List<Contact> at line 20 column 9

Controller
public with sharing class Jsonwrapclass {
public String jsonString {get;set;}
 public  Jsonwrapclass(){
 jsonString = prepareData();
 }
 private string prepareData()
{
acc a=new acc();
account acou=[select name,industry from account where id='0010K00001px8HpQAI'];
list<contact> conl=[select id,lastname from contact where accountid='0010K00001px8HpQAI'];
a.name=acou.name;
a.industry=acou.industry;
List<contact> lcllist=null;
for(contact co:conl){
conlist c=new conlist();
c.id=co.id;
c.lastname=co.lastname;
system.debug(c);
lcllist=new list<contact>();
lcllist.add(c);
}
system.debug(lcllist);

/* if(lcllist==null){
lcllist=new list<contact>();
lcllist.add(c);
}*/

//a.conlist=lcllist;
string s=system.JSON.serialize(a);
return s;
}

Public class acc{
string name {get; set;}
string industry {get; set;}
list<contact> conlist{get;set;}
}
public class conlist{
string id {get; set;}
string lastname{get; set;}

}
}
Hi,
Please suggest how to handle this type error in Apex.when a received blank value in response i get the error which is pasted below:-
Controller:-
public class Railway {
public string city            {get; set;}
public string result          {get; set;}
public JsonParser resset      {get; set;}

Public void invoke(){
string endpoint='https://indianrailways.p.rapidapi.com/findstations.php?station='+city;
Http http=new Http();
HttpRequest req=new HttpRequest ();
Req.setHeader('X-RapidAPI-Host', 'indianrailways.p.rapidapi.com');
Req.setHeader('X-RapidAPI-Key', 'b6aaeccc96msh12c221cffd99255p151d80jsn32a04d0da645');
req.setEndpoint(endpoint);
req.setMethod('GET');
HttpResponse res=http.send(req);
result=res.getBody();
if(result!=null || result!=''){
resset =(JsonParser)system.JSON.deserialize(result,JsonParser .class);
}
else
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter correct value'));
}
}

public class JsonParser{
        public list<stations> stations{get;set;}
    
    }
    public class stations{
        public String stationCode{get;set;}
        public String stationName{get;set;}
}
}

VF PAGE:-
<apex:page controller="Railway">
<apex:form >
<apex:inputText value="{!city}"/>
<apex:commandButton action="{!invoke}" value="Invoke" rerender="i"/> <br></br>
</apex:form>
<apex:pageBlock title="STATION NAMAE AND CODES" id="i">
<apex:pageBlockSection title="STATION NAMAE AND CODES" columns="4">
<apex:pageBlockTable value="{!resset.stations}" var="a"  rendered="{! !ISNULL(resset)}">
<apex:column headerValue="stationName" value="{!a.stationName}" />
<apex:column headerValue="stationCode" value="{!a.stationCode}"   />
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock> <br></br><br></br>
{!result} <br></br><br></br>
</apex:page>














ERROR:-
ystem.JSONException: Expected List<Railway.stations> but found "" at [line:1, column:2]
Error is in expression '{!invoke}' in component <apex:commandButton> in page irailway: Class.System.JSON.deserialize: line 15, column 1
Class.Railway.invoke: line 17, column 1
 
I have an existing Salesforce custom object that I need to add 200 custom fields to.  The list of Field Label and Field Names are in a CSV file.  Is it possible to import and create the custom fields?  They will all be date fields.  I am a .NET developer.  I have not been able to find anything how to dynamically add a custom field to an object using the tooling API with C#.
Hi,
I am unable to print array return by controller on VF page:-
Controller:-
public with sharing class generateStringArray {
    public list<String> generateStringArray{ get; set; }
    public static list<string> getgenerateStringArray(){
        Integer n=10;    
        list<string> myarray=new list<string>();
        for(integer i=0;i<=n;i++){
            myarray.add('Test'+i);
        }
        return myarray;
    } 
}

VF page:-
<apex:page Controller="generateStringArray" showHeader="true" sidebar="false">
    <h1>List</h1>
    
        <apex:repeat value="{!generateStringArray}" var="string" id="theRepeat">
        <apex:outputText value="{!string}" id="theValue"/><br/>
        </apex:repeat>

  
</apex:page>

 
I am new in integration. Please find the below JSON sample request.I need to create JSON like this and send request to external system and need to save the reponse from external system.Pleae Help.
-------------------------------------------------------
 REQUEST DATA
-------------------------------------------------------
{
  "userCredentials": {
    "userId": "Sample USer",
    "userPassword": "PAssword",
    "source": "MOBILE",
    "sourceId": "358156078472543",
    "initiatedBy": "ADMIN",
    "deviceName": "SM-J200G",
    "deviceVersion": "22",
    "sourceVersion": "6.0.0.1",
    "latitude": "28.61929",
    "longitude": "77.3784",
    "address": "A-118, A Block"
  },
  "stageLeadDetails": {
    "txnType": "LEAD",
    "loanType": "NEW",
    "loanSubType": "NOR_NA",
    "operationType": "LEAD",
    "monthlyIncome": 25000,
    "obligation": 0,
    "dafaultEmi": 0,
    "dafaultLoanAmount": 50000,
    "dafaultFoir": 0,
    "mobileAppVersion": "6.0.0.1",
    "salesId": "MADMIN911",
    "salesSequenceNo": 911,
    "loanPurpose": "HL",
    "loanPurposeDesc": "Home Loan",
    "lifeInsurance": "Y",
    "loanProductsInsurance": "Y",
    "propertyInsurance": "Y",
    "leadFinalScore": 0,
    "mobileDealId": 911,
    "imeiNumber": "860998036081713",
    "amountRequired": 50000,
    "finalRate": 15,
    "longitude": "28.6192979",
    "latitude": "77.3784688",
    "locationAddress": "A-118, A Block, Sector 63, Noida, Uttar Pradesh 201307, India Noida Uttar Pradesh India 201307 A-118",
    "tenure": 120,
    "product": "HC",
    "productDesc": "HOME CONSTRUCTION LOAN",
    "scheme": 6,
    "schemeDesc": "HOME CONSTRUCTION DOCUMENTED INCOME",
    "rateType": "E",
    "branchId": "7",
    "leadGenerationCity": "UDAIPUR",
    "apf_napf": "",
    "iir": 3.23,
    "foir": 3.23,
    "emi": 807,
    "nearestBranch": 1,
    "leadMakerId": "ADMIN",
    "leadGenerationDate": "2018-10-16",
    "leadMakerDate": "2018-10-16",
    "leadGeneratedRm": "ADMIN",
    "dealSourceType": "ADVERTISE",
    "dealSourceName": "HGCH",
    "makerDate": "2018-10-16",
    "propertyCurrentStatus": "",
    "householdMonthlyIncome": 0,
    "customerRoleList": [
      {
        "salesId": "MADMIN911",
        "customerRole": "PRAPPL",
        "makerDate": "2018-10-16",
        "customerDtl": {
          "salesCustomerId": "3",
          "salesId": "MADMIN911",
          "existingCustomerId": 0,
          "customerExistingType": "N",
          "salutation": "DR",
          "cibilId": "",
          "lastBureau": "NA",
          "photoStream": "",
          "customerConstitution": "SEASDINCO",
          "customerConstitutionDesc": "SELF EMPLOYED ASSESSED INCOME",
          "residentialStatus": "RESIDENT",
          "castCategory": "ST",
          "castCategoryDesc": "SCHEDULE TRIBE(ST)",
          "firstName": "ABHI",
          "middleName": "",
          "lastName": "SINGH",
          "gender": "MALE",
          "genderDesc": "MALE",
          "emailId": "",
          "alternateEmailId": "",
          "customerDOB": "1978-01-07",
          "customerCategory": "GOLD",
          "customerCategoryDesc": "GOLD",
          "maritalStatus": "S",
          "maritalStatusDesc": "SINGLE",
          "community": "",
          "husbandName": "",
          "naregaNo": "",
          "educationDetail": "PRO",
          "educationDetailDesc": "PROFESSIONAL",
          "isMobileVerified": "N",
          "isEmailVerified": "N",
          "isPanVerified": "",
          "pan": "BODPM4246E",
          "drivingLicense": "",
          "voterId": "",
          "passportNumber": "",
          "aadharNumber": "",
          "customerType": "I",
          "turnover": 0,
          "monthlyIncome": 25000,
          "fatherHusbandName": "FATHER",
          "motherName": "MOTHER",
          "guaranteeAmount": 0,
          "numberOfDependent": 0,
          "makerDate": "2018-10-16",
          "stageAddressDtlList": [
            {
              "salesId": "MADMIN911",
              "bpType": "CS",
              "addressType": "REI",
              "addressTypeDesc": "CURRENT RESIDENCE",
              "addressLine1": "ADDRESS",
              "addressLine2": "",
              "addressLine3": "",
              "pincode": "110011",
              "tehsil": 32574,
              "tehsilDesc": "Udyog Bhawan S.O",
              "district": 122,
              "districtDesc": "CENTRAL DELHI",
              "state": 10,
              "stateDesc": "DELHI",
              "country": 1,
              "countryDesc": "INDIA",
              "stayingTogether": "",
              "addressDetail": "REL",
              "monthlyRent": 0,
              "stdCode": "",
              "phoneNo": "",
              "mobileNo": "8802738748",
              "communicationAddress": "Y",
              "landmark": "LANDMARK",
              "areaName": "",
              "noOfRooms": 0,
              "periodStay": 0,
              "noOfYears": 5,
              "noOfMonths": 0,
              "plotNo": "",
              "floorNo": "",
              "makerDate": "2018-10-16"
            }
          ],
          
        }
      }
    ],
   
    "deviceName": "SM-J200G",
    "deviceVersion": "22"
  },
  "leadSubmissionType": "LEAD"
}
------------------------------------------------------
 RESPONSE DATA 
-------------------------------------------------------
{"operationStatus":"1","operationMessage":"Operation Completed Successfully. ","salesLeadId":"19761","applicationForm":null,"loanPurposeMakerDate":"2019-01-07 16:40:50"}
Hi,
I have to two custom object Building__c and lease__c bothe objects have a firld name Expiry date.Building__c is parent and lease__c is child in look relatioship.I can not create MD relatioship between them because of some reason.now i want a trigger which pick the minimum expiry date from the lease records and upadte by building__c expiry date.

Thanks in advence!
I have two status picklist field one at contact and one at account.Both the picklist have the same value (Active,Inactive,closed).Now i want when i update the status on account then the contactstatus is automatically update as account. 
i have already a trigger on customer_project_c which is follows-

public with sharing class RBI_CustomerProjectTriggerHandler {
  public static boolean firstRun = true;
  public ID  CusRecType = [SELECT Id FROM RecordType WHERE DeveloperName = 'Customer'].Id;
  public ID RbiRecType = [SELECT Id FROM RecordType WHERE DeveloperName = 'RBI'].Id;
  public list<Account> Acclist=[Select Id , Weightage_Electrification_Sanitation__c,Weightage_Basement__c,
                      Weightage_Excavaton_of_Footings__c, Weightage_Finishing__c,
                      Weightage_RCC_Slab_Casting__c,RecordTypeId,Weightage_Masonary__c from Account WHERE RecordTypeId=:RbiRecType OR RecordTypeId=:CusRecType];
       
                    
  // Before Insert Trigger
  public void OnBeforeInsert(list<Customer_Projects__c> Cusprojectlist){ 
    if(Cusprojectlist!=null && Cusprojectlist.size()>0){
      for(Customer_Projects__c cusproj : Cusprojectlist){
          for(Account Acc : Acclist){
            if((cusproj.Weightage_Type__c == 'Realty BI') && (Acc.RecordTypeId==RbiRecType)) {
              cusproj.Weightage_Basement__c=Acc.Weightage_Basement__c;
                cusproj.Weightage_Electrification_Sanitation__c=Acc.Weightage_Electrification_Sanitation__c;
                cusproj.Weightage_Excavaton_of_Footings__c=Acc.Weightage_Excavaton_of_Footings__c;
                cusproj.Weightage_Finishing__c=Acc.Weightage_Finishing__c; 
                cusproj.Weightage_RCC_Slab_Casting__c=Acc.Weightage_RCC_Slab_Casting__c;
                cusproj.Weightage_Masonary__c=Acc.Weightage_Masonary__c; 
          }
                else if((cusproj.Weightage_Type__c == 'Customer') && (Acc.RecordTypeId ==CusRecType) && (Acc.Id == cusproj.AccountId__c)) { 
                  cusproj.Weightage_Basement__c=Acc.Weightage_Basement__c;
                cusproj.Weightage_Electrification_Sanitation__c=Acc.Weightage_Electrification_Sanitation__c;
                cusproj.Weightage_Excavaton_of_Footings__c=Acc.Weightage_Excavaton_of_Footings__c;
                cusproj.Weightage_Finishing__c=Acc.Weightage_Finishing__c; 
                cusproj.Weightage_RCC_Slab_Casting__c=Acc.Weightage_RCC_Slab_Casting__c;
                cusproj.Weightage_Masonary__c=Acc.Weightage_Masonary__c;
                }
            }
        }
    }
  }
  //OnBeforeUpdate trigger
  public void OnBeforeUpdate(list<Customer_Projects__c> CusprojectNew, list<Customer_Projects__c> CusprojectOld, Map<Id, Customer_Projects__c> ObjectMap){
    for(Customer_Projects__c cusprj : CusprojectNew){
      if(cusprj.Id == ObjectMap.get(cusprj.Id).Id && ObjectMap.get(cusprj.Id).Weightage_Type__c != cusprj.Weightage_Type__c){
        for(Account Acc1 : Acclist){
            if((cusprj.Weightage_Type__c == 'Customer') && (cusprj.AccountId__c==Acc1.Id) && (Acc1.RecordTypeId ==CusRecType) ) { 
              cusprj.Weightage_Basement__c=Acc1.Weightage_Basement__c;
                cusprj.Weightage_Electrification_Sanitation__c=Acc1.Weightage_Electrification_Sanitation__c;
                cusprj.Weightage_Excavaton_of_Footings__c=Acc1.Weightage_Excavaton_of_Footings__c;
                cusprj.Weightage_Finishing__c=Acc1.Weightage_Finishing__c; 
                cusprj.Weightage_RCC_Slab_Casting__c=Acc1.Weightage_RCC_Slab_Casting__c;
                cusprj.Weightage_Masonary__c=Acc1.Weightage_Masonary__c;
              }
              else if((cusprj.Weightage_Type__c == 'Realty BI') && (Acc1.RecordTypeId==RbiRecType)) {
                cusprj.Weightage_Basement__c=Acc1.Weightage_Basement__c;
                  cusprj.Weightage_Electrification_Sanitation__c=Acc1.Weightage_Electrification_Sanitation__c;
                  cusprj.Weightage_Excavaton_of_Footings__c=Acc1.Weightage_Excavaton_of_Footings__c;
                  cusprj.Weightage_Finishing__c=Acc1.Weightage_Finishing__c; 
                  cusprj.Weightage_RCC_Slab_Casting__c=Acc1.Weightage_RCC_Slab_Casting__c;
                  cusprj.Weightage_Masonary__c=Acc1.Weightage_Masonary__c;
              }
            }
      }
    }
  }
}
now i want to modify this and email trigger  functionality which fired a mail when a customer project created under account and its project_status__c='PMR' (this status of  project is custom field on customer_project__c). I have a textbox of group mail where , emails are inserted and seprated by comma ",". so i need a trigger which fire mail to group mail of particular customer which is linked to project.:-

Project Object: customer_project__c
Relation with Account is Mater-Detail
Custom Field on contacts: Group_email and a check box "Primary"   this group mail is entered where primary check box is checked.
this both contact and customer project is under accont

It urgent please help me  soon a possible.
Hi,  I am very new in salesforce developement . I need a trigger which fired a mail when a customer project created under account. I have a text of group mail where , emails are inserted seprated by comma ",". so i need a trigger which fire mail to group mail of particular customer which is linked to project.