• benwrigley
  • NEWBIE
  • 30 Points
  • Member since 2007

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

Hi All,

 

This isn't really an APEX question but I still think you are the right crowd.

 

I've written a trigger on Account to catch the country field and populate a relevant tax field. Simple enough.

 

Now I want to run that query on all 30k account records that I have. 

 

I thought I could just use the Bulk Uploader and perform an update on all Accounts and set Name=Name so that the trigger will execute. This works fine for about the first 56 records and then fails with 'Too many SOQL...'

 

Does anyone else have a good solution for this?

 

TIA

Hi All,

 

I've just downloaded the most recent Force.com IDE (v 20.0?) and tried installing on two different XP machines.

 

Both installations fail with a JVM exit error.

 

I would paste the error here but it's in a windows that won't let me copy. 

 

How to I go about starting to find the issue or even finding an older version of the IDE if this one is known to be broken?

 

Thanks

Hi All,

 

This is a new one for me, I've just hit a repeatable internal server error, but not sure how to debug it!

 

 

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!

Error ID: 1789751736-5504 (393970645) 

 

Has anyone got a sensible way?

 

TIA

 

Hi There,

 

Does anyone know how to deploy authorisation workflows?

 

I don't see them as an option in the change sets in the interface or as an option in the force.com IDE.

 

Any ideas?

 

TIA 

Hi All,

 

I just found this link to a salesforce manual for the debug log:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_debugging_system_log_console.htm

 

My log doesn't look anything like this. I only have 3 secions:

 

- Filter Details (hidden by defaul)

- Execute Apex

- Logs

 

Is the link above pointing to a more recent/out-of-date version?

 

TIA

 

Hi All,

 

I have a VF page set up to render as PDF. I also have a class that calls this page, stores in a blob and attaches to an Opportunity.  This all works fine.

 

My test scripts fail however on this line:

 

Blob pdfBlob = pdfPage.getContent();

 

with 'List has no rows for assignment to SObject'.

 

here is the context:

 

 

public void generateSalesOrder() {
		
        PageReference pdfPage = Page.TMDR_SalesOrder;
        pdfPage.getParameters().put('oppid',Opp.id);
        
        // generate the pdf blob
        Blob pdfBlob = pdfPage.getContent();
        String attName = Opp.name + '.pdf';
        
        //does the quote exist already?
        List<Attachment> atts = [select ID from Attachment where parentId = :Opp.id and name=:attName];
        
        if (atts.size() > 0){
        	for (Attachment att:atts){
        		delete att;
        	}
        }
        
        PDF = new Attachment(parentId = Opp.id, name=attName, body = pdfBlob);
        insert PDF;
        
  }

 

 

I wondered if actually the error was coming from the VF page itself, so I stripped out all of it's content, but still got the same error.

 

Anyone got any advice?

 

TIA

 

Hi There,

 

I am writing a trigger to test if certain Opportunity field values have been changed by the user. Some fields are allowed and some are not.

 

I have a List of field names that I iterate through with the code below

 

 

for (String f : notAllowed){
			
    Schema.Sobjectfield field = newOpp.getSObjectType().getDescribe().fields.getMap().get(f);
			
    if (field.getDescribe().getType().Name() == 'Decimal'){
	Decimal newVal = newOpp.get(f);
	Decimal oldVal = orig.get(f);
	if (Math.round(newVal) != Math.round(oldVal)){
		return false;
	} 
    }
    else if (newOpp.get(f) != orig.get(f)){
	return false;
    }
}

return true;

 

 

I had to add the decimal check as I found that Decimal values that were not being edited can be different by 10 decimal places. 

 

The decimal check is where it fails. According to the docs, newOpp.get(f) returns an Object, what kind of Object is unclear to me and how I get the decimal value out of it is just as unclear.

 

Can anyone help?

 

TIA

 

 

Hi There,

 

Before asking my question I need to give a bit of background.

 

