You need to sign in to do that
Don't have an account?
Money Care 7
How to Update picklist value
Hi Guys
I am facing one challenge for long time .I have two object Account and Discount__c with lookup relationship ,Account object have a picklist filed with value LEAD and CUSTOMER.
Now i have created a account record with picklist value LEAD. my requirment is when i am going to create a record on discount__c object the picklist value which was LEAD is converted to CUSTOMER autometically.that mean the parent object which have have child record then it will happens.how to achieve this solution ?
I am facing one challenge for long time .I have two object Account and Discount__c with lookup relationship ,Account object have a picklist filed with value LEAD and CUSTOMER.
Now i have created a account record with picklist value LEAD. my requirment is when i am going to create a record on discount__c object the picklist value which was LEAD is converted to CUSTOMER autometically.that mean the parent object which have have child record then it will happens.how to achieve this solution ?
Add this in trigger:
Add this method in Class:
All Answers
Could you share some after insert trigger sample code...
Refer below trigger and controller:
Trigger:
Controller:
Thanks,
Dhanya
Mark this as Best Answer, if this solves your problem.
what you all share is only working on new record creation.which is working fine as per my requirment.
Problem is i have 3000 existing record in account object,i want to update all existing record picklist value to CUSTOMER which account record have child record i mean Discount__c.how to achieve this .....
Thanks in advance
After modification its showing error
Error: Compile Error: Didn't understand relationship 'Discount__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 13 column 34
Refer this link for checking child relationship name: http://www.soliantconsulting.com/blog/2012/10/sfdc-best-practice-child-relationship-names
Are you able to get child relationship name?
How to write test class for above batch class....
Refer this link for more information about Batch Test Class : https://developer.salesforce.com/docs/atlas.en-us.apex_workbook.meta/apex_workbook/apex_batch_2.htm
This is working fine when child record created, parent record Account Type field autometically updated This is ok for inserting/creating record
for example i did delete the child record then parent record back to the post value "LEAD" autometically i mean how to implement backword process .
Add this in trigger:
Add this method in Class:
Error MessageSystem.DmlException: Insert failed. First exception on row 0; first error: ENTITY_IS_DELETED, entity is deleted: []
I have created and modified the handler class and trigger which is working in sandbox properly.but in production some user facing this type of issue
Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, TypeCheck: execution of AfterInsert caused by: System.DmlException: Update failed. First exception on row 0 with id 0019000000uJACTAA4; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: [] Class.PicklistHandler.OnAfterInsert: line 21, column 1 Trigger.TypeCheck: line 7, column 1: []
How to achieve this issue,anybody have idea.