• rtscott
  • NEWBIE
  • 0 Points
  • Member since 2008

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

Hello All,

 

I would like to create an HTML file that a Salesforce user can click on while logged into the system that will grab the user's Session ID and append it to the document. I believe I can do this with the AJAX Toolkit, but I am not sure how to make it happen. For example: let's say that I attach the following HTML file to a Case in Salesforce.com:

<!doctype html>
<html>
<head>
<script src="/soap/ajax/16.0/connection.js" type="text/javascript"></script>
<script type="text/javascript">
function initPage() {
var sid = sforce.connection.sessionId;
document.getElementById('output').innerHTML = +sid;
}
</script>
</head>
<body onload="initPage()">
<h1>Session id is: <span id="output"></span></h1>
</body>
</html>

If a Salesforce user opens this file, I want their Session ID to show up on the page. I have tried to do this, but I keep getting back "0" in my output (i.e. the page says "Session id is: 0").

 

Am I doing this wrong? Is there any way to make this happen?

 

Thanks for any info you can provide.

 

-- Robert 

 

Message Edited by rtscott on 09-01-2009 02:16 PM
Message Edited by rtscott on 09-01-2009 02:18 PM
Message Edited by rtscott on 09-01-2009 02:20 PM
  • September 01, 2009
  • Like
  • 0

Hello All,

 

We would like to setup Salesforce.com to deliver auto-response messages on Email-To-Case created Cases to addresses other than the "From" address of the original message. Currently, Salesforce will only deliver an auto-response to the "From" address on the original email. We have a Case trigger than fires on newly created Cases (before insert, before update, after insert, after update) that invokes an Apex class that performs some non-standard Case actions.

 

Is there any way that we can modify the Apex class so that auto-responses are delivered to different/additional addressses outside of the "From" address on the original message? For example, is there a way that we can set it up to deliver an auto-response to the "From" address and any "CC" addresses on the original message?

 

We also have a request to send the auto-response to the "Reply-To" address on the original email. The challenge with this is that there is no specific "Reply-To" field on the EmailMessage object:

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_emailmessage.htm 

 

I found an Idea for this on the Ideas site, but it looks to be pretty dormant:

 

http://ideas.salesforce.com/article/show/10088737/AutoResponse_control_choose_your_destination

 

Anyway, does anybody have ANY ideas on how to accomplish what I have described? Can the auto-responses be controlled through Apex?

 

Thanks in advance for any advice you can offer,

 

-- Rob 

Hello All,

 

I have - what is likely to be - a simple question:

 

I am setting up an Apex trigger to create Customer Portal Users from Contacts. When I create the Customer Portal User, I need to assign an 'Alias' for the new User account. I need to come up with a way to create aliases that are unique, so that my trigger doesn't fail when it tries to create a Portal User using an alias that already exists. I'm thinking I need to somehow use a random number in the Alias. So far I have this:

 

String alias = ''; if (c.FirstName != null) alias = 'GP-' + c.FirstName.substring(0,3) + c.LastName.substring(0,2); else alias = 'GP-' + c.LastName.substring(0,2);

 

