• Charlie Cox
  • NEWBIE
  • 15 Points
  • Member since 2014

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

I am the System Admin for our instance. I am currently developing a visualforce page. The System Admin profile has access to the page and controller.

However when I call my action function I get a "Insufficient Privileges" error message.
User-added image

I investigated further to see that I was getting an Internal Server Error.
User-added image

I have stripped functionality in the apex method the actionFunction calls until it does nothing. See Below:
 

public class UtilApplication {

    public List<List<SelectOption>> display {get;set;}
    public String assigned {get;set;}
    Map <String, Schema.SObjectType> objs {get;set;}
    
    public UtilApplication() {
        
        display = new List<List<SelectOption>>();
        
        objs = Schema.getGlobalDescribe();
        
        List<SelectOption> init_opts = new List<SelectOption>();
        
        // Value | Label
        init_opts.add(new SelectOption('Student_Application__c','Student Application'));
        init_opts.add(new SelectOption('Contact','Contact'));
        
        display.add(init_opts);
        
        System.debug('In constructor');

    }
    
    // method in question
    public void add_object() {
        System.debug('In here');
    }
}
The Visualforce looks like this:
 
<apex:page showHeader="false" sidebar="false" controller="UtilApplication">
    <head>
		<script>
        	function callJS() {
            	console.log("In this");
                select_section();   
            }
        </script>
    </head>  
    <body>
        <apex:form>
            <apex:outputPanel id="configure">
                <apex:outputPanel>
                    <apex:pageBlock title="Select Section">
                        <apex:actionFunction name="select_section" action="{!add_object}" reRender="configure"/>
                            <apex:selectList multiselect="false" value="{!assigned}" size="1" onchange="callJS()">
                                <apex:selectOptions value="{!display[0]}"/>
                            </apex:selectList>
                    </apex:pageBlock>
                </apex:outputPanel>
            </apex:outputPanel>
        </apex:form>
    </body>
</apex:page>

I have used actionFunctions like this before so I am not sure what the issue is.

Any input would be great.

Thanks!

 

This is my test class:

@isTest(seeAllData = true)
public with sharing class NUBSCartControllerTest{
    
    static testMethod void NUBSCartControllerTestMethod() {
       
       Contact c = new Contact();
       c.firstName = 'Charles';
       c.lastName = 'Cox';
       c.email = 'charliecox17@yahoo.com';
       insert c;
       
       Event_Registration__c er = new Event_Registration__c ();
       er.name = 'CharlesConference';
       er.hasPaid__c = false;
       er.Applicant_Name__c = c.id;
       insert er;
       
       Id stnd = Test.getStandardPricebookId();
       
       Product2 p = new Product2();
       p.name = 'Thursday, March 26, Opening Reception';
       insert p;
       
       ConProd_Bridge__c cpb = new ConProd_Bridge__c();
       cpb.Product__c = p.id;
       cpb.Contact__c = c.id;
       insert cpb;
       
       PricebookEntry pbe= new PricebookEntry();
       pbe.Product2Id = p.Id;
       pbe.unitPrice = 30;
       pbe.Pricebook2Id = stnd;
       pbe.isActive = true;
       insert pbe;
       
       Opportunity o = new Opportunity();
       o.Name = 'thisOpp';
       o.Amount = 30;
       o.stageName = 'Prospecting';
       o.closeDate = Date.TODAY().addYears(1);
       o.Contact__c = c.id;
       insert o;
       
       OpportunityLineItem ole = new OpportunityLineItem();
       ole.UnitPrice = 30;
       ole.OpportunityId = o.id;
       ole.PriceBookEntryId = pbe.id;
       ole.Quantity = 1;
       insert ole;
       
       Test.setCurrentPageReference(new PageReference('Page.myPage'));
       System.currentPageReference().getParameters().put('oppId', o.id);
       System.currentPageReference().getParameters().put('isConference', 'true');
     
       NUBSCartController contr = new NUBSCartController();
       
       contr.BillingFirst = 'Charles';
       contr.BillingLast = 'Cox';
       contr.BillingAddress = '26 West';
       contr.BillingCity = 'Austin';
       contr.BillingState = 'Texas';
       contr.BillingCountry  = 'United States';
       contr.BillingPostcode = '78681';
       
       contr.CardType = 'Visa';
       contr.CardNumber = '4111111111111111';
       contr.CardMonth = '12';
       contr.CardYear = '2038';
       contr.CardSecurity = '123';
       
       contr.cancel();     
       contr.preCharge();
       contr.processPayment();
    
       contr.isConference = 'false';
       contr.sendEmails(c);
    }    
}


