You need to sign in to do that
Don't have an account?
Taresh Pandey
Need help to write "Test Class" for the RemoteAction
// This method is use to create chart Records (Bulky method)
// INPUT: Array of Sobject (Chart) with field data.
// OUTPUT: return ID if inserted without error return null if inertion failes.
//
@RemoteAction
public static String insertChart(List<Chart> RemoteCharts){
List<Lean__Chart__c> NewCharts= new List<Lean__Chart__c>();
for(Chart Chart: RemoteCharts){
Lean__Chart__C Newchart= new Lean__Chart__c();
Newchart.Name =Chart.Name;
Newchart.Lean__DeveloperName__c = Chart.DeveloperName;
Newchart.Lean__Filter__c = Chart.Filter;
Newchart.Lean__Format__c = Chart.Format;
Newchart.Lean__GUID__c = Chart.Id;
Newchart.Lean__Height__c = Chart.Height;
Newchart.Lean__Left__c = Chart.Left;
Newchart.Lean__LockState__c = Chart.LockState;
Newchart.Lean__ReportId__c = Chart.ReportID;
Newchart.Lean__Top__c = Chart.Top;
Newchart.Lean__ValueStream__c = (Chart.ValueStreamID==''?null:Chart.ValueStreamID);
Newchart.Lean__Width__c = Chart.Width;
Newchart.Lean__X__c = Chart.X;
Newchart.Lean__Y__c = Chart.Y;
Newchart.Lean__CmpID__c =Chart.CmpID;
Newchart.Lean__Size__c = Chart.Size;
Newchart.Lean__ChartURL__c = Chart.ChartURL;
Newchart.Lean__JSONData__c = Chart.JSONData;
NewChart.Lean__OnlyShowChart__c = Chart.OnlyShowChart;
NewCharts.add(Newchart);
}
List<Database.Upsertresult> uResults;
try {
Schema.Sobjectfield ExternField = Lean__Chart__C.Fields.Lean__GUID__c;
uResults = Database.upsert(NewCharts, ExternField, true);
} catch (DmlException e){
System.debug(e.getMessage());
return '';
}
return NewCharts[0].Id ;
}
Regards'
Taresh
// INPUT: Array of Sobject (Chart) with field data.
// OUTPUT: return ID if inserted without error return null if inertion failes.
//
@RemoteAction
public static String insertChart(List<Chart> RemoteCharts){
List<Lean__Chart__c> NewCharts= new List<Lean__Chart__c>();
for(Chart Chart: RemoteCharts){
Lean__Chart__C Newchart= new Lean__Chart__c();
Newchart.Name =Chart.Name;
Newchart.Lean__DeveloperName__c = Chart.DeveloperName;
Newchart.Lean__Filter__c = Chart.Filter;
Newchart.Lean__Format__c = Chart.Format;
Newchart.Lean__GUID__c = Chart.Id;
Newchart.Lean__Height__c = Chart.Height;
Newchart.Lean__Left__c = Chart.Left;
Newchart.Lean__LockState__c = Chart.LockState;
Newchart.Lean__ReportId__c = Chart.ReportID;
Newchart.Lean__Top__c = Chart.Top;
Newchart.Lean__ValueStream__c = (Chart.ValueStreamID==''?null:Chart.ValueStreamID);
Newchart.Lean__Width__c = Chart.Width;
Newchart.Lean__X__c = Chart.X;
Newchart.Lean__Y__c = Chart.Y;
Newchart.Lean__CmpID__c =Chart.CmpID;
Newchart.Lean__Size__c = Chart.Size;
Newchart.Lean__ChartURL__c = Chart.ChartURL;
Newchart.Lean__JSONData__c = Chart.JSONData;
NewChart.Lean__OnlyShowChart__c = Chart.OnlyShowChart;
NewCharts.add(Newchart);
}
List<Database.Upsertresult> uResults;
try {
Schema.Sobjectfield ExternField = Lean__Chart__C.Fields.Lean__GUID__c;
uResults = Database.upsert(NewCharts, ExternField, true);
} catch (DmlException e){
System.debug(e.getMessage());
return '';
}
return NewCharts[0].Id ;
}
Regards'
Taresh
Please find test class below : Let me know if you need any help.
Regards,
Abhishek
All Answers
Please find test class below : Let me know if you need any help.
Regards,
Abhishek