Keep in mind that the 'Alias' field on the User can only be a 8 characters max. What would be best best way to make unique aliases using a random string? (In my example, there is a 'CP-' prefix for "Customer Portal" - I don't necessarily need that.)

 

Here is the full create portal user code, if interested (please feel free to point out any glaring errors - I am new to this!):

 

if (createflag) { String alias = ''; if (c.FirstName != null) alias = 'GP-' + c.FirstName.substring(0,3) + c.LastName.substring(0,2); else alias = 'GP-' + c.LastName.substring(0,2); Database.DMLOptions dmo = new Database.DMLOptions(); dmo.EmailHeader.triggerUserEmail = true; User u = new User(Alias=alias, Email=c.email, FirstName=c.FirstName, LastName=c.LastName, Username=c.Email, ProfileId='00e60000000abCD', LocaleSidKey='en_US', TimezoneSidKey='America/Los_Angeles', ContactId=c.Id, EmailEncodingKey='UTF-8', LanguageLocaleKey='en_US'); ulist.add(u); u.setOptions(dmo); contactIds.add(c.Id); }

 

Message Edited by rtscott on 04-30-2009 12:34 PM

Hello,

 

I am building a Visualforce page that is bound to the Case standard controller. This page is replacing the standard New Case page in Salesforce.com. I want to include an input that allows users to add an attachment to their Case when they are creating the record using my page. I already have a controller extension that this page is using to enhance the New Case process. I see that there was a new "apex:inputFile" component included in the Winter 09 release that allows me to do this. The documentation gives me the following usage example:

 

(from: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_inputFile.htm)

 

 

<; Page: --><apex:page standardController="Document" extensions="documentExt"><-- Upload a file and put it in your personal documents folder--> <apex:messages /> <apex:form id="theForm"> <apex:pageBlock> <apex:pageBlockSection> <apex:inputFile value="{!document.body}" filename="{!document.name}"/> <apex:commandButton value="save" action="{!save}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form></apex:page> /*** Controller ***/public class documentExt { public documentExt(ApexPages.StandardController controller) { Document d = (Document) controller.getRecord(); d.folderid = UserInfo.getUserId(); //this puts it in My Personal Documents } }

 

However, this code assumes that the page is bound to the Document standard controller. Also, since the Case record is not yet created, I cannot specify the parent ID of the Case for my attachment since it does not exist yet (remember, this page replaces the standard New Case page.)

 

Can someone explain to me how I would modify my controller extension to make the "apex:inputFile" component work in this scenario? I'm planning on adding this to my Visualforce page:

 

<apex:pageBlockSectionItem> <apex:outputLabel value="Add attachment:" /> <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" /> <apex:commandButton value="save" action="{!save}" /></apex:pageBlockSectionItem>

 

 

 but I know that I will need to modify my controller extension to make this work. Also, if I use:

 

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

 

 

how will it know to just save the attachment, and not the entire Case page?

 

Thanks for any help that you can provide. I'm pretty new to Visualforce/Apex development, so examples of how to make this work would be greatly appreciated! :)

 

Thanks,

 

-- Rob 

 

Hello All,

I want to setup "indicator" fields on the Case object that indicate NEW Case Comments or Emails exist on a Case. The idea is that when a support rep clicks on the Cases tab to view a list of cases they own, there will be 'New Comment' and 'New Email' columns that have a visual indicator next to each case that indicate there are new Comments or Emails on the Case. The indicator could be a checkbox, or a colored dot, or something similar.

Salesforce appears to have this functionality built-in to some degree:

- For Case Comments, when a new comment is added to a Case through the Self-Service portal or Customer Portal,  there will be an icon at the top of the Case (next to the Case Number heading) that indicates there is a new comment on the case. See below image  - new-comment-email.gif - for example. When a Case Owner views the case, this icon goes away - I have to assume that the act of viewing the case changed the "status" of the comment to make the icon go away.

- For Emails, with email-to-case enabled, when a new email is received and associated with a Case, the email in the Emails related list has a Status of "New". See below image - new-comment-email.gif - for example. When the Case Owner views the email, the Status changes from "New" to "Read". The act of viewing the email has changed the Status value of the email.

I would like to leverage this functionality are create custom Case field "indicators" that I can put on list views. For Case Comments, I would like for the indicator to show new Case Comments made by ANY person, not just Self-Service/Customer Portal users.

Does anyone know how I would acheive this? How can I build a field that indicates the existence of New Case Comments or Emails on Cases?

Any details or advice that you can provide would be greatly appreciated.

Thanks,

-- Rob 

new-comment-email.gif 

Hello All,

 

I want to setup "indicator" fields on the Case object that indicate NEW Case Comments or Emails exist on a Case. The idea is that when a support rep clicks on the Cases tab to view a list of cases they own, there will be 'New Comment' and 'New Email' columns that have a visual indicator next to each case that indicate there are new Comments or Emails on the Case. The indicator could be a checkbox, or a colored dot, or something similar.

 

Salesforce appears to have this functionality built-in to some degree:

 

- For Case Comments, when a new comment is added to a Case through the Self-Service portal or Customer Portal,  there will be an icon at the top of the Case (next to the Case Number heading) that indicates there is a new comment on the case. See attached image  - new-comment-email.gif - for example. When a Case Owner views the case, this icon goes away - I have to assume that the act of viewing the case changed the "status" of the comment to make the icon go away.

 

- For Emails, with email-to-case enabled, when a new email is received and associated with a Case, the email in the Emails related list has a Status of "New". See attached image - new-comment-email.gif - for example. When the Case Owner views the email, the Status changes from "New" to "Read". The act of viewing the email has changed the Status value of the email.

 

I would like to leverage this functionality are create custom Case field "indicators" that I can put on list views. For Case Comments, I would like for the indicator to show new Case Comments made by ANY person, not just Self-Service/Customer Portal users.

 

Does anyone know how I would acheive this? How can I build a field that indicates the existence of New Case Comments or Emails on Cases?

 

Any details or advice that you can provide would be greatly appreciated.

 

Thanks,

 

-- Rob 

Hello,

I have done a fair amount of research on this topic, but I am still unclear on how to accomplish the following two things:

1. We are using Salesforce's Customer Portal product. We have built two custom objects and are displaying tabs for these custom objects in our Customer Portal. We have also built controller extensions for these custom objects to extend the functionality of the standard controllers. We want to display Visualforce pages when a user clicks on the tabs for these objects in the Customer Portal. In order to override the tabs for these objects with a Visualforce page, we cannot specify a standardContoller using the same object name in the Visualforce page. If we do, the VF page is not given as an option when you try to override the tab. If the VF page does not have a standardController specified, we can use it to override the tab, but we cannot link our controller extension to the page.

For example, I have a custom object called "Contact Us". I want to override the tab for this object with the following Visualforce page:

Code:
<apex:page standardController="Contact_Us__c" extensions="ContactUsExtensions">
  <h1>Custom Contact Us Page</h1>
</apex:page>

I am not given the option to override the "Contact Us" custom object tab with this page. It will only allow me to override it with a page that does not have a standardController specified. Why is that?

2. In addition to above, we need to show the standard "Contact Us" homepage when a user clicks on the "Contact Us" tab in the regular Salesforce interface, and we need to show a custom Visualforce page when a user clicks on the "Contact Us" tab in the Customer Portal. To do this, we created a new controller, ContactOverride - here is the code:

Code:
public class ContactOverride {
    public ContactOverride() {

    }


   String recordId;

public ContactOverride(ApexPages.StandardController
       controller) {recordId = controller.getId();}

public PageReference redirect() {
  Profile p = [select name from Profile where id =
               :UserInfo.getProfileId()];
  if ('Customer Portal User'.equals(p.name)
      || 'Customer Portal Test'.equals(p.name))
      {
       PageReference customPage =
Page.PortalContactUs;
       customPage.setRedirect(true);
       customPage.getParameters().put('id', recordId);
       return customPage;
      } else {
         return null; //otherwise stay on the same page
      }
   }
}

This code was lifted directly from the Force.com Cookbook (pages 53-56) and modified slightly to fit our needs. Basically, the controller sends users in the profiles "Customer Portal User" or "Customer Portal Test" to a custom Visualforce page (PortalContactUs) when they click on the "Contact Us" tab. If the user is not in either of those profiles, they stay on the same page.

Then, we created a new Visualforce page called ContactRedirect that looks like this:

Code:
<apex:page controller="ContactOverride" action="{!redirect}">
   <apex:detail />
</apex:page>

and override the tab on the "Contact Us" custom object with this page.

Again, we took this code from the Force.com Cookbook (pages 53-56) and modified it slightly. (The instructions in the Cookbook tell us to set a standardController and use the override controller we built as an extension. However, we cannot override the tab with a standardController set as explained in issue 1.)

This seems to work, but we would prefer that users who are not in the "Customer Portal User" or "Customer Portal Test" profiles see the standard "Contact Us" homepage under the "Contact Us" tab, and not the "ContactRedirect" VF page. Is there a way to change the controller (ContactOverride) to do this?

What are the best solutions to these issues?

Thanks for any help that you can offer,

-- Robert
 

 

Hello,

I put an override on the "View" link for one of my custom objects. I'm sending people to a custom Visualforce page when they choose to View a record from a list view. I am trying to re-create the record detail page in Visualforce and want to put a "Back to List: [Object Name]" link right under the sectionHeader - just like you would see on a standard record detail page. I think you can do this using the "apex:commandLink" component, but cannot figure out what the correct syntax is. Does anyone know how to do this in Visualforce?

Thanks,

Rob

I have an APEX Trigger that runs when a Task is created/updated, so it can update the related Case. 

 

Somehow, the trigger is causing the Case Assignment Rules to re-fire, but I don't know what.  Any thoughts?

 

 

 

trigger caseLastActivityDate on Task (after insert, after update) { Map<String, Task> tMap = new Map<String, Task>(); for (Task t : System.Trigger.new) { String whatId = t.WhatId; System.debug('whatId is ' + whatId); if(whatId <> null && whatId.startsWith('500') == true) { Case c = [select Id from Case where Id = :whatId]; if(c.Id <> null) { c.Last_Activity_Date__c = t.LastModifiedDate; update c; } } } }

 

 

 

Hello All,

 

I would like to create an HTML file that a Salesforce user can click on while logged into the system that will grab the user's Session ID and append it to the document. I believe I can do this with the AJAX Toolkit, but I am not sure how to make it happen. For example: let's say that I attach the following HTML file to a Case in Salesforce.com:

<!doctype html>
<html>
<head>
<script src="/soap/ajax/16.0/connection.js" type="text/javascript"></script>
<script type="text/javascript">
function initPage() {
var sid = sforce.connection.sessionId;
document.getElementById('output').innerHTML = +sid;
}
</script>
</head>
<body onload="initPage()">
<h1>Session id is: <span id="output"></span></h1>
</body>
</html>

If a Salesforce user opens this file, I want their Session ID to show up on the page. I have tried to do this, but I keep getting back "0" in my output (i.e. the page says "Session id is: 0").

 

Am I doing this wrong? Is there any way to make this happen?

 

Thanks for any info you can provide.

 

-- Robert 

 

Message Edited by rtscott on 09-01-2009 02:16 PM
Message Edited by rtscott on 09-01-2009 02:18 PM
Message Edited by rtscott on 09-01-2009 02:20 PM
  • September 01, 2009
  • Like
  • 0

Hello All,

 

I have - what is likely to be - a simple question:

 

I am setting up an Apex trigger to create Customer Portal Users from Contacts. When I create the Customer Portal User, I need to assign an 'Alias' for the new User account. I need to come up with a way to create aliases that are unique, so that my trigger doesn't fail when it tries to create a Portal User using an alias that already exists. I'm thinking I need to somehow use a random number in the Alias. So far I have this:

 

String alias = ''; if (c.FirstName != null) alias = 'GP-' + c.FirstName.substring(0,3) + c.LastName.substring(0,2); else alias = 'GP-' + c.LastName.substring(0,2);

 

Keep in mind that the 'Alias' field on the User can only be a 8 characters max. What would be best best way to make unique aliases using a random string? (In my example, there is a 'CP-' prefix for "Customer Portal" - I don't necessarily need that.)

 

Here is the full create portal user code, if interested (please feel free to point out any glaring errors - I am new to this!):

 

if (createflag) { String alias = ''; if (c.FirstName != null) alias = 'GP-' + c.FirstName.substring(0,3) + c.LastName.substring(0,2); else alias = 'GP-' + c.LastName.substring(0,2); Database.DMLOptions dmo = new Database.DMLOptions(); dmo.EmailHeader.triggerUserEmail = true; User u = new User(Alias=alias, Email=c.email, FirstName=c.FirstName, LastName=c.LastName, Username=c.Email, ProfileId='00e60000000abCD', LocaleSidKey='en_US', TimezoneSidKey='America/Los_Angeles', ContactId=c.Id, EmailEncodingKey='UTF-8', LanguageLocaleKey='en_US'); ulist.add(u); u.setOptions(dmo); contactIds.add(c.Id); }

 

Message Edited by rtscott on 04-30-2009 12:34 PM

Not sure if it was intended but allowing a Customer Portal User edit access on Cases so that they can add Attachements and Comments to a Case allows them to edit the entire Case via the Edit Action on the enhancedList. This is a big no no and I do not know how to stop them from editing the entire Case while still allowing them to add Attachments and Comments. I need to use the enhanceList functionality for sorting purposes on the list.

 

Is there a way to stop the edit action on the enhancedList?

 

Hello,

 

I am building a Visualforce page that is bound to the Case standard controller. This page is replacing the standard New Case page in Salesforce.com. I want to include an input that allows users to add an attachment to their Case when they are creating the record using my page. I already have a controller extension that this page is using to enhance the New Case process. I see that there was a new "apex:inputFile" component included in the Winter 09 release that allows me to do this. The documentation gives me the following usage example:

 

(from: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_inputFile.htm)

 

 

<; Page: --><apex:page standardController="Document" extensions="documentExt"><-- Upload a file and put it in your personal documents folder--> <apex:messages /> <apex:form id="theForm"> <apex:pageBlock> <apex:pageBlockSection> <apex:inputFile value="{!document.body}" filename="{!document.name}"/> <apex:commandButton value="save" action="{!save}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form></apex:page> /*** Controller ***/public class documentExt { public documentExt(ApexPages.StandardController controller) { Document d = (Document) controller.getRecord(); d.folderid = UserInfo.getUserId(); //this puts it in My Personal Documents } }

 

However, this code assumes that the page is bound to the Document standard controller. Also, since the Case record is not yet created, I cannot specify the parent ID of the Case for my attachment since it does not exist yet (remember, this page replaces the standard New Case page.)

 

Can someone explain to me how I would modify my controller extension to make the "apex:inputFile" component work in this scenario? I'm planning on adding this to my Visualforce page:

 

<apex:pageBlockSectionItem> <apex:outputLabel value="Add attachment:" /> <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" /> <apex:commandButton value="save" action="{!save}" /></apex:pageBlockSectionItem>

 

 

 but I know that I will need to modify my controller extension to make this work. Also, if I use:

 

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

 

 

how will it know to just save the attachment, and not the entire Case page?

 

Thanks for any help that you can provide. I'm pretty new to Visualforce/Apex development, so examples of how to make this work would be greatly appreciated! :)

 

Thanks,

 

-- Rob