I get the error 'TestMethod do not support Web service callouts' when I run the test with seeAlldata = true but not when seeAllData = false. I need to have seeAllData = true so I need to figure this error out. I don't see where I am using a web service call...

Any help would be great,

Thanks! 
<apex:inputField styleClass="standardizer" value="{!application.ArrivalDate__c}"/>
User-added image
On my visualforce page I have an inputField asking for a date. ArricalDate__c is a Date Field. I was wondering if there was a way to disable salesforces' default date selector circled in red. Is there a way to replace the thing circled in red with a calendar widget? 

Thanks!

Thanks
Hello All!

I am getting a DML Error attaching an attachment to a custom object in production. It works fine in sandbox just not produciton. Both production and the sandbox use a site

public PageReference uploadDoc() {
      // if no file has been selected, throw error message
      if (attachment.name == null && application.AppRoughDraft__c == null) {
            attachment.body = null;
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'You must upload a document or a rough draft'));
            return null;
        }
        
        // select the related applicant ID and the uploaded evaluation checkbox from evaluation record
        // External_Update__c eval = [SELECT Id, Applicant__c, EvalUploaded__c FROM External_Update__c WHERE Id =: ID];
        
        // set basic information (pulled from visualforce page)
        attachment.OwnerId = '005G0000003tiMx'; // since this is an external file, there is no owner. This ID is currently lucey's
        Event_Registration__c e1 = [SELECT id, name FROM Event_Registration__c WHERE Pertains_To__c =: 'CallForP' AND LastName__c =: c.lastName AND First_Name__c =: c.firstName];
        if(e.size() == 0) {
            attachment.ParentId = application.id; // record ID
        }
        else {
            list<Attachment> oldAtt = [SELECT id, name FROM attachment WHERE parentId =: e.get(0).id LIMIT 1];
            if(oldAtt.size() > 0) {
                delete oldAtt; // delete old attachment when you upload a new one
            }
            attachment.ParentId = e.get(0).id;
        }
        attachment.IsPrivate = False;
        string originalName = attachment.Name;
        
        string extension;
        // extract extension from file name
        if(attachment.name != null) {
            extension = originalName.substring(originalName.length() - 4, originalName.length()).toLowerCase(); // get the .doc, .pdf, etc.
        
        // if the file is not a .pdf document, throw error message and do not attach
        if (extension != '.pdf' && extension != '.doc' && extension != 'docx') {
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'Only .pdf, .doc, or .docx documents are accepted. Please convert your document.'));
            attachment.body = null;
            return null;
            
        } else { // otherwise, change file name to TeacherEvaluation.pdf
            attachment.name = c.firstName + '-' + c.lastName + 'Submission' + extension;
        }
        
        list<Attachment> allAttacts = [SELECT id, Name FROM Attachment WHERE parentId =: application.id];
        // if an evaluation has already been uploaded, throw an error message and do not upload
        if (allAttacts.size() > 0) {
            attachment.body = null;
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'Please delete previous version before uploading.'));
            return null;
        } else { // begin uploading
            try {
                insert attachment;
                //eval.EvalUploaded__c = True; // change uploaded eval checkbox to True
                //upsert eval; // save changes
            } catch (DMLException e) { // if an error occurs, throw error message
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, 'Error uploading attachment'));
                attachment.body = null;
                return null;
            } finally {
                attachment = new Attachment();
            } 
        } 
    }
        pageReference reRend = new PageReference('/apex/NUBSThankYou');
        reRend.setRedirect(true);
        return reRend;
        }    
        
