• kali charan
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 10
    Replies
Hi everyone,
I want to write the batch class.The issue is in that notes and attachment section i have to convert the attachment type file type using the batch class.How can i do it.If there is any code it is much more appreciable.
HI everyone,

   I have struct with one of the requirement that i have the parent account and multiple child contacts and in the parent account i have the amount field that is populated from the child amount .If the parent amount has 25 and again i have inserted new child contact with 30 .when i have deleted the 30 amount record from contact it should get update as previous 25 in the parent amount Ihave written the trigger for insert and update and am not getting for delete .

Please help me how to write the trigger for delete functionality using trigger ,thanks.
Hi everyone,

    I have written the trigger .In that i have a list of contacts and in that i have number field amount.I have multiple amounts and ia want to find the least amount value and it a check box should be populated on tha account aobject.please suggest me in this scenario.

Thanks.
 
Hi everyone,

   I have written the code for contact,and i have the scenario like for the account if the first child is inserted the amount field of contact should be automatically populated to the parent amount field of account and if the next contact is inserted the check box of the account field should be checked and amount is less with the previous contact it should check the check box of lesser amout.

I am getting the error like

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger UpdateAmount caused an unexpected exception, contact your administrator: UpdateAmount: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.UpdateAmount: line 18, column 1

Please fix the issues and if any modifications required.Please help me.

trigger UpdateAmount on Contact (after insert, after update) {
  Map<ID, Account> parentAccs = new Map<ID, Account>(); 
  List<Id> listIds = new List<Id>();
  List<Account> updatedparentAccs = new List<Account>();
  List<contact> COnIds= new List<contact>();
  
   for (contact childObj : Trigger.new) {
    listIds.add(childObj.AccountID);
  }

  parentAccs = new Map<Id, account>([SELECT id, Parent_amount__c,Greater_amount__c,Lesser_Amount__c,Name,(SELECT ID, Amount__c FROM contacts) FROM Account WHERE ID IN :listIds]);
  system.debug('%%%%%%%%%%%'+parentAccs);
  COnIds = [select id,AccountID from contact where AccountID IN :listIds];
  Account myParentOpp;
  
  for (contact con: Trigger.new){
     myParentOpp = parentAccs.get(con.AccountID);
     myParentOpp.Parent_amount__c= con.Amount__c;
     if(COnIds.size()>1 && con.Amount__c>COnIds[0].Amount__c){
     myParentOpp.Greater_Amount__c = true;
     }
     
    updatedparentAccs.add(myParentOpp);
    }
    

  if(!updatedparentAccs.isEmpty()){
  update updatedparentAccs;
  }

}

Thanks.
Hi everyone,

   I am newbie to salesforce and i want help to update the parent account of amount field when ever the contact of amount field is inserted or updated.and i have the scenario like when ever the contact is created or updated the amount field of account should be auto populated this is the first scenario. The second scenario is when the 2nd contact is created if the amount field is greater the first amount the greater amount field should be populated on the account amount field. The 3rd scenario is there are two check boxes greater amount and lesser amount in the account object this should be populated with the latest contact whether it should be greater or lesser than the previous account.

The fields are
Account object:
Parent_amount__c = Text field
Greater_amount__c = checkbox
Lesser_Amount__c = checkbox

Contact object:
Amount__c 

I have written some code only for update thing and please help me for second and third scenarios.

The 1st scenario is also giving error for me.

trigger UpdateAmount on Contact (after insert, after update) { //You want it on update too, right?
  Map<ID, Account> parentOpps = new Map<ID, Account>(); //Making it a map instead of list for easier lookup
  List<Id> listIds = new List<Id>();

  for (contact childObj : Trigger.new) {
    listIds.add(childObj.Account.id);
  }

  //Populate the map. Also make sure you select the field you want to update, amount
  //The child relationship is more likely called Quotes__r (not Quote__r) but check
  //You only need to select the child quotes if you are going to do something for example checking whether the quote in the trigger is the latest
  parentOpps = new Map<Id, account>([SELECT id, Parent_amount__c,Greater_amount__c,Lesser_Amount__c,Name,(SELECT ID, Amount__c FROM contacts) FROM Account WHERE ID IN :listIds]);

  for (contact con: Trigger.new){
     Account myParentOpp = parentOpps.get(con.Account.id);
     myParentOpp.Parent_amount__c = con.Amount__c;
  }

  update parentOpps.values();

}