I have set up an approval process on Opportunities that doesn't use the built in locking. Instead I set a flag on the opportunity and I have a trigger preventing any more updates.

 

The reason I am doing this, is that I need to let users amend opportunities after they have been approved. If the user chooses to make a change, then approval is revoked and must be resubmitted. (I cannot see any way to do this with the built-in process).

 

So, now I have a trigger that allows the user to uncheck the 'locked' flag but in the process also removes authorisation. This all works fine.

 

However, for cosmetic completeness I would like to add a record to the Approval related list, so the user isn't confused why the last approval history shows Approved when it's actually not.

 

How can I add a record to that list? Ideally it would say that Approval was either rejected or revoked and a comment to explain.

 

Any ideas?

 

TIA 

Hi There,

 

I have an approval workflow on Opportunity that, on approval, sets a flag 'isApproved__c' to true and locks the Opportunity.

 

Is there a way in APEX I can unlock the object after this has happened? I want the user to have the chance to revise something that may have already been authorised and then force them through the approval process again.

 

Can anyone offer some advice?

 

TIA

Hi All,

 

I want to add a button to the Opportunity Page that, when clicked, checks that certain fields have valid data.

 

If they don't, then I will display an error message.

 

If they do they I'll do something else.

 

So, is the right way to do this:

 

1) User clicks button which calls URL to a VF page

2) VF page calls the controller to check validation

3) If not valid, set errors on Opportunity and redirect user back to Opportunity page (somehow)

4) If valid, do the other action and send user back to Opportunity (somehow)

 

This feels wrong. For a start the VF page is purely there for calling the controller class and never actually displays anything.

 

What's the 'right' way to do this?

 

TIA

Does anyone know of a way to deploy classes that refer to each other?

 

I have a custom exception class and a custom email class. The email class instantiates and exception if anything goes wrong. Equally the exception class send an email to the system administrator if a serious exception is caught.

 

As a result, I cannot deploy these without commenting out great chunks of code first. Is there a sensible way to do this?

 

TIA

 

 

Hi There,

 

I need some advise on best practise wrt to buttons on page layouts.

 

I have a number of custom buttons that link to various VF pages. These buttons should only load the VF page if certain criteria are met e.g. sharing rules, authorisation etc.

 

The question I have is where to make these checks?

 

In the past I would have done the validation in an s-control but I think my options now are :

 

1) Make the button execute javascript and show an error if validation fails.

2) Have an interim VF page that checks validation through the controller and displays an error or redirects to the correct page.

3) Embed validation into 'rendered' fields of VF components

4) Continue using s-controls.

 

Is there any strong opinion on this?

 

TIA

Hi There,

 

I have added a button to an Opportunity page that takes the user directly to a VF Page.

 

I would like to identify if the user has write access to the Opportunity and display an error instead of the VF page if they don't.

 

How have others done this?

 

TIA 

Hi all,

 

I'm sure I'm being stupid here, but is there to way to have a Lookup field on an object reference an OpportunityLineItem?

 

I don't get this as an option when creating the field.

 

TIA

Hi There,

 

I'm sure this must be simple, but I'm not finding an immediate solution anywhere.

 

I have a method with ID as input parameter but no idea what object the ID is for.

 

I want to work out what type of object is is before I decide what to do with it.

 

sObject generic = [select ID from [?] where id=:someid];

 

Sorry for the basic question.

 

TIA

Hi There,

 

I have a 'Save' button on my page that starts as disabled = 'true' until the form fields have been filled with valid information.

 

I have an apex:function that tests the validity of data and rerenders the save button.

 

All works fine, and when the data is valid the save button becomes active. But only the top one!

 

http://awesomescreenshot.com/0dc1o2y57

 

Anyone got a fix?

I'm sorry for such a stupid question but I'm at a complete loss.

 

Any idea why this doesn't work:

 

 

<apex:messages style="font-color:red;"/>

 


