• Andy123
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies

I'm just learning, so please bear with me.  I'm making a case-merge application.  The user selects cases to be merged and presses a list button.  This launches a VF page that displays the selected cases in an apex:pageBlockTable.

 

I would now like to add a number of summary columns to this table.  The summary columns show how many emails, tasks, attachments, etc.. each of the cases to be merged has.

 

In my VF page I have:

 

<apex:pageBlockTable value="{!SelectedCases}" var="item">

  <apex:column value="{!item.CaseNumber}"/>

  <apex:column value="{!item.Subject}"/>

  ...etc...

</apex:pageBlockTable>

 

In my class I have:

 

public Case[] getSelectedCases() {

  Set<Id> selectedCaseIds = new Set<Id>();

  for (SObject c : setCon.getSelected()) {

     selectedCaseIds.add(c.Id);

  }

  SObject[] items = [SELECT c.Id, c.CaseNumber, c.Subject, c.Contact.Name, c.Account.Name, 

    c.CreatedDate, c.Origin, c.LastModifiedDate FROM Case c WHERE Id IN :selectedCaseIds];

  return items;

}

 

 

I now would like to add a number columns to my table that are the results of queries like:

SELECT count() FROM CaseComment cc WHERE cc.ParentId = EACH CASE ID IN THE ABOVE SET;

 

so my ultimate display shows

 

<apex:pageBlockTable value="{!SelectedCases}" var="item">

  <apex:column value="{!item.CaseNumber}"/>

  <apex:column value="{!item.Subject}"/>

  <apex:column value="{!item.CountOfCaseComments}" />

  ...etc...

</apex:pageBlockTable>

How do I make a 'custom' object that will be rendered in the pageBlockTable where I can add attributes from various sources?

 

Thanks!

 

I'm just learning, so please bear with me.  I'm making a case-merge application.  The user selects cases to be merged and presses a list button.  This launches a VF page that displays the selected cases in an apex:pageBlockTable.

 

I would now like to add a number of summary columns to this table.  The summary columns show how many emails, tasks, attachments, etc.. each of the cases to be merged has.

 

In my VF page I have:

 

<apex:pageBlockTable value="{!SelectedCases}" var="item">

  <apex:column value="{!item.CaseNumber}"/>

  <apex:column value="{!item.Subject}"/>

  ...etc...

</apex:pageBlockTable>

 

In my class I have:

 

public Case[] getSelectedCases() {

  Set<Id> selectedCaseIds = new Set<Id>();

  for (SObject c : setCon.getSelected()) {

     selectedCaseIds.add(c.Id);

  }

  SObject[] items = [SELECT c.Id, c.CaseNumber, c.Subject, c.Contact.Name, c.Account.Name, 

    c.CreatedDate, c.Origin, c.LastModifiedDate FROM Case c WHERE Id IN :selectedCaseIds];

  return items;

}

 

 

I now would like to add a number columns to my table that are the results of queries like:

SELECT count() FROM CaseComment cc WHERE cc.ParentId = EACH CASE ID IN THE ABOVE SET;

 

so my ultimate display shows

 

<apex:pageBlockTable value="{!SelectedCases}" var="item">

  <apex:column value="{!item.CaseNumber}"/>

  <apex:column value="{!item.Subject}"/>

  <apex:column value="{!item.CountOfCaseComments}" />

  ...etc...

</apex:pageBlockTable>

How do I make a 'custom' object that will be rendered in the pageBlockTable where I can add attributes from various sources?

 

Thanks!

 

I'm just learning, so please bear with me.  I'm making a case-merge application.  The user selects cases to be merged and presses a list button.  This launches a VF page that displays the selected cases in an apex:pageBlockTable.

 

I would now like to add a number of summary columns to this table.  The summary columns show how many emails, tasks, attachments, etc.. each of the cases to be merged has.

 

In my VF page I have:

 

<apex:pageBlockTable value="{!SelectedCases}" var="item">

  <apex:column value="{!item.CaseNumber}"/>

  <apex:column value="{!item.Subject}"/>

  ...etc...

</apex:pageBlockTable>

 

In my class I have:

 

public Case[] getSelectedCases() {

  Set<Id> selectedCaseIds = new Set<Id>();

  for (SObject c : setCon.getSelected()) {

     selectedCaseIds.add(c.Id);

  }

  SObject[] items = [SELECT c.Id, c.CaseNumber, c.Subject, c.Contact.Name, c.Account.Name, 

    c.CreatedDate, c.Origin, c.LastModifiedDate FROM Case c WHERE Id IN :selectedCaseIds];

  return items;

}

 

 

I now would like to add a number columns to my table that are the results of queries like:

SELECT count() FROM CaseComment cc WHERE cc.ParentId = EACH CASE ID IN THE ABOVE SET;

 

so my ultimate display shows

 

