• bblay
  • NEWBIE
  • 75 Points
  • Member since 2010

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 16
    Replies

I would like to add an attachments section to my custom visual force page. I would also like to display the attachment on the next page.  Here is what I have so far. Please steer me in the right direction

 

 

<apex:page controller="leadController" tabStyle="Referral__c">
    <script>
        function confirmCancel() {
            var isCancel = confirm("Are you sure you wish to cancel?");
            if (isCancel) return true;
  
        return false;
        }
    </script>
    <apex:sectionHeader title="Lead Informaiton" subtitle="Step 2 of 3"/>
    <apex:relatedList list="NotesAndAttachments"/>
    <apex:form >
    <apex:pageBlock title="Candidate Information" mode="edit">
        <apex:pageBlockButtons >
            <apex:commandButton action="{!Leadstep3}" value="Next"/>
            <apex:commandButton action="{!Leadstep1}" value="Previous"/>
            <apex:commandButton action="{!leadcancel}" value="Cancel"
                                onclick="return confirmCancel()" immediate="true"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Candidate Information">
            <apex:inputField id="candidateName" value="{!referral.Candidate_Name__c}"/>
            <apex:inputField id="candidateEmail" value="{!referral.Candidate_Email__c}"/>
            <apex:inputField id="candidatecellPhone" value="{!referral.Candidate_Cell_Phone__c}"/>
            <apex:inputField id="candidateCity" value="{!referral.Candidate_City__c}"/>
            <apex:inputField id="candidateState" value="{!referral.Candidate_State__c}"/>
            <apex:inputField id="areaofExperties" value="{!referral.Area_of_Expertise__c}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

 

In order to free up licenses easily I want to allow Authenticated Website users to make their account inactive so I don't have to personally uncheck the 'Active' box on their User information page.

 

Below is some code I thought would work perfectly and make things very easy without having to create a customer controller until I got the error "Error: Cannot de-activate self" 

 

 

<apex:page standardStylesheets="false" sidebar="false"  standardController="User" showHeader="false"  >

Name: {!User.firstname}

<apex:form >

UNCHECK to make account inactive. <apex:inputField value="{!User.isactive}"/>

<apex:commandButton value="Finish Deletion" action="{!quicksave}"/>

</apex:form>

</apex:page>

 

Does anyone know of a simple way around this? Thanks!

 

  • March 01, 2011
  • Like
  • 0

I was curious if someone might be able to help me limit the attachment size a user is allowed to upload on my VF page to only 2MB. I found this code online and have no idea where to start. I'm thinking it would likely just be a couple lines of code to check the file size and display an error message if more than 2MB but I'm not sure how to do this. 

 

Any ideas or help would certainly be appreciated! Thanks!

 

 

public class VFFileUpload  
{  
    public Id recId {get;set;}  
      
    public VFFileUpload(ApexPages.StandardController ctlr)  
    {  
       recId = ctlr.getRecord().Id;       
    }  
      
    public string fileName {get;set;}  
      
    public Blob fileBody {get;set;}  
    
    private integer fileSize;
    
    public Blob getFileBody()
    {
        return this.fileBody;
    }
    
    public void setFileBody(Blob fileBody)
    {
        this.fileBody = fileBody;
        setFileSize(this.fileBody.size());
    }

    public Integer getFileSize()
    {
        return this.fileSize;
    }

    public void setFileSize(Integer fileSize)
    {
        this.fileSize = fileSize;
    }
                                                     
    public PageReference UploadFile()  
    {  
        PageReference pr;  
        if(fileBody != null && fileName != null)  
        {  
        
          Attachment myAttachment  = new Attachment();  
          myAttachment.Body = fileBody;  
          myAttachment.Name = fileName;  
          myAttachment.ParentId = recId;  
          insert myAttachment;  
  
          Member__c m = [select id from Member__c WHERE     ID=:System.currentPageReference().getParameters().get('id')];
          List<Attachment> a = [select id from attachment where parentid = :m.id];
 
 
          if(a.size() > 7){
            delete a;         
          }                                   
                   
          PageReference page = ApexPages.currentPage();
          page.setRedirect(true);
          return page;    
        }  
        return null; 
    }    
}

 

 

  • February 28, 2011
  • Like
  • 0

