• Egor Palatov
  • NEWBIE
  • 25 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 7
    Replies

public String sortExpression{
		get{
			return sortExp;
		}
		set{
			if (value == sortExp){
				sortDirection = (sortDirection == 'ASC')? 'DESC' : 'ASC';
			}
			else{
				sortDirection = 'ASC';
				sortExp = value;
			}
		}
	}

	public String getSortDirection(){ 
        if (sortExpression == null || sortExpression == ''){
			return 'ASC';
        }
		else{
			return sortDirection;
        }
	}

	public void setSortDirection(String value){  
		sortDirection = value;
	}

	public PageReference ViewData(){
		String sortFullExp = sortExpression  + ' ' + sortDirection;
		items = Database.query('SELECT Id, Name, Type__c,Quantity__c,ProductionDate__c,Price__c,InStock__c,AddDate__c,Image__c FROM Item__c  order by ' + sortFullExp);
		return null;
	}

 
Hi, i need to write assert to test pagination class, and i guess i need to get quntity of records displayed at this moment and assert with expected, how can i do this? 

Hi, how to catch exception with Custom setting list?

Custom setting: NumRecOnPage__c

Custom setting field: Number_records__c

Contoller:

public class ParseCSVController {
    public Blob 							csvFileBody		{get;set;}
	public String 							csvAsString		{get;set;}
	public String[] 						csvFileLines	{get;set;}
	public List<Car_detail__c> 				detailList		{get;set;}
    public List<Car_Detail__c> 				showNow			{get;set;}
	public List<NumRecOnPage__c> 			pageSize		{get;set;} 
    public Map<String,Integer>				mapOfFields		{get;set;}
	public Integer 							resultSize		{get;set;} 
	public Integer 							pageNumber		{get;set;} 
    public Integer 							limitSize		{get;set;}
    public Integer 							counter 		= 	0;
	
	public ParseCSVController(){
        csvFileLines 	= new String[]{};
        showNow 		= new List<Car_Detail__c>();
        detailList 		= new List<Car_detail__c>();
        mapOfFields		= new Map<String,Integer>();       
        pageSize 		= NumRecOnPage__c.getAll().values();        
        limitSize 		= pageSize[0].Number_Records__c.intValue() ;
        resultSize 		= 0;
        pageNumber 		= counter; 
	}
       
    public Boolean getHasNext(){
        if(pageNumber < getNumPages()){
            return true;
        }
        return false;
    }
    
	public boolean getHasPrevious(){
        if(pageNumber>1){
			return true;
        }
		return false;
    }
    
    public void Next(){
        showNow.clear();
        counter+=1;
        pageNumber += 1;      
        integer i0 = counter * limitSize;
        for(integer i = i0 ;i<resultSize;i++){
            if(i<(i0+limitSize)){
                showNow.add(detailList.get(i));
                }else break;
            }
    }
    
	public void Previous(){
        showNow.clear();
        pageNumber = pageNumber-1;
        counter=counter-1;       
        integer i0 = counter * limitSize;      
        for(integer i = i0; i < resultSize; i++){
            if(i < (i0+limitSize)){
                showNow.add(detailList.get(i));
            }else break;
        }
	}
        
	public void Reload(){
        showNow.clear();
        pageNumber = 1;
        counter = 0;
        integer i0 = counter * limitSize;
        for(integer i=i0;i<resultSize;i++){
            if(i<i0+limitSize){
                showNow.add(detailList.get(i));
                }else break;
            }  
	}
    
	public integer getNumPages(){
        integer ost = math.mod(resultSize, limitSize);
        if(ost>0){
        	return resultSize/limitSize+1;
        }
        return resultSize/limitSize;
	}
    
    public void First(){
        counter = 0;
        pageNumber = 1;
        showNow.clear();
        for(integer i=0;i<resultSize;i++){
                if(i<limitSize){
                	showNow.add(detailList.get(i));
                }else break;
		}  
	}
    