<apex:pageBlockTable value="{!SelectedCases}" var="item">

  <apex:column value="{!item.CaseNumber}"/>

  <apex:column value="{!item.Subject}"/>

  <apex:column value="{!item.CountOfCaseComments}" />

  ...etc...

</apex:pageBlockTable>

How do I make a 'custom' object that will be rendered in the pageBlockTable where I can add attributes from various sources?

 

Thanks!

 

With Winter '11, if you create a Site, a new Salesforce-provided class gets deployed to your org: MyProfilePageController.cls

 

There is test code in this class that fails if you don't have a portal user installed. This prevents you from doing anything in that org that requires running all tests.

 

Here is the error:

 

System.QueryException: List has no rows for assignment to SObject

Class.MyProfilePageController.testSave: line 78, column 35 External entry point

 

and the line in question:

 

 

User existingPortalUser = [SELECT id, profileId, userRoleId FROM User WHERE UserRoleId <> null AND UserType='CustomerSuccess' LIMIT 1];

 

This failure prevents doing any save from Eclipse. You can't deploy new code, edit object metadata files, etc. Complete showstopper.

 

Can anyone:

 * confirm this (we think reproducing will require that you create a new Site, perhaps the first Site in the org, after Winter 11)

 * think of a work-around (tried enabling self-service portal, but it doesn't create the required user type)

 

Anyone from Salesforce confirm that this is a bug and not something we're doing wrong?

 

Thanks!

 

Here is the entire class:

 

/**
 * An apex class that keeps updates of a portal user in sync with its corresponding contact.
   Guest users are never able to access this page.
 */
public class MyProfilePageController {

    private User user;
    private boolean isEdit = false;
    
    public User getUser() {
        return user;
    }

    public MyProfilePageController() {
        user = [SELECT id, email, username, usertype, communitynickname, timezonesidkey, languagelocalekey, firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax, contact.email
                FROM User
                WHERE id = :UserInfo.getUserId()];
        // guest users should never be able to access this page
        if (user.usertype == 'GUEST') {
            throw new NoAccessException();
        }
    }
    
    public Boolean getIsEdit() {
        return isEdit;
    }
    
    public void edit() {
        isEdit=true;
    }    
    
    public void save() {
        if (user.contact != null) {              
            setContactFields(user.contact);
        }
        
        try {
            update user;
            if (user.contact != null) { 
                update user.contact;
            }
            isEdit=false;
        } catch(DmlException e) {
            ApexPages.addMessages(e);
        }
    }
    
    public PageReference changePassword() {
        return Page.ChangePassword;
    }
    
    public void cancel() {
        isEdit=false;
        user = [SELECT id, email, username, communitynickname, timezonesidkey, languagelocalekey, firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax, contact.email
                FROM User
                WHERE id = :UserInfo.getUserId()];
    }
    
    private void setContactFields(Contact c) {
        c.title = user.title;
        c.firstname = user.firstname;
        c.lastname = user.lastname;
        c.email = user.email;
        c.phone = user.phone;
        c.mobilephone = user.mobilephone;
        c.fax = user.fax;
        c.mailingstreet = user.street;
        c.mailingcity = user.city;
        c.mailingstate = user.state;
        c.mailingpostalcode = user.postalcode;
        c.mailingcountry = user.country;
    }

    static testMethod void testSave() {         
        // Modify the test to query for a portal user that exists in your org
        User existingPortalUser = [SELECT id, profileId, userRoleId FROM User WHERE UserRoleId <> null AND UserType='CustomerSuccess' LIMIT 1];
        System.assert(existingPortalUser != null, 'This test depends on an existing test portal user to run');
        
        String randFax = Math.rint(Math.random() * 1000) + '5551234';
        
        System.runAs(existingPortalUser) {
            MyProfilePageController controller = new MyProfilePageController();
            System.assertEquals(existingPortalUser.Id, controller.getUser().Id, 'Did not successfully load the current user');
            System.assert(controller.isEdit == false, 'isEdit should default to false');
            controller.edit();
            System.assert(controller.isEdit == true);
            
            controller.cancel();
            System.assert(controller.isEdit == false);
            
            controller.getUser().Fax = randFax;
            controller.save();
            System.assert(controller.isEdit == false);
        }
        
        // verify that the user and contact were updated
        existingPortalUser = [Select id, fax, Contact.Fax from User where id =: existingPortalUser.Id];
        System.assert(existingPortalUser.fax == randFax);
        System.assert(existingPortalUser.Contact.fax == randFax);
    }

}

 

 

 

  • October 15, 2010
  • Like
  • 0
I'm working with the Plone <-> Salesforce.com integration and creating cases from my website. I'm not using web-to-case, just using the API to create Cases and the Related Contact and Account.

Is there any way to fire the default Case Assignment rule when a Case is created via the API? Seems like there are two ways to fire the rules:
  1. Create the Case via web-to-lead
  2. Create the case in the UI, and check the Assignment Rule checkbox
Am I missing the handy-dandy FireAssignmentRule field on the Case?

Thanks,
Steve