I'm trying to change my domain name mydomain.force.com to mydomain.com 

 

I've read http://www.adnsandbox.com/df08/sites_using_custom_domain.pdf but the issue I'm having is creating those CNAME records on Go Daddy.

 

On Godaddy I have the option to change the A (Host) record from @ to an IP address which from reading articles on their site is what I would need to do but instead of an IP address I think I need to have it say mydomain.force.com but it'll only let me put an IP address in.

 

If anyone has experience with this or might be able to offer suggestions I'd highly appreciate it. Currently I'm forwarding mydomain.com to mydomain.force.com and this in turn I believe has resulted in my site not being searchable on Google anymore because I do not have the custom domain configured (my site has been running for about 3 months now).

 

Thanks!

  • December 04, 2010
  • Like
  • 0

Does anyone know how I can delete an attachment on a VF page by just using a link? I allow my users to upload images to be displayed and I want them to be able to just click a link or small button that allows them to delete the image.

 

I know I can use the <apex:listViews type="attachment"/> and see all the attachments and get the Edit | Del | View but I just want the delete button. While working with my DE account I was able to use this:

 

 

<apex:repeat value="{!Member__c.attachments}" var="attachment" rows="1" first="0"> 
    
<a href="/setup/own/deleteredirect.jsp?delID={!attachment.ID}" onclick="confirmation4()">Delete</a>

<img src="{!URLFOR($Action.Attachment.Download, attachment.Id)}"/>
</apex:repeat>

 

 

and I was able to delete with no issues. But with keeping this same code in my Enterprise Production Trial it doesn't seem to work. I highlighted the delete link in the listview to get the URL and created this link:

 

<a href="/setup/own/deleteredirect.jsp?id={!Member__c.id}&delID={!attachment.ID}">Del.</a>

 

but I keep getting an error message saying "The attempted delete was invalid for your session. Please confirm your delete." and then there's a delete link right below but I click on it and nothing happens.

 

Any ideas? I'm stuck.... Thanks!

  • August 09, 2010
  • Like
  • 0

Has anyone had the issue of mult-select picklists not showing in Internet Explorer 7 on Visualforce pages?

 

I've tried in Chrome, Firefox, Safari, and IE 8 and everything seems to show up with no issues, but in IE 7 the multi-select picklists are not even showing up on the page.

 

Any ideas on how to fix this would be greatly appreciated or suggestions on where to look. This is sort of a major issue for me as some of these fields are required on my pages and as you know many people still are using IE 7.

 

Thanks!

  • August 03, 2010
  • Like
  • 0

I'm trying to add the currently logged in user to a text field of mine which then displays a list of other users who have clicked the 'Add Name' button on a particular custom object of mine for events (Date__c). 

 

My javascript below works perfectly how I would like it to work meaning it adds the user's name to the next line in a long text area field after the user clicks the button.

 

 

<apex:form> 
<textarea name="textarea1">{!Date__c.Date_List__c}</textarea><br/> 
<input type="button" name="insert" value="Add Name" onclick="this.form.textarea1.value=this.form.textarea1.value.concat('\r\n{!$User.communitynickname}');"/>  
</apex:form>

 

 

My issue though is when I try to convert the html textarea into an <apex:inputtextarea> tag so I can then save the info. I tried the below code and it looks exactly the same on the VF page as the above code but it doesn't add the user name to the inputtextarea field.

 

 

<apex:form> 
<apex:inputTextarea id="textarea1" value="{!Date__c.Date_List__c}"/><br/>
<input type="button" name="insert" value="Add Name" onclick="this.form.textarea1.value=this.form.textarea1.value.concat('\r\n{!$User.communitynickname}');"/>  
</apex:form> 

 

 

Any thoughts on this? I have a feeling it's something simple but I'm just not sure. Thanks for any ideas or suggestions!

 

 

  • July 20, 2010
  • Like
  • 0

