• Narendhar Reddy Yenugu
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
public with sharing class CaseLwc {
public CaseLwc() {
}
@AuraEnabled(cacheable=true)
public static List<FetchValueWrapper> getPicklistValues(sObject objInfo,string picklistFieldApi){
Schema.DescribeSObjectResult objDescribe = objInfo.getSObjectType().getDescribe();
Map< string, Schema.SObjectField> fieldMap= objDescribe.fields.getMap();
List<Schema.picklistEntry> values=fieldMap.get(picklistFieldApi).getDescribe().getPicklistValues();
system.debug('values-----'+values);
List<FetchValueWrapper> objWrapper=new List<FetchValueWrapper>();
for(Schema.picklistEntry p:values){
FetchValueWrapper fw = new FetchValueWrapper();
fw.slabel=p.getlabel();
fw.svalue=p.getvalue();
objWrapper.add(fw);
system.debug('Map-----'+objWrapper);
}
return objWrapper;
}
/* @AuraEnabled(cacheable=true)
public static List<String> getCaseFields(){
SObjectType caseType = Schema.getGlobalDescribe().get('Case');
Map<String,Schema.SObjectField> mfields = caseType.getDescribe().fields.getMap();
system.debug('fields------'+mfields);
List<String> sObjectDetailsList = new List<String>();
for(String s : mfields.keySet()){
sObjectDetailsList.add(String.valueOf(mfields.get(s)));
}
system.debug('sObjectDetailsList------'+sObjectDetailsList);
return sObjectDetailsList;
} */


@AuraEnabled(cacheable=true)
public static list<CaseWrapper> getCaseFields() {
list<string> fvlst = new list<string>();
list<CaseWrapper> lstwrp = new list<CaseWrapper>();
list<string> fieldvaluelst = new list<string>();
String obj = 'Case';
Map<String,Schema.SObjectType> gd = Schema.getGlobalDescribe();
Schema.SObjectType sobjType = gd.get(obj);
Schema.DescribeSObjectResult describeResult = sobjType.getDescribe();
Map<String,Schema.SObjectField> fieldsMap = describeResult.fields.getMap();
system.debug('fieldsMap---'+fieldsMap);
CaseWrapper cwrp = new CaseWrapper();
cwrp.AccountId = fieldsMap.get('AccountId').getDescribe().getLabel();
cwrp.CaseNumber = fieldsMap.get('CaseNumber').getDescribe().getLabel();
cwrp.AssetId = fieldsMap.get('AssetId').getDescribe().getLabel();
cwrp.Origin = fieldsMap.get('Origin').getDescribe().getLabel();
cwrp.OwnerId = fieldsMap.get('OwnerId').getDescribe().getLabel();
cwrp.Reason = fieldsMap.get('Reason').getDescribe().getLabel();
cwrp.SourceId = fieldsMap.get('SourceId').getDescribe().getLabel();
  cwrp.IsClosedOnCreate = fieldsMap.get('IsClosedOnCreate').getDescribe().getLabel();
cwrp.SuppliedName = fieldsMap.get('SuppliedName').getDescribe().getLabel();
cwrp.ContactEmail = fieldsMap.get('ContactEmail').getDescribe().getLabel();
cwrp.Status = fieldsMap.get('Status').getDescribe().getLabel();
cwrp.Type = fieldsMap.get('Type').getDescribe().getLabel();
cwrp.SuppliedPhone = fieldsMap.get('SuppliedPhone').getDescribe().getLabel();
cwrp.SuppliedEmail = fieldsMap.get('SuppliedEmail').getDescribe().getLabel();
cwrp.SuppliedCompany = fieldsMap.get('SuppliedCompany').getDescribe().getLabel();
cwrp.Subject = fieldsMap.get('Subject').getDescribe().getLabel();
cwrp.Priority = fieldsMap.get('Priority').getDescribe().getLabel();
cwrp.ContactFax = fieldsMap.get('ContactFax').getDescribe().getLabel();
cwrp.ContactMobile = fieldsMap.get('ContactMobile').getDescribe().getLabel();
cwrp.ContactId = fieldsMap.get('ContactId').getDescribe().getLabel();
cwrp.ContactPhone = fieldsMap.get('ContactPhone').getDescribe().getLabel();
cwrp.Description = fieldsMap.get('Description').getDescribe().getLabel();
cwrp.Comments = fieldsMap.get('Comments').getDescribe().getLabel();
cwrp.LastModifiedById = fieldsMap.get('LastModifiedById').getDescribe().getLabel();
cwrp.ParentId = fieldsMap.get('ParentId').getDescribe().getLabel();
cwrp.CreatedDate = fieldsMap.get('CreatedDate').getDescribe().getLabel();
cwrp.PotentialLiability = fieldsMap.get('PotentialLiability__c').getDescribe().getLabel();
cwrp.EngineeringReqNumber = fieldsMap.get('EngineeringReqNumber__c').getDescribe().getLabel();
cwrp.Product = fieldsMap.get('Product__c').getDescribe().getLabel();
cwrp.SLAViolation = fieldsMap.get('SLAViolation__c').getDescribe().getLabel();
lstwrp.add(cwrp);
system.debug('wrplist--'+lstwrp);
return lstwrp;
}

@AuraEnabled
public static void saveRecords(Case Obj) {
system.debug('obj'+ obj);
Insert Obj;
}
public with sharing class FetchValueWrapper {
@AuraEnabled public string slabel {get;set;}
@AuraEnabled public string svalue {get;set;}
}
}