	public void Last(){
        counter = getNumPages()-1;
        pageNumber = getNumPages();
        showNow.clear();        
        integer i0 = counter*limitSize;
		for(integer i=i0;i<resultSize;i++){
                if(i<(i0+limitSize)){
                showNow.add(detailList.get(i));
                }else break;
		}  
	}
    
    public integer getCounterValue(){
		return counter;
	}
Can someone help me to write test class for this method?(shownow is a lise of my objects that current displayed on my VF page
public void removeDetail(){
	Integer indexVal = Integer.valueof(system.currentpagereference().getparameters().get('index'));
	shownow.remove(indexVal - 1);            
}

 

Hi, can somebody advice how to create test class for this pagination?

Controller:

public class ParseCSVController {
    
	public Blob csvFileBody{get;set;}
	public string csvAsString{get;set;}
	public String[] csvFileLines{get;set;}
	public List<Car_detail__c> DetailList{get;set;}
    public List<SelectOption> paginationSizeOptions{get;set;}
    public List<Car_Detail__c> showNow{get;set;}
	public List<NumRecOnPage__c> PageSize{get;set;} 
	public integer ResultSize{get;set;} 
	public integer PageNumber{get;set;} 
	public integer limitSize{get;set;}
    public Integer counter = 0;
	
public ParseCSVController(){

	csvFileLines = new String[]{};
    showNow = new List<Car_Detail__c>();
	DetailList = New List<Car_detail__c>();
        PageSize = NumRecOnPage__c.getAll().values(); 
        limitSize = PageSize[0].Number_Records__c.intValue() ;
        ResultSize = 0;
        PageNumber = counter;
  }
    
    
    public boolean getHasNext(){
        if(PageNumber<getNumPages())
            return true;
        return false;
    }
    public boolean getHasPrevious(){
        if(PageNumber>1)
            return true;
        return false;
    }
    public void Next(){
        showNow.clear();
        counter+=1;
        PageNumber += 1;
        
        integer i0 = counter * limitSize;

        for(integer i = i0 ;i<ResultSize;i++){
            if(i<(i0+limitSize)){
                showNow.add(DetailList.get(i));
            }else break;
        }
    }
    public void Previous(){
        showNow.clear();
        PageNumber = PageNumber-1;
        counter=counter-1;
        
        integer i0 = counter * limitSize;
        
        for(integer i = i0 ;i<ResultSize;i++){
            if(i<(i0+limitSize)){
                showNow.add(DetailList.get(i));
            }else break;
        }
    }
    public void reload(){
        showNow.clear();
        PageNumber = 1;
        counter = 0;
        integer i0 = counter * limitSize;
        for(integer i=i0;i<ResultSize;i++){
            if(i<i0+limitSize){
                showNow.add(DetailList.get(i));
            }else break;
        }  
    }
    public integer getNumPages(){
        integer ost = math.mod(ResultSize, limitSize);
        if(ost>0)
            return ResultSize/limitSize+1;
        return ResultSize/limitSize;
    }
    public void First(){
        counter = 0;
        PageNumber = 1;
        showNow.clear();
        for(integer i=0;i<ResultSize;i++){
            if(i<limitSize){
                showNow.add(DetailList.get(i));
            }else break;
        }  
    }
public void Last(){
	counter = getNumPages()-1;
	PageNumber = getNumPages();
	showNow.clear();
        
	integer i0 = counter*limitSize;
	for(integer i=i0;i<ResultSize;i++){
		if(i<(i0+limitSize)){
			showNow.add(DetailList.get(i));
            }else break;
        }  
    }
public integer getCounterValue(){
        return counter;
    }

Test class(that i have ATM):
@isTest
public class ParseCSVControllerTest {
static testMethod void getCustomSettings(){ 
	NumRecOnPage__c customSet = new NumRecOnPage__c(); 
	customSet.Name = '10'; 
	customSet.Number_Records__c = 10; 
	insert customSet; 

	Car__c[] TestCars = new Car__c[]{new Car__c(Name = 'Mersedes'), new Car__c(Name = 'Audi'), 
	new Car__c(Name = 'BMW')}; 

	insert TestCars; 
}  
}

 
Hi, i have  a master-detail relation ship between Car__c(master) and Car_detail__c(detail).

There is a parser for csv file and i need a  picklist to choose to every record it's car__c(relationsheep) field. I tried to create variable "a" that contains the "car id", but it doesnt helped
controller:
public class ParseCSVController {
    
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<Car_detail__c> DetailList{get;set;}
public String CarName {get; set;}
Id a;
public ParseCSVController(){
	csvFileLines = new String[]{};
	DetailList = New List<Car_detail__c>();
}
 public List<SelectOption> getCar(){ 
	List<SelectOption> options = new List<SelectOption>(); 
	List<Car__c> carList = new List<Car__c>();
	carList = [Select Id, Name FROM Car__c];    
	options.add(new SelectOption('--None--','--None--'));    
	for (Car__c cars : carList) 
{ 
	options.add(new SelectOption(cars.Id,cars.Name));
    a = cars.Id;
}          
	return options; 
}
public void importCSVFile(){
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n');
           for(Integer i=1;i<csvFileLines.size();i++){
               Car_detail__c detailObj = new Car_detail__c();
               string[] csvRecordData = csvFileLines[i].split(',');
               detailObj.name = csvRecordData[0] ;             
               detailObj.Type__c = csvRecordData[1];
               detailObj.Length__c = Decimal.valueOf(csvRecordData[2]);
               detailObj.Width__c = Decimal.valueOf(csvRecordData[3]);   
               detailObj.Depth__c = Decimal.valueOf(csvRecordData[4]);
               detailObj.Material__c = csvRecordData[5]; 
               detailObj.Price__c = Decimal.valueOf(csvRecordData[6]); 
               detailObj.Model__c = csvRecordData[7]; 
               detailObj.Year__c = Decimal.valueOf(csvRecordData[8]); 
               detailObj.Quantity__c = Decimal.valueOf(csvRecordData[9]); 
               detailObj.Storage_key__c = Decimal.valueOf(csvRecordData[10]);
               detailObj.Car__c =  a; 
               
               DetailList.add(detailObj);   
           }
        //insert detaillist;
        }
        
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        }  
  }
}

VF page:
<apex:page controller="ParseCSVController">
    <apex:form >
        <apex:pagemessages />
        <apex:pageBlock >
            <apex:pageBlockSection columns="4"> 
                  <apex:inputFile value="{!csvFileBody}"  filename="{!csvAsString}"/>
                  <apex:commandButton value="Import Detail" action="{!importCSVFile}"/>
                  <apex:commandButton value="Save" action="{!Save}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock >
           <apex:pageblocktable value="{!DetailList}" var="detail">
           <apex:variable value="{!0}" var="cnt"/>
              <apex:inlineEditSupport event="ondblClick"/>
              <apex:column value="{!detail.Name}"  headerValue="Наименование детали" />
              <apex:column value="{!detail.Type__c}" headerValue="Тип" />
              <apex:column value="{!detail.Length__c}" headerValue="Длинна" />
              <apex:column value="{!detail.Width__c}" headerValue="Ширина" />
              <apex:column value="{!detail.Depth__c}" headerValue="Глубина" />
              <apex:column value="{!detail.Material__c}" headerValue="Материал" />
              <apex:column value="{!detail.Price__c}" headerValue="Цена" />
              <apex:column value="{!detail.Model__c}" headerValue="Модель" />
              <apex:column value="{!detail.Year__c}" headerValue="Год выпуска" />
              <apex:column value="{!detail.Quantity__c}" headerValue="Количество" />
              <apex:column value="{!detail.Storage_key__c}" headerValue="Код на складе" />
              <apex:column headerValue="Марка автомобиля"> 
				<apex:selectList value="{!CarName}" id="car" size="1" > 
				<apex:selectOptions value="{!car}" /> 
				</apex:selectList> 
		      </apex:column>
     </apex:pageBlock>
   </apex:form>
</apex:page>


 

Hi, i have  a master-detail relation ship between Car__c(master) and Car_detail__c(detail) and i need a  picklist to choose to every record it's car__c(relationsheep) field.

i tried this code but have " A value cannot be stored to Car__c in type Car_Detail__c" problem 

public List<SelectOption> getCar(){ 
	List<SelectOption> options = new List<SelectOption>(); 
	List<Car__c> carList = new List<Car__c>(); 
	carList = [Select Id, Name FROM Car__c]; 
	options.add(new SelectOption('--None--','--None--'));
    
	for (Car__c cars : carList) 
{ 
	options.add(new SelectOption(cars.Id,cars.Name));
    Car_detail__c.Car__c = cars.Id;    
}          
	return options; 
}

public String sortExpression{
		get{
			return sortExp;
		}
		set{
			if (value == sortExp){
				sortDirection = (sortDirection == 'ASC')? 'DESC' : 'ASC';
			}
			else{
				sortDirection = 'ASC';
				sortExp = value;
			}
		}
	}