I have a 'my account' type of page where users can create a profile if they haven't made one already and then if they have created a profile (custom object of mine Member__c) they have the option to update their profile or delete it. 

 

Currently I have a query (updateP) that will select the logged in user and compare if their first name (which will always be unique in my case) has already been created for a username (Member__c.Name) for a profile and if so it displays a link to update their profile. The trouble I'm having is my other query (editP). I only want the create profile link to be available if the first name has not been used to create a profile username.

 

I have tried using the != for not equal to for the editP query which is exactly what I'm trying to do but I keep getting a compile error: unexpected token: 'Userinfo.getFirstName' which doesn't make sense to me because the other query displays the right info perfectly on my page...

 

Does anyone has some ideas as to what I might be doing wrong here? Thank you!!

 

 

 

public class myaccount {

    public myaccount() {
    }

    public myaccount(ApexPages.StandardController controller) {
    }

public String ObjectType { get; set; }
Member__c[] updateP;
Member__c[] editP;
public void initList() {
query();
}
Public PageReference query() {

editP = [SELECT Name FROM Member__c WHERE name != Userinfo.getFirstName()] ;

updateP = [SELECT Name FROM Member__c WHERE name=:Userinfo.getFirstName()] ;

 return null;
 }
 public Member__c[] getMember() {
return updateP;

}

public Member__c[] getEdit() {
return editP;

}
}

 

 

 

  • July 20, 2010
  • Like
  • 0

Is it possible to limit the file attachment size on a custom object? 

 

I believe I read that the current Salesforce limit is either 5 or 10mb but I'd like to limit it to only 2mb per attachment as I have users that will be uploading multiple pictures and I don't want my file storage usage limits to be exceeded as some people are capturing images on their 13 megapixel cameras at 6mb a picture. I want to be able to limit these types of people uploading images to just the 2mb.

 

I'm currently working through a developer edition account and my file storage limit is 20mb, but in the future I'll be upgrading but will be having hundreds of users uploading images and cannot afford to take up storage space. As also each user is displayed on a search page I created with one of their images they've uploaded and I need to cut down on the page's loading time too.

 

Also, is it possible to limit the number of attachments that can be uploaded, to say 7 attachments?

 

Thanks for any ideas you might be able to share!!  

  • July 02, 2010
  • Like
  • 0

In the To part of my send email page in VF below I want to be able to populate the input field with an email address that's recorded at {!Member__c.Email__c}  that someone has entered when creating a new record in my Member object.

 

Right now I have to manually type in an address. Everything works right and email gets sent but it's important that when sending email users don't need to type in this address. 

 

When I change the value for the inputText field in VF from value={!emailTo} to value={!Member__c.Email__c} the email address is shown but there is no valid To address to be able to send an email in mail.setToAddress so it fails.

 

Any help or ideas on this would be much appreciated!!

 

 

 

Apex

 

public class SendEmailPage {

    public SendEmailPage(ApexPages.StandardController controller) {
    }

public String emailTo {get; set;}
public String emailSubject {get; set;}
public String emailBody {get; set;}
public String response {get; set;}
 
public PageReference sendEmail(){

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

mail.setToAddresses(new String[] {emailTo});           
                                                
mail.setOrgWideEmailAddressId('0D2A0000000PBAC'); mail.setReplyTo('no-reply@company.com'); mail.setSubject(emailSubject); mail.setHtmlBody(emailBody); try{ Messaging.SendEmailResult[] resultMail = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); if(resultMail[0].isSuccess()) { PageReference page = System.Page.messagesent; page.setRedirect(true); return page; } else{ response = resultMail[0].getErrors().get(0).getMessage(); } }catch(System.EmailException ex){ response = ex.getMessage(); } return null; } }

 

 

VF Code

 

<apex:form >

To: <apex:outputField value="{!Member__c.Name}" /><br/>
<apex:inputText value="{!emailTo}" style="width: 200px"/><br/>

Subject:<br/>
<apex:inputtext value="{!emailSubject}" style="width: 400px"></apex:inputtext><br/><br/>