<apex:messages style="font-color:red;"/>

 

I get the messages, but no color :(

Hi All,

 

Perhaps I'm being stupid but this one seems like a bug to me. There is a little too much code to paste everything here so I'll explain.

 

I have a controller (TMDR_ShoppingCart) which instantiates and loads up an instance of class I've written (TMDR_RateCard Ratecard). 

 

TMDR_ShoppingCart has a method TMDR_RateCard getRateCard();

TMDR_Ratecard has a method List<Product2> getProducts();

 

All fine and all working so far.

 

Here is the snippet of my page:

 

 

                            <apex:column style="font-weight:bold" width="320px" headerValue="Name">
<apex:variable var="r" value="{!RateCard}"/> <apex:pageBlockTable value="{!r.ProductsAsList}" var="p" id="table"> <apex:column style="font-weight:bold" width="320px" headerValue="Name">
<apex:commandLink action="{!addItem}" value="{!p.name}" id="addProductLink" >           <apex:param name="productID" value="{!p.ID}"/>  </apex:commandLink>   </apex:column> </apex:pageBlockTable>

This code successfully renders a table with a list of product names. However, clicking on the link simply rerenders the page. The call to addItem() never happens (plenty of debug showed me that).

 

Now, if I get rid of the var and call it directly instead like so:

 

 

<apex:pageBlockTable value="{!RateCard.ProductsAsList}" var="p" id="table">
    <apex:column style="font-weight:bold" width="320px" headerValue="Name">
        <apex:commandLink action="{!addItem}" value="{!p.name}" id="addProductLink" >
            <apex:param name="productID" value="{!p.ID}"/>
         </apex:commandLink>  
    </apex:column> 
</apex:pageBlockTable> 

 Page renders just as before, but now the links work.

 

An inspection of the rendered link shows that the code is identical for both versions

 

 

<a id="j_id0:j_id1:products:j_id2:table:0:addProductLink" href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('j_id0:j_id1'),'j_id0:j_id1:products:j_id2:table:0:addProductLink,j_id0:j_id1:products:j_id2:table:0:addProductLink,productID,01t20000000Fa4WAAS','');}return false">Basic Job</a>

 And a quick edit on the fly shows that  (typeof  jsfcljs == 'function) is true in both instances.

 

 

 

Obvious solution is not to use the var I know , but I was actually loading it up earlier in the page to call other methods. (I've slimmed the page down massively to debug)

 

So, is this a bug?

 

TIA

 

 

 

Hi There,

 

This is a real noob quesion so apologies in advance.

 

I have created a custom object called TMDR_PackageEntry__c and in addition to all the build in methods like save() etc I would like to have a few validation methods of my own. How can I write a class that extends the default class that must exist around this new object?

 

I'm assuming there is a way to do this to avoid having to rewrite all the getter and setter methods etc.

 

Thanks

 

 

Hi There,

 

Anyone know if this should work?

 

 

    <apex:column style="font-weight:bold" headerValue="Sites" width="320px" rendered="{!RequireSites}">
        <apex:outputText value="{!SiteAbbreviations}">
            <apex:param name="pbid" value="{!pb.ID}" assignTo="{!SiteAbbreviations}"/>
        </apex:outputText>
     </apex:column>

 I would expect the param to call the method setSiteAbbreviations(String pbid) in the controller

 

And the getSiteAbbreviations() to get back the value of what we set in the set method.

 

The get works fine, but the set never gets called. 

 

Can you bind params of outputText to controller variables?

 

TIA

 

Hi All,

 

This isn't really an APEX question but I still think you are the right crowd.

 

I've written a trigger on Account to catch the country field and populate a relevant tax field. Simple enough.

 

Now I want to run that query on all 30k account records that I have. 

 

I thought I could just use the Bulk Uploader and perform an update on all Accounts and set Name=Name so that the trigger will execute. This works fine for about the first 56 records and then fails with 'Too many SOQL...'

 

Does anyone else have a good solution for this?

 

TIA

Hi All,

 

This is a new one for me, I've just hit a repeatable internal server error, but not sure how to debug it!

 

 

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!

Error ID: 1789751736-5504 (393970645) 

 

Has anyone got a sensible way?

 

TIA

 

Hi All,

 

I just found this link to a salesforce manual for the debug log:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_debugging_system_log_console.htm

 

My log doesn't look anything like this. I only have 3 secions:

 

- Filter Details (hidden by defaul)

- Execute Apex

- Logs

 

Is the link above pointing to a more recent/out-of-date version?

 

TIA

 

Hi All,

 

I have a VF page set up to render as PDF. I also have a class that calls this page, stores in a blob and attaches to an Opportunity.  This all works fine.

 

My test scripts fail however on this line:

 

Blob pdfBlob = pdfPage.getContent();

 

with 'List has no rows for assignment to SObject'.

 

here is the context:

 

 

public void generateSalesOrder() {
		
        PageReference pdfPage = Page.TMDR_SalesOrder;
        pdfPage.getParameters().put('oppid',Opp.id);
        
        // generate the pdf blob
        Blob pdfBlob = pdfPage.getContent();
        String attName = Opp.name + '.pdf';
        
        //does the quote exist already?
        List<Attachment> atts = [select ID from Attachment where parentId = :Opp.id and name=:attName];
        
        if (atts.size() > 0){
        	for (Attachment att:atts){
        		delete att;
        	}
        }
        
        PDF = new Attachment(parentId = Opp.id, name=attName, body = pdfBlob);
        insert PDF;
        
  }

 

 

I wondered if actually the error was coming from the VF page itself, so I stripped out all of it's content, but still got the same error.

 

Anyone got any advice?

 

TIA

 

Hi There,

 

I am writing a trigger to test if certain Opportunity field values have been changed by the user. Some fields are allowed and some are not.

 

I have a List of field names that I iterate through with the code below

 

 

for (String f : notAllowed){
			
    Schema.Sobjectfield field = newOpp.getSObjectType().getDescribe().fields.getMap().get(f);
			
    if (field.getDescribe().getType().Name() == 'Decimal'){
	Decimal newVal = newOpp.get(f);
	Decimal oldVal = orig.get(f);
	if (Math.round(newVal) != Math.round(oldVal)){
		return false;
	} 
    }
    else if (newOpp.get(f) != orig.get(f)){
	return false;
    }
}

return true;

 

 

I had to add the decimal check as I found that Decimal values that were not being edited can be different by 10 decimal places. 

 

The decimal check is where it fails. According to the docs, newOpp.get(f) returns an Object, what kind of Object is unclear to me and how I get the decimal value out of it is just as unclear.

 

Can anyone help?

 

TIA

 

 

Hi All,

 

I want to add a button to the Opportunity Page that, when clicked, checks that certain fields have valid data.

 

If they don't, then I will display an error message.

 

If they do they I'll do something else.

 

So, is the right way to do this:

 

1) User clicks button which calls URL to a VF page

2) VF page calls the controller to check validation