	public String getSortDirection(){ 
        if (sortExpression == null || sortExpression == ''){
			return 'ASC';
        }
		else{
			return sortDirection;
        }
	}

	public void setSortDirection(String value){  
		sortDirection = value;
	}

	public PageReference ViewData(){
		String sortFullExp = sortExpression  + ' ' + sortDirection;
		items = Database.query('SELECT Id, Name, Type__c,Quantity__c,ProductionDate__c,Price__c,InStock__c,AddDate__c,Image__c FROM Item__c  order by ' + sortFullExp);
		return null;
	}

 

Hi, how to catch exception with Custom setting list?

Custom setting: NumRecOnPage__c

Custom setting field: Number_records__c

Contoller:

public class ParseCSVController {
    public Blob 							csvFileBody		{get;set;}
	public String 							csvAsString		{get;set;}
	public String[] 						csvFileLines	{get;set;}
	public List<Car_detail__c> 				detailList		{get;set;}
    public List<Car_Detail__c> 				showNow			{get;set;}
	public List<NumRecOnPage__c> 			pageSize		{get;set;} 
    public Map<String,Integer>				mapOfFields		{get;set;}
	public Integer 							resultSize		{get;set;} 
	public Integer 							pageNumber		{get;set;} 
    public Integer 							limitSize		{get;set;}
    public Integer 							counter 		= 	0;
	