Body:<br/>
<apex:inputtextarea value="{!emailBody}" style="width: 400px; height: 100px"></apex:inputtextarea><br/>


<apex:commandbutton value="Send Message" action="{!sendEmail}" rerender="statusMail"></apex:commandbutton>
<apex:outputpanel id="statusMail" layout="block">
<strong><apex:outputtext value="{!response}"></apex:outputtext></strong>
</apex:outputpanel>
</apex:form>

 

 

 

 

  • May 25, 2010
  • Like
  • 0

I would like to add an attachments section to my custom visual force page. I would also like to display the attachment on the next page.  Here is what I have so far. Please steer me in the right direction

 

 

<apex:page controller="leadController" tabStyle="Referral__c">
    <script>
        function confirmCancel() {
            var isCancel = confirm("Are you sure you wish to cancel?");
            if (isCancel) return true;
  
        return false;
        }
    </script>
    <apex:sectionHeader title="Lead Informaiton" subtitle="Step 2 of 3"/>
    <apex:relatedList list="NotesAndAttachments"/>
    <apex:form >
    <apex:pageBlock title="Candidate Information" mode="edit">
        <apex:pageBlockButtons >
            <apex:commandButton action="{!Leadstep3}" value="Next"/>
            <apex:commandButton action="{!Leadstep1}" value="Previous"/>
            <apex:commandButton action="{!leadcancel}" value="Cancel"
                                onclick="return confirmCancel()" immediate="true"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Candidate Information">
            <apex:inputField id="candidateName" value="{!referral.Candidate_Name__c}"/>
            <apex:inputField id="candidateEmail" value="{!referral.Candidate_Email__c}"/>
            <apex:inputField id="candidatecellPhone" value="{!referral.Candidate_Cell_Phone__c}"/>
            <apex:inputField id="candidateCity" value="{!referral.Candidate_City__c}"/>
            <apex:inputField id="candidateState" value="{!referral.Candidate_State__c}"/>
            <apex:inputField id="areaofExperties" value="{!referral.Area_of_Expertise__c}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

 

In order to free up licenses easily I want to allow Authenticated Website users to make their account inactive so I don't have to personally uncheck the 'Active' box on their User information page.

 

Below is some code I thought would work perfectly and make things very easy without having to create a customer controller until I got the error "Error: Cannot de-activate self" 

 

 

<apex:page standardStylesheets="false" sidebar="false"  standardController="User" showHeader="false"  >

Name: {!User.firstname}

<apex:form >

UNCHECK to make account inactive. <apex:inputField value="{!User.isactive}"/>

<apex:commandButton value="Finish Deletion" action="{!quicksave}"/>

</apex:form>

</apex:page>

 

Does anyone know of a simple way around this? Thanks!

 

  • March 01, 2011
  • Like
  • 0

Hi all,

 

We have a public site where all pages are available to the guest user profile.  When accessing this site through the browser, we've never seen an authorization required page.  However, when google bots attempt to crawl the site we get intermittent 401 Authorization Required responses.  

 

I've tried hitting the site from seoconsultants check header tool, and I get intermittent 401 and 302 responses.  The 302 that I've just received is saying that the page has been moved to : cust_maint/site_down/maintenance.html.   Web analyzer gives the same results, yet using fiddler shows that the browsers are receiving nothing but 200 responses.

 

Has anyone else seen behaviour like this?  Its proving difficult to track down as every time I raise a case with support, they close it saying they don't support the google client.  However, that's not the issue here - I need to understand why the Salesforce server is returning the responses that it is.

 

 

 

 

I was curious if someone might be able to help me limit the attachment size a user is allowed to upload on my VF page to only 2MB. I found this code online and have no idea where to start. I'm thinking it would likely just be a couple lines of code to check the file size and display an error message if more than 2MB but I'm not sure how to do this. 

 

Any ideas or help would certainly be appreciated! Thanks!

 

 

public class VFFileUpload  
{  
    public Id recId {get;set;}  
      
    public VFFileUpload(ApexPages.StandardController ctlr)  
    {  
       recId = ctlr.getRecord().Id;       
    }  
      