The error is 
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger UpdateAmount caused an unexpected exception, contact your administrator: UpdateAmount: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.UpdateAmount: line 16, column 1

Please help in fixing the bug and please suggest me for 2nd and 3rd scenarios

Thanks.
Hi Everyone,


  I am a newbie to salesforce and and i have a requirement that I have an **Average amount** number field in account and **Amount** number field in contact and stage picklist in contact and stage picklist values are hot,cold ,warm.I have a scenario like if the stage value is hot the contact amount field should be directly populated on Average amount of account field and if the stages of contact is rather than hot the average of all the amounts of multiple contacts should be populated on the account average amount field.It should work if new contacts are inserted and even for update.


       My requirement is i have to write class in the logic and that should be called from the class.


Thanks.
HI,

I have field called phone in contact when i inserted the new contact or updated the contact of related account the account phone should be prepoulated in the contact phone field of the existing account using trigger.

Thanks in advance.
Hai,

1) I have two inputFields in visualforce page,both are picklist values it should validate if both picklist values should not repeat twice & it should be allowed if one picklist value is repeated.

2)I have a number field it should be allow the values between 80 &100

How to write validation in controller.please can anyone tell me...
HI everyone,

   I have struct with one of the requirement that i have the parent account and multiple child contacts and in the parent account i have the amount field that is populated from the child amount .If the parent amount has 25 and again i have inserted new child contact with 30 .when i have deleted the 30 amount record from contact it should get update as previous 25 in the parent amount Ihave written the trigger for insert and update and am not getting for delete .

Please help me how to write the trigger for delete functionality using trigger ,thanks.
Hi everyone,

   I am newbie to salesforce and i want help to update the parent account of amount field when ever the contact of amount field is inserted or updated.and i have the scenario like when ever the contact is created or updated the amount field of account should be auto populated this is the first scenario. The second scenario is when the 2nd contact is created if the amount field is greater the first amount the greater amount field should be populated on the account amount field. The 3rd scenario is there are two check boxes greater amount and lesser amount in the account object this should be populated with the latest contact whether it should be greater or lesser than the previous account.

The fields are
Account object:
Parent_amount__c = Text field
Greater_amount__c = checkbox
Lesser_Amount__c = checkbox

Contact object:
Amount__c 

I have written some code only for update thing and please help me for second and third scenarios.

The 1st scenario is also giving error for me.

trigger UpdateAmount on Contact (after insert, after update) { //You want it on update too, right?
  Map<ID, Account> parentOpps = new Map<ID, Account>(); //Making it a map instead of list for easier lookup
  List<Id> listIds = new List<Id>();

  for (contact childObj : Trigger.new) {
    listIds.add(childObj.Account.id);
  }

  //Populate the map. Also make sure you select the field you want to update, amount
  //The child relationship is more likely called Quotes__r (not Quote__r) but check
  //You only need to select the child quotes if you are going to do something for example checking whether the quote in the trigger is the latest
  parentOpps = new Map<Id, account>([SELECT id, Parent_amount__c,Greater_amount__c,Lesser_Amount__c,Name,(SELECT ID, Amount__c FROM contacts) FROM Account WHERE ID IN :listIds]);

  for (contact con: Trigger.new){
     Account myParentOpp = parentOpps.get(con.Account.id);
     myParentOpp.Parent_amount__c = con.Amount__c;
  }

  update parentOpps.values();

}

The error is 
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger UpdateAmount caused an unexpected exception, contact your administrator: UpdateAmount: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.UpdateAmount: line 16, column 1

Please help in fixing the bug and please suggest me for 2nd and 3rd scenarios

Thanks.
Hi Everyone,


  I am a newbie to salesforce and and i have a requirement that I have an **Average amount** number field in account and **Amount** number field in contact and stage picklist in contact and stage picklist values are hot,cold ,warm.I have a scenario like if the stage value is hot the contact amount field should be directly populated on Average amount of account field and if the stages of contact is rather than hot the average of all the amounts of multiple contacts should be populated on the account average amount field.It should work if new contacts are inserted and even for update.


       My requirement is i have to write class in the logic and that should be called from the class.


Thanks.
HI,

I have field called phone in contact when i inserted the new contact or updated the contact of related account the account phone should be prepoulated in the contact phone field of the existing account using trigger.

Thanks in advance.