3) If not valid, set errors on Opportunity and redirect user back to Opportunity page (somehow)

4) If valid, do the other action and send user back to Opportunity (somehow)

 

This feels wrong. For a start the VF page is purely there for calling the controller class and never actually displays anything.

 

What's the 'right' way to do this?

 

TIA

Does anyone know of a way to deploy classes that refer to each other?

 

I have a custom exception class and a custom email class. The email class instantiates and exception if anything goes wrong. Equally the exception class send an email to the system administrator if a serious exception is caught.

 

As a result, I cannot deploy these without commenting out great chunks of code first. Is there a sensible way to do this?

 

TIA

 

 

Hi There,

 

I need some advise on best practise wrt to buttons on page layouts.

 

I have a number of custom buttons that link to various VF pages. These buttons should only load the VF page if certain criteria are met e.g. sharing rules, authorisation etc.

 

The question I have is where to make these checks?

 

In the past I would have done the validation in an s-control but I think my options now are :

 

1) Make the button execute javascript and show an error if validation fails.

2) Have an interim VF page that checks validation through the controller and displays an error or redirects to the correct page.

3) Embed validation into 'rendered' fields of VF components

4) Continue using s-controls.

 

Is there any strong opinion on this?

 

TIA

Hi There,

 

I have a 'Save' button on my page that starts as disabled = 'true' until the form fields have been filled with valid information.

 