    public string fileName {get;set;}  
      
    public Blob fileBody {get;set;}  
    
    private integer fileSize;
    
    public Blob getFileBody()
    {
        return this.fileBody;
    }
    
    public void setFileBody(Blob fileBody)
    {
        this.fileBody = fileBody;
        setFileSize(this.fileBody.size());
    }

    public Integer getFileSize()
    {
        return this.fileSize;
    }

    public void setFileSize(Integer fileSize)
    {
        this.fileSize = fileSize;
    }
                                                     
    public PageReference UploadFile()  
    {  
        PageReference pr;  
        if(fileBody != null && fileName != null)  
        {  
        
          Attachment myAttachment  = new Attachment();  
          myAttachment.Body = fileBody;  
          myAttachment.Name = fileName;  
          myAttachment.ParentId = recId;  
          insert myAttachment;  
  
          Member__c m = [select id from Member__c WHERE     ID=:System.currentPageReference().getParameters().get('id')];
          List<Attachment> a = [select id from attachment where parentid = :m.id];
 
 
          if(a.size() > 7){
            delete a;         
          }                                   
                   
          PageReference page = ApexPages.currentPage();
          page.setRedirect(true);
          return page;    
        }  
        return null; 
    }    
}

 

 

  • February 28, 2011
  • Like
  • 0

I've been working with network solutions on how to point a custom domain to a force.com site.  From what I understand, a cname record will only point the www version of the domain to the force.com site.  The non www version will go nowhere.  According to Network Solutions.

 

Does anyone out there have experience with this and know a way around it?  Is that true?  Certainly there are companies whose domains are registered with Network Solutions and are effectively using sites.  I really appreciate any guidance.  Thanks! 

I'm trying to change my domain name mydomain.force.com to mydomain.com 

 

I've read http://www.adnsandbox.com/df08/sites_using_custom_domain.pdf but the issue I'm having is creating those CNAME records on Go Daddy.

 

On Godaddy I have the option to change the A (Host) record from @ to an IP address which from reading articles on their site is what I would need to do but instead of an IP address I think I need to have it say mydomain.force.com but it'll only let me put an IP address in.

 

If anyone has experience with this or might be able to offer suggestions I'd highly appreciate it. Currently I'm forwarding mydomain.com to mydomain.force.com and this in turn I believe has resulted in my site not being searchable on Google anymore because I do not have the custom domain configured (my site has been running for about 3 months now).

 

Thanks!

  • December 04, 2010
  • Like
  • 0

Has anyone had the issue of mult-select picklists not showing in Internet Explorer 7 on Visualforce pages?

 

I've tried in Chrome, Firefox, Safari, and IE 8 and everything seems to show up with no issues, but in IE 7 the multi-select picklists are not even showing up on the page.

 

Any ideas on how to fix this would be greatly appreciated or suggestions on where to look. This is sort of a major issue for me as some of these fields are required on my pages and as you know many people still are using IE 7.

 

Thanks!

  • August 03, 2010
  • Like
  • 0

I'm trying to add the currently logged in user to a text field of mine which then displays a list of other users who have clicked the 'Add Name' button on a particular custom object of mine for events (Date__c). 

 

My javascript below works perfectly how I would like it to work meaning it adds the user's name to the next line in a long text area field after the user clicks the button.

 

 

<apex:form> 
<textarea name="textarea1">{!Date__c.Date_List__c}</textarea><br/> 
<input type="button" name="insert" value="Add Name" onclick="this.form.textarea1.value=this.form.textarea1.value.concat('\r\n{!$User.communitynickname}');"/>  
</apex:form>

 

 

My issue though is when I try to convert the html textarea into an <apex:inputtextarea> tag so I can then save the info. I tried the below code and it looks exactly the same on the VF page as the above code but it doesn't add the user name to the inputtextarea field.

 

 

<apex:form> 
<apex:inputTextarea id="textarea1" value="{!Date__c.Date_List__c}"/><br/>
<input type="button" name="insert" value="Add Name" onclick="this.form.textarea1.value=this.form.textarea1.value.concat('\r\n{!$User.communitynickname}');"/>  
</apex:form> 

 

 

