質問

I have 2 custom objects i have created and due to the limitations of salesforce lists and reports i cant get more then 255 characters to be displayed on a long textarea.

Sales_Trip__c
- Name - string
- Date_From - date
- Date_To - date
- Salesman - lookup User


Sales_Trip_Visit__c
- Sales_Trip - master-detail
- Account - master-detail
- Notes - Long Textarea
- Date - date

so i'm trying to create a new visualforce page that displays the sales_trip_visit__c's in a table ordered by Sales_Trip_Visit__c.Date

I have the page working using the Sales_Trip__c standard controller But that returns the visits unordered.

From what i can tell i cant do that within the page so i am attempting to create an extension for the Sales_Trip__c standard controller that has a method that returns a list of visits ordered by the date.

This is what i have so far and i think i'm not doing something right.

public class mySalesTripControllerExtension {

private final Sales_Trip__c satr;

public mySalesTripControllerExtension(ApexPages.StandardController stdController) {
    this.satr = (Sales_Trip__c)stdController.getRecord();
}

public List<Sales_Trip_Visits__c> getVisitList() {
    con = new List<Sales_Trip_Visits__c>();
    con = [SELECT Date, Account.Name, Notes FROM Sales_Trip_Visits__c WHERE Sales_Trip__c.id = :this.satr.id ORDER BY Date]
    return con;
}
}

I'm getting the following error but i think I am doing it completely wrong.

    Error: Compile Error: sObject type 'Sales_Trip_Visits__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names. at line 18 column 15

Thanks for the help this is now my revised code. and i have kept the nameing convention i am using which is a duplicate custom object same fields / same relationships just a different name ( original had a rich textarea. _2 has a long textarea

public class mySalesTripControllerExtension {

    private final Sales_Trip__c satr;

    // The extension constructor initializes the private member
    // variable acct by using the getRecord method from the standard
    // controller.
    public mySalesTripControllerExtension(ApexPages.StandardController stdController) {
        this.satr = (Sales_Trip__c)stdController.getRecord();
    }

    public List<Sales_Trip_Visit_2__c> getVisitList() {
        Sales_Trip_Visit_2__c con = [SELECT Date__c, Account__r.Name, Notes__c FROM Sales_Trip_Visit_2__c WHERE  Sales_Trip__r.Id = :satr.id ORDER BY Date__c];
        return con;
    }
}

Current error.

Error: Compile Error: Return value must be of type: LIST<Sales_Trip_Visit_2__c> at line 16 column 9 
役に立ちましたか?

解決

First of all you can make a sorting on a page but you will have to use some javascript for it. A better approach would be as you're doing to make the sorting on the controller side. You making it right overall except the error i mentioned in a comment. Here is modified code

public List<Sales_Trip_Visits__c> getVisitList() {
   Sales_Trip_Visits__c con = [SELECT Date__c, Account__r.Name, Notes__c FROM Sales_Trip_Visits__c WHERE  Id = :satr.id ORDER BY Date__c]
   return con;
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top