July 28, 2017 Merfantz Editor Salesforce Developments Tutorial 0 To Cover the Wrapper Class test method in FieldAx, Code – public with sharing class sno_in_table{ public list<wrap> getRecords() { integer sno=1; list<wrap>emps=new list<wrap>(); list<employee__c>emp_records=[select name,phone__c from employee__c]; for(employee__c em:emp_records){ emps.add(new wrap(sno,em)); sno++; } return emps; } //wrapper class public class wrap{ public integer sno{get;set;} public employee__c emp{get;set;} public wrap(integer sn, employee__c e){ emp=e; sno=sn; } } public static testmethod void m1(){ sno_in_table sno=new sno_in_table(); sno.getrecords(); } } Solution: – Integer int=56; employee__c emp = new employee__c(); // if possible insert fields in this sno_in_table.wrap cmp = new sno_in_table.wrap(int,emp); We are the ISV Partners and Please reach us for custom development => www.merfantz.com Author BioMerfantz Editor+ Recent PostsAugust 4, 2023How to Setup CRM Analytics for Financial Services CloudAugust 2, 2023How to Get Started with Salesforce Hyperforce - MerfantzJuly 28, 2023Health Cloud Mastery: Salesforce Trailhead for Effective Healthcare CRMJuly 26, 2023How to integrate Data cloud and Marketing cloud In Salesforce Tags: Field Service ManagementFieldax
To Cover the Wrapper Class test method in FieldAx,
Code –
public with sharing class sno_in_table{
public list<wrap> getRecords() {
integer sno=1;
list<wrap>emps=new list<wrap>();
list<employee__c>emp_records=[select name,phone__c from employee__c];
for(employee__c em:emp_records){
emps.add(new wrap(sno,em));
sno++;
}
return emps;
}
//wrapper class
public class wrap{
public integer sno{get;set;}
public employee__c emp{get;set;}
public wrap(integer sn, employee__c e){
emp=e;
sno=sn;
}
}
public static testmethod void m1(){
sno_in_table sno=new sno_in_table();
sno.getrecords();
}
}
Solution: –
Integer int=56;
employee__c emp = new employee__c();
// if possible insert fields in this
sno_in_table.wrap cmp = new sno_in_table.wrap(int,emp);