I have an apex:function that tests the validity of data and rerenders the save button.

 

All works fine, and when the data is valid the save button becomes active. But only the top one!

 

http://awesomescreenshot.com/0dc1o2y57

 

Anyone got a fix?

I am passing this url

 

/apex/PosEntriesFilterPageExcel?id={!Account.Id}&soldBy={!utilityObject.soldBy__c}

 

 

and I am trying catch in the controller in the following way

 

 

String accountId=ApexPages.currentPage().getParameters().get('Id');
this.utilityObject.soldByValue__c=ApexPages.currentPage().getParameters().get('soldBy');

 

It is giving error in the second line

 

 

Yet I am receiving such exception. Any help will be appreciated

  • September 21, 2010
  • Like
  • 0

I have started to write the test script but only get 40% coverage, very new to APEX but slowly getting there with a lot of help.  Thanks to all the community for your support!

 

The code below is simple it just allows a meeting note and attendee object to sit on the same page (visualforce) and when you hit save a meeting note record is created and attendee is linked to the meeting note. 

 

I am sure the testing code is poor to say the least but I am very new to all this and having to rely on free stuff as I can't afford the developer courses yet.

 

Thanks

 

Ross

 

 

public class newMeetingController {

    public newMeetingController(ApexPages.StandardController controller) {
    }

   Meeting_Note__c meeting;
   Attendee__c attendee;
    
   public Meeting_Note__c getMeeting() {
      if(Meeting == null) Meeting = new Meeting_Note__c();
      return Meeting;
   }

   public Attendee__c getAttendee() {
      if(Attendee == null) Attendee = new Attendee__c();
      return Attendee;
   } 
    
    public PageReference cancel() {
            PageReference MeetPage = new ApexPages.StandardController(Meeting).view();
            MeetPage.setRedirect(true);
            return MeetPage; 
    }
    
   public PageReference save() {

      insert meeting; 
    
      attendee.meeting_note__c = meeting.id;
      insert attendee;

      PageReference meetPage = new ApexPages.StandardController(Meeting).view();
      meetPage.setRedirect(true);

      return meetPage;
   }
   
    public static testMethod void newMeetingController() {
    Contact c = new Contact(FirstName='Test', LastName='Contact');
    insert c;
   
    Meeting_Note__c m = new Meeting_Note__c(Subject__c='Test');
    insert m;
   
    Attendee__c a = new Attendee__c(Meeting_Note__c = m.id, Contact__c = c.id);
    insert a;
   
    System.assertEquals(c.id,a.contact__c);
   
    ApexPages.StandardController sc = new ApexPages.StandardController(a);
    newMeetingController ae = new newMeetingController(sc);
    Attendee__c attTemp = ae.attendee;
    ae.attendee = null;
    ae.getAttendee();
    ae.attendee = attTemp;
    ae.save();
    
    newMeetingController me = new newMeetingController(sc);
    Meeting_Note__c meTemp = me.meeting;
    me.meeting = null;
    me.getMeeting();
    me.Meeting = meTemp;
    me.save();
}

}

 

Is there any way to write a validation when a user clicks on Submit for Approval button for an approval process? 

 

Submit for Approval button is not even visible in the Button and Links section. So, I am not sure how to do it.

 

 

Hi,

 