Here is the method used to upload the attachment. I keep getting a 'Error uploading attachment' error meaning I am catching the DML exception e. Does anyone have any solutions? 

Thanks!
Hello,

I have added a VF page to my site but each time I try to create my custom object through the VF page I get this error.

'Authorization Required 

You must first log in or register before accessing this page. 
If you have forgotten your password, click Forgot Password to reset it.'

I have done my research and know that this usually has to do with field level security. I have given access to every field and object for the profile associated with my site. We are using the guest profile licence. I really am lost and have spent the last 2 days trying to debug this.

Any help would be nice. Thanks
I am having trouble displaying fields on my visualforce page when I add it to the site. I have checked all the public access settings and the field level security, they are both set as they should be. It is like I do not have access to the object itself. When I do <apex:inputField value="ObjectName.Field__c" /> it shows up in the visualforce page but not the site. We are using record types for this object but everything seems to be fine there as well. Does anyone have any expirence with this?

Thanks!
I am making name tags based on a contacts name. The page is rendered as a pdf so the contact can print their name tag easily. In order to get the page to be landscape I had to use: 
<style>
     @page { size:landscape; }
</style> 

and set the API version to 26.0.

To flip the text I am using this CSS:
<style type="text/css">
.flipTxt {
      -webkit-transform: rotate(-180deg);
      -moz-transform: rotate(-180deg);}
</style>

When this is applied to <h1> tag in a normal VF page it works fine but when renderAs="pdf" it no longer works. Does anyone have any idea why this happeneds or how it can be fixed?


Thanks.
I am attempting to making a column of commandButtons that serve as links to other pages on a site I am making. However the commandButton is not passing the ID to the other page, thus not allowing a user to view it. Is there a way to pass parameters with commandButtons? I tried using <a href=" " > but that will not work for a public facing site.

Here is the code generating the links:

<apex:pageBlockTable value="{!courses}" var="c" id="theTable">
                <apex:column headerValue="Name" 
                  <apex:commandButton value="{!c.Name}" action="{!viewCrs}">
                        <apex:param value="{!c.Id}" assignTo="{!courseId}" name="courseId" />
                  </apex:commandButton>
                    
                </apex:column>



Alternatively I could use commandLinks. That code looks like this:

<apex:pageBlockTable value="{!courses}" var="c" id="theTable">
                <apex:column headerValue="Name"
                  <apex:commandLink value="{!c.Name}" action="{!viewCrs}">
                        <apex:param value="{!c.Id}" assignTo="{!courseId}" name="courseId" />
                  </apex:commandLink>
                </apex:column>

However when I do that and click on the link it redirects to the same page. I saw that this error came up:User-added image

I tried commenting out that line of code but still has the same problem. Again I cannot use <a> because of the issues with forward facing sites. 


Any insight would be helpful! Thanks!
For reasons that don't matter I am trying to make a button look like a link using css in visualforce. Currently I have:
<button class="tableButton">
               <apex:commandButton value="{!c.Name}" action="{!viewCrs}">
                          <apex:param value="{!c.Id}" assignTo="{!courseId}" name="courseId" />
               </apex:commandButton>
</button>

The tableButton css looks like:
.tableButton {
     background:none;
     border:none;
     padding:0;
     /*border is optional*/
     border-bottom:1px solid #444;
     cursor: pointer;
}

However this just underlines the existing button. I'd like the "button" to look something like: click here to go to desired page

Thanks
I am having trouble displaying fields on my visualforce page when I add it to the site. I have checked all the public access settings and the field level security, they are both set as they should be. It is like I do not have access to the object itself. When I do <apex:inputField value="ObjectName.Field__c" /> it shows up in the visualforce page but not the site. We are using record types for this object but everything seems to be fine there as well. Does anyone have any expirence with this?

