I got an error \"Unknown property 'newTaskForTypeController.typeOfTask'\". any help please", "answerCount": 2, "upvoteCount": 0, "datePublished": "2016-03-28T10:26:04.000Z", "author": { "@type": "Person", "name": "Amr Mohsen", "url": "https://trailblazers.salesforce.com/profileView?u=0053000000CVxCzAAL", "affiliation": { "@type": "Organization", "name": "--" } }, "suggestedAnswer": [ { "@type": "Answer", "text": "Hi Amr, As you are using It shoulbe a getter to the Controller.   public TaskForTypes__c typeOfTask { get ; set ;} Hope this will be helpful. Thanks, Abhishek", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T4WThSAN", "datePublished": "2016-03-28T11:35:58.000Z", "author": { "@type": "Person", "name": "Abhishek Vishwakarma", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000DAlxJQAT", "affiliation": { "@type": "Organization", "name": "Trekbin Technology" } } } ] } }
Skip to main content
Amr Mohsen asked in #Apex
Hello, 

I've created a custom controller like below 

public class newTaskForTypeController {

public TaskForTypes__c typeOfTask;

public string SelectedTaskId { get; set; }

public TaskForTypes__c getTaskTypes(){

if(typeOfTask == null) return new TaskForTypes__c();

return typeOfTask;

}

//First page which will contain name

public PageReference step1(){

return Page.Tasks_For_Types1;

}

//Second page which will contain Sub type name and

public PageReference step2(){

return Page.Tasks_For_Types2;

}

//Cancel the operation

public PageReference cancel(){

//Navigate to first page

PageReference tft1 = new ApexPages.StandardController(typeOfTask).view();

tft1.setRedirect(true);

return tft1;

}

//Save method

public PageReference save(){

if(typeOfTask == null) typeOfTask = new TaskForTypes__c();

insert typeOfTask;

PageReference tft1 = new ApexPages.StandardController(typeOfTask).view();

tft1.setRedirect(true);

return null;

}

//Get cuurent tasks

public List<TaskForTypes__c> getTypeTasks(){

List<TaskForTypes__c> tsks = [SELECT Subject__c, Task_Description__c FROM TaskForTypes__c WHERE Sub_Type_Name__c =: typeOfTask.Sub_Type_Name__c];

return tsks;

}

//Delete Task from List

public void DeleteTask()

{

// if for any reason we are missing the reference

if (SelectedTaskId == null) {

return;

}

// find the account record within the collection

TaskForTypes__c tobeDeleted = null;

for(TaskForTypes__c a : getTypeTasks())

if (a.Id == SelectedTaskId) {

tobeDeleted = a;

break;

}

//if account record found delete it

if (tobeDeleted != null) {

Delete tobeDeleted;

}

//refresh the data

getTypeTasks();

}

public List<TaskForTypes__c> getUniqueTypes(){

List<TaskForTypes__c> types = [SELECT Sub_Type_Name__c FROM TaskForTypes__c];

return types;

}

}

and my VF page code is 

<apex:page controller="newTaskForTypeController" tabStyle="TaskForTypes__c" >

<script>

function confirmCancel() {

var isCancel = confirm("Are you sure you wish to cancel?");

if (isCancel) return true;

return false;

}

</script>

<apex:sectionHeader title="Add New Task Assignment For Types Rule"/>

<apex:form >

<apex:pageBlock title="Rule Name" mode="edit">

<apex:pageBlockButtons >

<apex:commandButton action="{!save}" value="Save & Next" />

<apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true" />

</apex:pageBlockButtons>

<apex:pageBlockSection >

<apex:inputField id="subtype" value="{!typeOfTask.Sub_Type_Name__c}" required="true" />

</apex:pageBlockSection>

</apex:pageBlock>

</apex:form>

</apex:page>

I got an error "Unknown property 'newTaskForTypeController.typeOfTask'".

any help please 
2 answers
  1. Mar 28, 2016, 11:35 AM
    Hi Amr,

    As you are using

    <apex:inputField id="subtype" value="{!typeOfTask.Sub_Type_Name__c}" required="true" />

    It shoulbe a getter to the Controller.

     

    public TaskForTypes__c typeOfTask { get ; set ;}

    Hope this will be helpful.

    Thanks,

    Abhishek
0/9000