• Imran Rahman 3
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
I would like to run some workflow actions when my object record has been created or updated, however from what I can see 'Scheduled Actions' can only be set when the Object node is set to trigger only when the record is "Created". Is there any work around for this?
I have created a custom extension which allows me to pull specified data into my visualforce news page.
In my extension I have mutliple queries which pull filtered data if used with url parameters and also have my own pagination built in.

How can I create a test class for the following:
public with sharing class force_NewsController {

    public String filteredEvents { get; set; }
 
    public force_NewsController (){
        CountTotalRecords= [SELECT COUNT() FROM News__c];

        // pagination filter
        String category = Apexpages.currentPage().getParameters().get('cat');
        if (category == 'product launches') {
            CountTotalRecords = [SELECT COUNT() FROM News__c WHERE Category__c = 'Product Launches'];
        } else if (category == 'events') {
            CountTotalRecords = [SELECT COUNT() FROM News__c WHERE Category__c = 'Events'];
        } else if (category == 'press releases') {
            CountTotalRecords = [SELECT COUNT() FROM News__c WHERE Category__c = 'Press Releases'];
        } else if (category == 'case studies') {
            CountTotalRecords = [SELECT COUNT() FROM News__c WHERE Category__c = 'Case Studies'];
        } else {
            CountTotalRecords = [SELECT COUNT() FROM News__c];
        }
    }
 
    public Integer CountTotalRecords{get;set;}
    public String QueryString {get;set;}
    public Integer OffsetSize = 0;
    private Integer QueryLimit = 6;
    public string excerpt;
    public list<News__c> lstItem {get;set;}
    public list<News__c> NewsList {get;set;}
    public list<News__c> EventList {get;set;}
    public map<id,string> newsmap{get;set;}

    public Boolean filteredEvents(){
        if(apexpages.currentpage().getparameters().get('cat') == 'events'){
            return true;
        }
        else return false;
    }
 

    public list<News__c> getNewsItems(){
        lstItem = new list<News__c>();

        String category = Apexpages.currentPage().getParameters().get('cat');
        String query = 'SELECT Id, Name, Title__C, Content__c, Publish_Date__c, Category__c, Event_Date_Start__c, Event_Date_End__c, Event_Location__c, ';
        query += '(Select Id, Name, LastModifiedDate From Attachments Order By LastModifiedDate DESC) ';
        query += 'FROM News__c ';

        if (category != null)
        {
            query += 'WHERE Category__c = :category ';
        }

        query += 'ORDER BY Publish_Date__c DESC, Name DESC LIMIT :QueryLimit OFFSET :OffsetSize';

        lstItem = Database.query(query);
        return lstItem;
    }

    public Boolean getDisablePrevious(){
        if(OffsetSize>0){
            return false;
        }
        else return true;
    }
 
    public Boolean getDisableNext() {
        if (OffsetSize + QueryLimit < countTotalRecords){
            return false;
        }
        else return true;
    }
 
    public PageReference Next() {
        OffsetSize += QueryLimit;
        return null;
    }
 
    public PageReference Previous() {
        OffsetSize -= QueryLimit;
        return null;
    }

    public list<News__c> getHomeNewsItems(){
        NewsList = new list<News__c>();

        String query = 'SELECT Id, Name, Title__C, Content__c, Publish_Date__c, Category__c, ';
        query += '(Select Id, Name, LastModifiedDate From Attachments Order By LastModifiedDate DESC) ';
        query += 'FROM News__c ';
        query += 'WHERE Category__c != \'Events\' ';
        query += 'ORDER BY Publish_Date__c DESC, Name DESC LIMIT 5';

        NewsList = Database.query(query);
        return NewsList;
    }

    public list<News__c> getUpcomingEvents(){
        EventList = new list<News__c>();

        String query = 'SELECT Id, Name, Title__C, Publish_Date__c, Event_Date_Start__c, Event_Date_End__c, Event_Location__c ';
        query += 'FROM News__c ';
        query += 'WHERE Category__c = \'Events\' ';
        query += 'ORDER BY Event_Date_Start__c ASC, Name DESC LIMIT 3';

        EventList = Database.query(query);
        return EventList;
    }

    public LIST<Service_Status__c> getServiceItems() {
        return [SELECT Id, Name, Information__c, Status_Colour__c FROM Service_Status__c ORDER BY Priority__c DESC];
    }

    public LIST<News__c> getAlerts() {
        date d = system.today().addDays(-8);
        return [SELECT Id, Name, Title__C, Publish_Date__c FROM News__c WHERE Flash_Message__c = TRUE AND Publish_Date__c > :d  ORDER BY Publish_Date__c DESC LIMIT 1];
    }

}


 
I have a visualforce page with a standard controller which creates a new record on click of my commandButton. This function works using just standard controllers at the moment.

What I would like to do if insertion is successful, to redirect the page to my own custom detail page (mysite.force.com/detailPage?id=) instead of the salesforce's default one. I need to also pass the ID parameter of the newly created record so I can pull up the infomation on the page.
I would like to manually alter/code the menu bar in my customer portal because I would like to add a navbar with dropdowns (which I believe salesforce does not have out of the box).

How can I do this?
I have a visualforce page with a standard controller which creates a new record on click of my commandButton. This function works using just standard controllers at the moment.

What I would like to do if insertion is successful, to redirect the page to my own custom detail page (mysite.force.com/detailPage?id=) instead of the salesforce's default one. I need to also pass the ID parameter of the newly created record so I can pull up the infomation on the page.
I would like to manually alter/code the menu bar in my customer portal because I would like to add a navbar with dropdowns (which I believe salesforce does not have out of the box).

How can I do this?