You need to sign in to do that
Don't have an account?
fiona gentry
How to load an existing record and modify it
Hi Gurus,
this is an apex controller code to insert a record,please help me in writing a code to load an existing record and modify it as well
Your help is highly appreciated
Regards,
Fiona
this is an apex controller code to insert a record,please help me in writing a code to load an existing record and modify it as well
public class PickListHandler { @AuraEnabled public static List<String> getLevel1(){ List<String> tempLst1 = new List<String>(); for(AggregateResult ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c group by Level_1__c]) { tempLst1.add(''+ar.get('Level_1__c')); } return tempLst1; } @AuraEnabled public static List<String> getLevel2(string strName){ List<String> tempLst2 = new List<String>(); for(AggregateResult ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName group by Level_2__c]) { tempLst2.add(''+ar.get('Level_2__c')); } return tempLst2; } @AuraEnabled public static List<String> getLevel3(string strName1,string strName2){ List<String> tempLst3 = new List<String>(); for(AggregateResult ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c]) { tempLst3.add(''+ar.get('Level_3__c')); } return tempLst3; } @AuraEnabled public static String savecasetype(string level1,string level2,string level3,string id){ string strMsg='successfull'; try{ ERT_Case_Type__c obj=new ERT_Case_Type__c(); Obj.Case__c = id; System.debug('CASE = '+ Obj.Case__c); Obj.Level_1__c=level1; System.debug('Level1 = '+ Obj.Level_1__c); Obj.Level_2__c=level2; System.debug('Level2 = '+ Obj.Level_2__c); Obj.Level_3__c=level3; System.debug('Level3 = '+ Obj.Level_3__c); Insert obj; } catch(Exception ex){ strMsg='error'; } return strMsg; } }
Your help is highly appreciated
Regards,
Fiona
Hi fiona,
I am not able to understand your requirment properly. can you explain it properly, so that i help to you.
and if you are using js and html then please show me.
Thank you
Now I want to extend the functionality of above lightning component so that user who wishes to change Record data on Case can just update the value of Level1, Level2 and Level3 and do an Upsert on the same case
Now to achieve Edit a record functionality,added lightning:actionOverride in apex cmp and then overridden the standard Edit button of ERT case type custom object ..Here comes the problem when I use the same component in Edit button ,I see error as below
Hence I need help to write a code to load an existing record and modify it
Expected behavior:- Now I want to extend the functionality of above lightning component so that user who wishes to change Record data on Case can just update the value of Level1, Level2 and Level3 and do an Upsert on the same case