	public ParseCSVController(){
        csvFileLines 	= new String[]{};
        showNow 		= new List<Car_Detail__c>();
        detailList 		= new List<Car_detail__c>();
        mapOfFields		= new Map<String,Integer>();       
        pageSize 		= NumRecOnPage__c.getAll().values();        
        limitSize 		= pageSize[0].Number_Records__c.intValue() ;
        resultSize 		= 0;
        pageNumber 		= counter; 
	}
       
    public Boolean getHasNext(){
        if(pageNumber < getNumPages()){
            return true;
        }
        return false;
    }
    
	public boolean getHasPrevious(){
        if(pageNumber>1){
			return true;
        }
		return false;
    }
    
    public void Next(){
        showNow.clear();
        counter+=1;
        pageNumber += 1;      
        integer i0 = counter * limitSize;
        for(integer i = i0 ;i<resultSize;i++){
            if(i<(i0+limitSize)){
                showNow.add(detailList.get(i));
                }else break;
            }
    }
    
	public void Previous(){
        showNow.clear();
        pageNumber = pageNumber-1;
        counter=counter-1;       
        integer i0 = counter * limitSize;      
        for(integer i = i0; i < resultSize; i++){
            if(i < (i0+limitSize)){
                showNow.add(detailList.get(i));
            }else break;
        }
	}
        
	public void Reload(){
        showNow.clear();
        pageNumber = 1;
        counter = 0;
        integer i0 = counter * limitSize;
        for(integer i=i0;i<resultSize;i++){
            if(i<i0+limitSize){
                showNow.add(detailList.get(i));
                }else break;
            }  
	}
    
	public integer getNumPages(){
        integer ost = math.mod(resultSize, limitSize);
        if(ost>0){
        	return resultSize/limitSize+1;
        }
        return resultSize/limitSize;
	}
    