I have this actionFunction:

 

<apex:actionFunction action="{!addStuff}" name="addStuffJS"> <apex:param name="firstParam" assignTo="{!xAdded}" value="" /> <apex:param name="secondParam" assignTo="{!yAdded}" value="" /> <apex:param name="thirdParam" assignTo="{!zAdded}" value="" /> </apex:actionFunction>

 and in the controller there is:

 

public String xAdded { get; set; } public String yAdded { get; set; } public String zAdded { get; set; } public void addStuff() { system.debug('added x: ' + xAdded); }

 

 

 The actionFunction is called from a JS script which itself is invoked after some button is pressed like so:

 

function btnActionJS() { for (var i=0; i < thisArray.size(); i++) { addStuffJS(thisArray[i]x, thisArray[i].y, thisArray[i].z); } }

 

The issue is that the values for xAdded, yAdded, and zAdded on the controller are all null when the button on the page is pressed (the debug statement on addStuff() prints null). Am I doing something wrong somewhere?!

 

Thanks.

 

 

  • January 20, 2010
  • Like
  • 0

I created a visualforce page and a button that calls the visual force page to do some behind the scenes processing.  The processing basically clones a custom object record and its children, doing some other unique things.  The button is displayed on the standard detail record screen of the custom object and when clicked it will call the visual force page below, call it 'CLONE':

 

 

 

<apex:page standardController="custom_object__c" action="{!autoRun_Version}" extensions="custom_Controller_Ext" title="Cloning Custom object record"> <apex:sectionHeader title="Cloning of Custom object record"/> <apex:messages /> <apex:outputPanel > Click <apex:outputLink value="/{!$CurrentPage.parameters.id}"> Here </apex:outputLink> to return to the Custom object record </apex:outputPanel> </apex:page>

 

The code in the controller does all the processing and it works fine.  The issue is I want to display any error messages on the page where the button is clicked, but this is a standard page created by Salesforce and the company doesn't want to change it.  So I currently display the messages in the Visual force page, 'CLONE' above.  I would prefer to display the errors on the standard page where the button is clicked, if possible.  But, if it isn't, I want to display them on a Generic Error Page.  The error page will have the errors and then a link to go back to the standard detail page where the button is on.

 

The main part of the controller code is displayed, I didn't include everything because it would just complicate the matter:

 

 

public with sharing class custom_Controller_Ext { *** all the stuff such as constructors and private variables set above *** public PageReference autoRun_Version() { .... // *** all the stuff in autoRun_Version that wasn't pertinent has been left out *** .... if (Campaign_Inactive__c != true) { vIO(); vInv(); } else { System.debug('SKM-IO Campaign is Inactive'); PageReference pageRef = Page.ErrorPg; pageRef.getParameters().put('id', custom_object__c.id); System.debug('SKM- (INACTIVE) Page Reference =' + pageRef); pageRef.setRedirect(true); ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'ERROR: \'INACTIVE\' '); ApexPages.addMessage(myMsg); return pageRef; } } }

 

Lastly, the  visualforce page, ErrorPg, is attached.  This is my generic error page. As you see below, I have the <apex:messages /> code in the visual force page, but the message I added above int the controller doesn't get displayed.   I believe it has to do with the fact that the button exists on a standard detail page, which calls a visualforce page and then gets redirected to another visualforce page to display the message.  Is this permissable

 

BTW, I can see the error messages if I change the 'return pageRef' to 'return null'.  This basically shows the errors in the 'CLONE' visualforce page, not the generic error visualforce page.

 

 

<apex:page standardController="custom_object__c"> <apex:sectionHeader title="Generic Error Page"/> <apex:messages /> <apex:outputPanel > Click <apex:outputLink value="/{!$CurrentPage.parameters.id}"> Here </apex:outputLink> to return to the Campaign </apex:outputPanel> </apex:page>

 

 Any help will be appreciated.

 

Thanks