Thanks!

I am the System Admin for our instance. I am currently developing a visualforce page. The System Admin profile has access to the page and controller.

However when I call my action function I get a "Insufficient Privileges" error message.
User-added image

I investigated further to see that I was getting an Internal Server Error.
User-added image

I have stripped functionality in the apex method the actionFunction calls until it does nothing. See Below:
 

public class UtilApplication {

    public List<List<SelectOption>> display {get;set;}
    public String assigned {get;set;}
    Map <String, Schema.SObjectType> objs {get;set;}
    
    public UtilApplication() {
        
        display = new List<List<SelectOption>>();
        
        objs = Schema.getGlobalDescribe();
        
        List<SelectOption> init_opts = new List<SelectOption>();
        
        // Value | Label
        init_opts.add(new SelectOption('Student_Application__c','Student Application'));
        init_opts.add(new SelectOption('Contact','Contact'));
        
        display.add(init_opts);
        
        System.debug('In constructor');

    }
    
    // method in question
    public void add_object() {
        System.debug('In here');
    }
}
The Visualforce looks like this:
 
<apex:page showHeader="false" sidebar="false" controller="UtilApplication">
    <head>
		<script>
        	function callJS() {
            	console.log("In this");
                select_section();   
            }
        </script>
    </head>  
    <body>
        <apex:form>
            <apex:outputPanel id="configure">
                <apex:outputPanel>
                    <apex:pageBlock title="Select Section">
                        <apex:actionFunction name="select_section" action="{!add_object}" reRender="configure"/>
                            <apex:selectList multiselect="false" value="{!assigned}" size="1" onchange="callJS()">
                                <apex:selectOptions value="{!display[0]}"/>
                            </apex:selectList>
                    </apex:pageBlock>
                </apex:outputPanel>
            </apex:outputPanel>
        </apex:form>
    </body>
</apex:page>

I have used actionFunctions like this before so I am not sure what the issue is.

Any input would be great.

Thanks!

 

This is my test class:

@isTest(seeAllData = true)
public with sharing class NUBSCartControllerTest{
    
    static testMethod void NUBSCartControllerTestMethod() {
       
       Contact c = new Contact();
       c.firstName = 'Charles';
       c.lastName = 'Cox';
       c.email = 'charliecox17@yahoo.com';
       insert c;
       
       Event_Registration__c er = new Event_Registration__c ();
       er.name = 'CharlesConference';
       er.hasPaid__c = false;
       er.Applicant_Name__c = c.id;
       insert er;
       
       Id stnd = Test.getStandardPricebookId();
       
       Product2 p = new Product2();
       p.name = 'Thursday, March 26, Opening Reception';
       insert p;
       
       ConProd_Bridge__c cpb = new ConProd_Bridge__c();
       cpb.Product__c = p.id;
       cpb.Contact__c = c.id;
       insert cpb;
       
       PricebookEntry pbe= new PricebookEntry();
       pbe.Product2Id = p.Id;
       pbe.unitPrice = 30;
       pbe.Pricebook2Id = stnd;
       pbe.isActive = true;
       insert pbe;
       
       Opportunity o = new Opportunity();
       o.Name = 'thisOpp';
       o.Amount = 30;
       o.stageName = 'Prospecting';
       o.closeDate = Date.TODAY().addYears(1);
       o.Contact__c = c.id;
       insert o;
       
       OpportunityLineItem ole = new OpportunityLineItem();
       ole.UnitPrice = 30;
       ole.OpportunityId = o.id;
       ole.PriceBookEntryId = pbe.id;
       ole.Quantity = 1;
       insert ole;
       
       Test.setCurrentPageReference(new PageReference('Page.myPage'));
       System.currentPageReference().getParameters().put('oppId', o.id);
       System.currentPageReference().getParameters().put('isConference', 'true');
     
       NUBSCartController contr = new NUBSCartController();
       
       contr.BillingFirst = 'Charles';
       contr.BillingLast = 'Cox';
       contr.BillingAddress = '26 West';
       contr.BillingCity = 'Austin';
       contr.BillingState = 'Texas';
       contr.BillingCountry  = 'United States';
       contr.BillingPostcode = '78681';
       
       contr.CardType = 'Visa';
       contr.CardNumber = '4111111111111111';
       contr.CardMonth = '12';
       contr.CardYear = '2038';
       contr.CardSecurity = '123';
       
       contr.cancel();     
       contr.preCharge();
       contr.processPayment();
    
       contr.isConference = 'false';
       contr.sendEmails(c);
    }    
}