    public void First(){
        counter = 0;
        pageNumber = 1;
        showNow.clear();
        for(integer i=0;i<resultSize;i++){
                if(i<limitSize){
                	showNow.add(detailList.get(i));
                }else break;
		}  
	}
    
	public void Last(){
        counter = getNumPages()-1;
        pageNumber = getNumPages();
        showNow.clear();        
        integer i0 = counter*limitSize;
		for(integer i=i0;i<resultSize;i++){
                if(i<(i0+limitSize)){
                showNow.add(detailList.get(i));
                }else break;
		}  
	}
    
    public integer getCounterValue(){
		return counter;
	}
Can someone help me to write test class for this method?(shownow is a lise of my objects that current displayed on my VF page
public void removeDetail(){
	Integer indexVal = Integer.valueof(system.currentpagereference().getparameters().get('index'));
	shownow.remove(indexVal - 1);            
}

 

Hi, can somebody advice how to create test class for this pagination?

Controller:

public class ParseCSVController {
    
	public Blob csvFileBody{get;set;}
	public string csvAsString{get;set;}
	public String[] csvFileLines{get;set;}
	public List<Car_detail__c> DetailList{get;set;}
    public List<SelectOption> paginationSizeOptions{get;set;}
    public List<Car_Detail__c> showNow{get;set;}
	public List<NumRecOnPage__c> PageSize{get;set;} 
	public integer ResultSize{get;set;} 
	public integer PageNumber{get;set;} 
	public integer limitSize{get;set;}
    public Integer counter = 0;
	
public ParseCSVController(){

	csvFileLines = new String[]{};
    showNow = new List<Car_Detail__c>();
	DetailList = New List<Car_detail__c>();
        PageSize = NumRecOnPage__c.getAll().values(); 
        limitSize = PageSize[0].Number_Records__c.intValue() ;
        ResultSize = 0;
        PageNumber = counter;
  }
    
    
    public boolean getHasNext(){
        if(PageNumber<getNumPages())
            return true;
        return false;
    }
    public boolean getHasPrevious(){
        if(PageNumber>1)
            return true;
        return false;
    }
    public void Next(){
        showNow.clear();
        counter+=1;
        PageNumber += 1;
        
        integer i0 = counter * limitSize;

        for(integer i = i0 ;i<ResultSize;i++){
            if(i<(i0+limitSize)){
                showNow.add(DetailList.get(i));
            }else break;
        }
    }
    public void Previous(){
        showNow.clear();
        PageNumber = PageNumber-1;
        counter=counter-1;
        
        integer i0 = counter * limitSize;
        
        for(integer i = i0 ;i<ResultSize;i++){
            if(i<(i0+limitSize)){
                showNow.add(DetailList.get(i));
            }else break;
        }
    }
    public void reload(){
        showNow.clear();
        PageNumber = 1;
        counter = 0;
        integer i0 = counter * limitSize;
        for(integer i=i0;i<ResultSize;i++){
            if(i<i0+limitSize){
                showNow.add(DetailList.get(i));
            }else break;
        }  
    }
    public integer getNumPages(){
        integer ost = math.mod(ResultSize, limitSize);
        if(ost>0)
            return ResultSize/limitSize+1;
        return ResultSize/limitSize;
    }
    public void First(){
        counter = 0;
        PageNumber = 1;
        showNow.clear();
        for(integer i=0;i<ResultSize;i++){
            if(i<limitSize){
                showNow.add(DetailList.get(i));
            }else break;
        }  
    }
public void Last(){
	counter = getNumPages()-1;
	PageNumber = getNumPages();
	showNow.clear();
        
	integer i0 = counter*limitSize;
	for(integer i=i0;i<ResultSize;i++){
		if(i<(i0+limitSize)){
			showNow.add(DetailList.get(i));
            }else break;
        }  
    }
public integer getCounterValue(){
        return counter;
    }

Test class(that i have ATM):
@isTest
public class ParseCSVControllerTest {
static testMethod void getCustomSettings(){ 
	NumRecOnPage__c customSet = new NumRecOnPage__c(); 
	customSet.Name = '10'; 
	customSet.Number_Records__c = 10; 
	insert customSet; 

	Car__c[] TestCars = new Car__c[]{new Car__c(Name = 'Mersedes'), new Car__c(Name = 'Audi'), 
	new Car__c(Name = 'BMW')}; 

	insert TestCars; 
}  
}

 
Hi, i have  a master-detail relation ship between Car__c(master) and Car_detail__c(detail).

There is a parser for csv file and i need a  picklist to choose to every record it's car__c(relationsheep) field. I tried to create variable "a" that contains the "car id", but it doesnt helped
controller:
public class ParseCSVController {
    
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<Car_detail__c> DetailList{get;set;}
public String CarName {get; set;}
Id a;
public ParseCSVController(){
	csvFileLines = new String[]{};
	DetailList = New List<Car_detail__c>();
}
 public List<SelectOption> getCar(){ 
	List<SelectOption> options = new List<SelectOption>(); 
	List<Car__c> carList = new List<Car__c>();
	carList = [Select Id, Name FROM Car__c];    
	options.add(new SelectOption('--None--','--None--'));    
	for (Car__c cars : carList) 
{ 
	options.add(new SelectOption(cars.Id,cars.Name));
    a = cars.Id;
}          
	return options; 
}
public void importCSVFile(){
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n');
           for(Integer i=1;i<csvFileLines.size();i++){
               Car_detail__c detailObj = new Car_detail__c();
               string[] csvRecordData = csvFileLines[i].split(',');
               detailObj.name = csvRecordData[0] ;             
               detailObj.Type__c = csvRecordData[1];
               detailObj.Length__c = Decimal.valueOf(csvRecordData[2]);
               detailObj.Width__c = Decimal.valueOf(csvRecordData[3]);   
               detailObj.Depth__c = Decimal.valueOf(csvRecordData[4]);
               detailObj.Material__c = csvRecordData[5]; 
               detailObj.Price__c = Decimal.valueOf(csvRecordData[6]); 
               detailObj.Model__c = csvRecordData[7]; 
               detailObj.Year__c = Decimal.valueOf(csvRecordData[8]); 
               detailObj.Quantity__c = Decimal.valueOf(csvRecordData[9]); 
               detailObj.Storage_key__c = Decimal.valueOf(csvRecordData[10]);
               detailObj.Car__c =  a; 
               
               DetailList.add(detailObj);   
           }
        //insert detaillist;
        }
        
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        }  
  }
}

VF page:
<apex:page controller="ParseCSVController">
    <apex:form >
        <apex:pagemessages />
        <apex:pageBlock >
            <apex:pageBlockSection columns="4"> 
                  <apex:inputFile value="{!csvFileBody}"  filename="{!csvAsString}"/>
                  <apex:commandButton value="Import Detail" action="{!importCSVFile}"/>
                  <apex:commandButton value="Save" action="{!Save}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock >
           <apex:pageblocktable value="{!DetailList}" var="detail">
           <apex:variable value="{!0}" var="cnt"/>
              <apex:inlineEditSupport event="ondblClick"/>
              <apex:column value="{!detail.Name}"  headerValue="Наименование детали" />
              <apex:column value="{!detail.Type__c}" headerValue="Тип" />
              <apex:column value="{!detail.Length__c}" headerValue="Длинна" />
              <apex:column value="{!detail.Width__c}" headerValue="Ширина" />
              <apex:column value="{!detail.Depth__c}" headerValue="Глубина" />
              <apex:column value="{!detail.Material__c}" headerValue="Материал" />
              <apex:column value="{!detail.Price__c}" headerValue="Цена" />
              <apex:column value="{!detail.Model__c}" headerValue="Модель" />
              <apex:column value="{!detail.Year__c}" headerValue="Год выпуска" />
              <apex:column value="{!detail.Quantity__c}" headerValue="Количество" />
              <apex:column value="{!detail.Storage_key__c}" headerValue="Код на складе" />
              <apex:column headerValue="Марка автомобиля"> 
				<apex:selectList value="{!CarName}" id="car" size="1" > 
				<apex:selectOptions value="{!car}" /> 
				</apex:selectList> 
		      </apex:column>
     </apex:pageBlock>
   </apex:form>
</apex:page>


 
I am stuck at the Trailhead: "Build a Lightning Component to Override a Standard Action" - "Use Lighting Data Service"
with the error:
"Challenge Not yet complete... here's what's wrong: The JavaScript controller markup for the 'PropertyDialog' component is not correct."
Thanks Trailhead ><
Everythign is working as expected when I test it. I passed the next modules with no issues.
I only copy pasted what they required so this looks like some other mistakes is creeping in.
PropertyDialog:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" > <aura:attribute name="picklistValues" type="Object" /> <aura:attribute name="propertyRecord" type="Property__c" /> <force:recordData aura:id="forceRecord" recordId="{!v.recordId}" targetFields="{!v.propertyRecord}" fields="Id,Name,Beds__c,Baths__c,Price__c,Status__c" mode="EDIT" /> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> <c:PicklistValues sObjectName="Property__c" fieldName="Status__c" picklistValues="{!v.picklistValues}" /> <lightning:input aura:id="propName" name="propName" label="Property Name" required="true" /> <lightning:input aura:id="propBeds" name="propBeds" label="Beds" /> <lightning:input aura:id="propBaths" name="propBaths" label="Baths" /> <lightning:input aura:id="propPrice" name="propPrice" label="Price" /> <lightning:select aura:id="propStatus" name="propStatus" label="Status"> <aura:iteration items="{!v.picklistValues}" var="item"> <option value="{!item}">{!item}</option> </aura:iteration> </lightning:select> <lightning:button variant="neutral" label="Cancel" /> <lightning:button variant="brand" label="Submit" onclick="{!c.saveRecord}" />


PropertyDialogController:
({ doInit : function(component, event, helper) { console.log('Property Dialiog init'); var recordData = component.find("forceRecord"); recordData.getNewRecord('Property__c', null, false, $A.getCallback(function() { console.log('callback from getNewRecord'); var rec = component.get("v.propertyRecord"); var error = component.get("v.recordError"); if (error || (rec === null)) { console.log("Error initializing record template: " + error); return; } })); }, saveRecord : function(component, event, helper){ console.log('saveRecord start'); var propBeds = parseInt(component.find('propBeds').get("v.value"), 10); var propBaths = parseInt(component.find('propBaths').get("v.value"), 10); var propPrice = parseInt(component.find('propPrice').get("v.value"), 10); component.set("v.propertyRecord.Name", component.find('propName').get("v.value")); component.set("v.propertyRecord.Beds__c", propBeds); component.set("v.propertyRecord.Baths__c", propBaths); component.set("v.propertyRecord.Price__c", propPrice); component.set("v.propertyRecord.Status__c", "Listed"); console.log('finished setting fields'); var tempRec = component.find("forceRecord"); console.log(tempRec); console.log(JSON.stringify(tempRec)) ; tempRec.saveRecord($A.getCallback(function(result) { console.log(result.state); var resultsToast = $A.get("e.force:showToast"); if (result.state === "SUCCESS") { resultsToast.setParams({ "title": "Saved", "message": "The record was saved." }); resultsToast.fire(); var recId = result.recordId; console.log('record id: '+recId); helper.navigateTo(component, recId); } else if (result.state === "ERROR") { console.log('Error: ' + JSON.stringify(result.error)); resultsToast.setParams({ "title": "Error", "message": "There was an error saving the record: " + JSON.stringify(result.error) }); resultsToast.fire(); } else { console.log('Unknown problem, state: ' + result.state + ', error: ' + JSON.stringify(result.error)); } })); }
})


PropertyDialogHelper:
({ navigateTo : function(component, recId) { var eventNav = $A.get("e.force:navigateToSObject"); eventNav.setParams({recordId: recId}); eventNav.fire(); }
})


Thanks for the help!