Any thoughts on this? I have a feeling it's something simple but I'm just not sure. Thanks for any ideas or suggestions!

 

 

  • July 20, 2010
  • Like
  • 0

I have a 'my account' type of page where users can create a profile if they haven't made one already and then if they have created a profile (custom object of mine Member__c) they have the option to update their profile or delete it. 

 

Currently I have a query (updateP) that will select the logged in user and compare if their first name (which will always be unique in my case) has already been created for a username (Member__c.Name) for a profile and if so it displays a link to update their profile. The trouble I'm having is my other query (editP). I only want the create profile link to be available if the first name has not been used to create a profile username.

 

I have tried using the != for not equal to for the editP query which is exactly what I'm trying to do but I keep getting a compile error: unexpected token: 'Userinfo.getFirstName' which doesn't make sense to me because the other query displays the right info perfectly on my page...

 

Does anyone has some ideas as to what I might be doing wrong here? Thank you!!

 

 

 

public class myaccount {

    public myaccount() {
    }

    public myaccount(ApexPages.StandardController controller) {
    }

public String ObjectType { get; set; }
Member__c[] updateP;
Member__c[] editP;
public void initList() {
query();
}
Public PageReference query() {

editP = [SELECT Name FROM Member__c WHERE name != Userinfo.getFirstName()] ;

updateP = [SELECT Name FROM Member__c WHERE name=:Userinfo.getFirstName()] ;

 return null;
 }
 public Member__c[] getMember() {
return updateP;

}

public Member__c[] getEdit() {
return editP;

}
}

 

 

 

  • July 20, 2010
  • Like
  • 0

Is it possible to limit the file attachment size on a custom object? 

 

I believe I read that the current Salesforce limit is either 5 or 10mb but I'd like to limit it to only 2mb per attachment as I have users that will be uploading multiple pictures and I don't want my file storage usage limits to be exceeded as some people are capturing images on their 13 megapixel cameras at 6mb a picture. I want to be able to limit these types of people uploading images to just the 2mb.

 

I'm currently working through a developer edition account and my file storage limit is 20mb, but in the future I'll be upgrading but will be having hundreds of users uploading images and cannot afford to take up storage space. As also each user is displayed on a search page I created with one of their images they've uploaded and I need to cut down on the page's loading time too.

 

Also, is it possible to limit the number of attachments that can be uploaded, to say 7 attachments?

 

Thanks for any ideas you might be able to share!!  

  • July 02, 2010
  • Like
  • 0

Hi all, 

 

After some poking and prodding, I've gotten file attachments to work. Files are associated with apprenticeships; here's the code that I'm using for the controller extension

 

 

public PageReference deletefile() {

PageReference pageRef = System.currentPageReference();

apprenticeshipId = pageRef.getParameters().get('id');

ctContactId = pageRef.getParameters().get('ctContactId');

url = '/apex/CTN_Apprenticeship';

 

fileId = System.currentPageReference().getParameters().get('fileId');

attachment = [select Apprenticeship__c.attachment__r.id from Apprenticeship__c where attachment__r.id = 'fileId'];

delete attachment;

 

urlstring = url + '?id=' + apprenticeshipId + '&ctContactId=' + ctContactId;

PageReference ref = new PageReference(urlstring); ref.setRedirect(true); return ref;

}

 

 

 

 

The question is about how users can remove files. How do I query the NotesAndAttachments child object? I've tried a bunch of things, but all seem to throw errors (and googling "NotesAndAttachments" only pulls up minimal results!).

 

Has anyone been through this? Does anyone have suggestions about what a simple query might look like that I could use to populate a deletefile() action, or point me toward a code snippet that might accomplish the same? Thanks so much!

 

--Dave 

 

 

Message Edited by davecruso on 06-03-2009 08:56 AM
Message Edited by davecruso on 06-03-2009 08:57 AM
Message Edited by davecruso on 06-03-2009 08:58 AM