I get the error 'TestMethod do not support Web service callouts' when I run the test with seeAlldata = true but not when seeAllData = false. I need to have seeAllData = true so I need to figure this error out. I don't see where I am using a web service call...

Any help would be great,

Thanks! 
<apex:inputField styleClass="standardizer" value="{!application.ArrivalDate__c}"/>
User-added image
On my visualforce page I have an inputField asking for a date. ArricalDate__c is a Date Field. I was wondering if there was a way to disable salesforces' default date selector circled in red. Is there a way to replace the thing circled in red with a calendar widget? 

Thanks!

Thanks
Hello,

I have added a VF page to my site but each time I try to create my custom object through the VF page I get this error.

'Authorization Required 

You must first log in or register before accessing this page. 
If you have forgotten your password, click Forgot Password to reset it.'

I have done my research and know that this usually has to do with field level security. I have given access to every field and object for the profile associated with my site. We are using the guest profile licence. I really am lost and have spent the last 2 days trying to debug this.

Any help would be nice. Thanks
I am having trouble displaying fields on my visualforce page when I add it to the site. I have checked all the public access settings and the field level security, they are both set as they should be. It is like I do not have access to the object itself. When I do <apex:inputField value="ObjectName.Field__c" /> it shows up in the visualforce page but not the site. We are using record types for this object but everything seems to be fine there as well. Does anyone have any expirence with this?

Thanks!
I am making name tags based on a contacts name. The page is rendered as a pdf so the contact can print their name tag easily. In order to get the page to be landscape I had to use: 
<style>
     @page { size:landscape; }
</style> 

and set the API version to 26.0.

To flip the text I am using this CSS:
<style type="text/css">
.flipTxt {
      -webkit-transform: rotate(-180deg);
      -moz-transform: rotate(-180deg);}
</style>

When this is applied to <h1> tag in a normal VF page it works fine but when renderAs="pdf" it no longer works. Does anyone have any idea why this happeneds or how it can be fixed?


Thanks.
I am attempting to making a column of commandButtons that serve as links to other pages on a site I am making. However the commandButton is not passing the ID to the other page, thus not allowing a user to view it. Is there a way to pass parameters with commandButtons? I tried using <a href=" " > but that will not work for a public facing site.

Here is the code generating the links:

<apex:pageBlockTable value="{!courses}" var="c" id="theTable">
                <apex:column headerValue="Name" 
                  <apex:commandButton value="{!c.Name}" action="{!viewCrs}">
                        <apex:param value="{!c.Id}" assignTo="{!courseId}" name="courseId" />
                  </apex:commandButton>
                    
                </apex:column>



Alternatively I could use commandLinks. That code looks like this:

<apex:pageBlockTable value="{!courses}" var="c" id="theTable">
                <apex:column headerValue="Name"
                  <apex:commandLink value="{!c.Name}" action="{!viewCrs}">
                        <apex:param value="{!c.Id}" assignTo="{!courseId}" name="courseId" />
                  </apex:commandLink>
                </apex:column>

However when I do that and click on the link it redirects to the same page. I saw that this error came up:User-added image

I tried commenting out that line of code but still has the same problem. Again I cannot use <a> because of the issues with forward facing sites. 


Any insight would be helpful! Thanks!