• OldDeadBug
  • NEWBIE
  • 55 Points
  • Member since 2007

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 46
    Questions
  • 52
    Replies

Hi -

I am trying to update the pick list values. When i click on save i am ending up with the below error.

 

System.NullPointerException: Attempt to de-reference a null object

Class.MyController.save: line 13, column 14 External entry point

 

 Can someone please advise me how to update the picklist values in the custom object. This is my first app using VF. Searched the doucumentation but no luck...please help.... Here is my code

 

I know i have to write some logic in the pagereference save..but not getting any idea...

 

<apex:page controller="MyController" tabStyle="Award_Tracking__c">
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageBlockTable value="{!Award_Tracking}" var="at">
<apex:column headervalue="Award/Recognition">
<apex:outputText value="{!at.Name_of_Award__c}"></apex:outputText>
</apex:column>
<apex:column headervalue="Reward Options">
<apex:inputField value="{!at.Reward_Option__c}" required="true"/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons >
      <apex:commandButton value="Save" action="{!save}"/>
   </apex:pageBlockButtons>

</apex:pageBlock>
</apex:form>
  </apex:page>

 

 

public class MyController
{
Award_Tracking__c awt;

 

public List<Award_Tracking__c> getAward_Tracking()
{
Award_Tracking__c[] lawt=[select Id,Name_of_Award__c,Reward_Option__c from Award_Tracking__c where Award_date__c<=TODAY and Award_expiration_date__c>=TODAY and SFDC_ID__c=:UserInfo.getUserId()];
return lawt;
}

 

 public PageReference save() {

      update awt;
      PageReference AwardShippingPage = new PageReference('/Apex/AwardShipping');
      AwardShippingPage.setRedirect(true);

      return AwardShippingPage;
   }


}

  • March 31, 2009
  • Like
  • 0

I've seen a few posts on this, but can't determine if this is a bug or not.

 

I have set up the App to go to a Default Landing page or a specific Partner Profile. The Partner Profile has access to the visualforce page designated as the Default Landing Page

 

Logging in as a partner with that profile still goes to the Home page. A post from several years ago suggested this may be a bug, but there is no indication that it was, or if it got fixed.

 

What am I missing?? Why can't get to the default landing page I've set up for this user?

 

Thanks

 

ODB

I'm trying to create a single pageblocktable where Columns="3" that will move every 4th item to a new row in the table.

 

I thought that by assigning the Columns attribute that SFDC would automatically move the 4th column to a new row, but instead they just start piling up on the right side of the screen, after the first 3 columns display correctly.

 

Currently I'm having to close each pageblock table after three columns, then and start a new data table underneath it. This is working, but it doesn't seem right to have to do that.

 

I've alsdo tried using the dataTable, but the same problem happens.

 

Here's my VF example:

<apex:pageBlockTable value="{!Service}" var="SVC" columns="3" columnsWidth="400px,400px,400px" width="100%" align="center">
         <apex:column >
           <apex:facet name="header">CustomerID: </apex:facet>
              <font size="3" color="black">{!Order.CustomerID__c}</font>
         </apex:column>
         <apex:column >
           <apex:facet name="header">MVNO: </apex:facet>
              <font size="3" color="black">{!Order.CustomerID__r.MVNO_Partner__r.Name}</font>
         </apex:column>
         <apex:column >
           <apex:facet name="header">Transaction Type: </apex:facet>
              <font size="3" color="black">{!Order.OrderType__r.OrderTypeDescription__c}</font>
         </apex:column>
         </apex:pageBlockTable> 
         <br/>
                  
          <apex:pageBlockTable value="{!Service}" var="SVC" columns="3" columnsWidth="300px,300px,300px" width="100%" align="center">
         <apex:column >
           <apex:facet name="header">ServiceID: </apex:facet>
              <font size="3" color="black">{!SVC.Name}</font>
         </apex:column>
         <apex:column >
           <apex:facet name="header">&nbsp;MVNO Market </apex:facet>
              <font size="3" color="black">&nbsp;{!SVC.MVNOMarketId__r.DisplayName__c}</font>
         </apex:column>
          <apex:column > &nbsp;
          </apex:column>
       </apex:pageBlockTable>

 I'm not really that fluent in HTML, so I'm kind of winging it here as far as formatting a page to look half-way decent. The above works as far as organizing the fields in more or less aligned rows. Width, Columnswidth, and align are kind of sketchy as well. Align doesn't seem to move anything. I realize I am probably using these wrong, but again, I'm having to trial-and-error this thing into shape.

 

Any help is appreciated.

 

ODB

 

 

 

I've built an controller extension to the Opportunity. I've also built some Javascript into the page where a user entering a value in one field should update the value in another.

 

The javascript is working, however if the user presses the enter key, as opposed to say the tab key, it appears that some kind of standard function in Salesforce gets called, as though the Opportunity edit page is open, and the page refreshes with the original value, defeating the javascript.It looks like the underlying Opportunity on which the page is based is updating and refreshing the VF page.

 

I can expect a user to hit the enter key as a habit when updating the field value so I need a way to stop whatever process is called when the enter button is hit in an edit page.

 

I have a javascript noenter-type routine, but I haven't seen any way to use Javascript to stop that process, probably because I'm not a javascript guru. 

 

Can I override the Opportunity Save function? Here's the code I'm using:

 

function noenterB(e){
    if(window.event){
    key = window.event.keyCode; //IE
    } else{
    key = e.which; //firefox
    }
    alert("Key is "+key);
    
    updSalT(); // this is the routine to update the other field
    }

I've tried to return null or false, but this has no effect. I don't think I can prevent or bypass whatever standard Salesforce save process is being called by pressing the enter key in Javascript, can I??

 <apex:InputText label="Project Sale $/W: " value="{!decSalBase}" id="SalB" onkeydown="noenterB(event)"/>

I was thinking of trying an actionSupport tag maybe to call some other APEX process which might bypass the save routine?

 

Any suggestions?

Don't know quite what's up with this. Seems like it should be simple. Here's the relevant code:

 

<apex:pageBlockSection rendered="{!IF(Opp.Utility__c = "CA-SDGE","true","false")}"
            title="Login ..." id="Login"> 
     <apex:pageBlockSectionItem >
           <bUsername:</b>&nbsp;&nbsp; <apex:inputText value="{!username}" label="Username" required="true"/>
     </apex:pageBlockSectionItem>
     <apex:pageBlockSectionItem />
     <apex:pageBlockSectionItem >
           <b>Password:</b>&nbsp;&nbsp; <apex:inputSecret value="{!password}" label="Password" required="true"/>
     </apex:pageBlockSectionItem>
</apex:pageBlockSection>

 If I remove the rendered statement the page works fine. With the statement, I get the following error:

 

"The element type "apex:pageBlockSection" must be terminated by the matching end-tag "</apex:pageBlockSection>""

 

I have the matching end tag, and the same rendered statement is working to render a button on the page.

 

Any ideas why this isn't working?

Accoridng to the SFDC Help on Quotas, a user needs the 'Manage Users' permission to manage other users' quotas. I have a user who needs to do this, and has the Manage Users permission, but he can't see the Quotas list in the User page to edit the quota.

 

I thought this permission was all that was needed to edit other users' quotas, but how do I get the Quotas list to appear in the User page for this particular user??

I am a bit new to working with XML, but need to design a process to generate a document from the Opportunity object to be used as the 'payload' of an HTTP Request.

 

Looking at the APEX XML Classes it seems like the XMLStreamWriter and the Document/XMLNode classes will both generate XML, but which is easier to use for creating a fairly complex document?

 

My application is to extract a load of fields from the Opportunity and related objects, then add the field values into an XML document for submitting a form to another site.

 

Again, I'm new to this so I am unsure of whether to just design a straight-forward, albeit long process of just generating the XML document one element at a time, every time, or if I can build a template that I can query and parse replacing the text values with field values. Ultimately I need to end up with an XML Document that can be read by the service we're using.

 

I've read through the APEX guide for information on the XML classes, and taken some online training to get up to speed with XML, or at least a little closer to speed. But I'm generally confused by the XML classes and when to use one or the other for this particular application.

 

Thanks for any help.

I am creating a custom button to send Opportunity data to submit a form on a non-Salesforce website.

 

In my test case the Opportunity Name has an ampersand (&) in the name.

 

It doesn't seem to matter if I use

ProjectName = {!Opportunity.Name}   or

 

ProjectName = {!URLENCODE(Opportunity.Name)}

 

In either case the name is still appearing with '&amp' in the name rather than just the '&' symbol. 

 

I can't really tell if the code managing the web form is causing the problem, or if I'm still not writing the Merge Code correctly.

 

If it is the web form that is resetting the '&' value, then I guess I'll have to create a formula field that removes special characters and send that instead, but if there is some other way, or some other reason this might be happening, I'd appreciate any help

 

Thanks

I am able to embed the VF page I want into a custom controller, but its behavior is very weird.

 

I have a series of currency values that I am putting in a panel grid. The VF Code looks like this:

 

<apex:page standardController="Object__c" extensions="RevenueBookController">
   <apex:CommandButton action="{!save}" value="Update Revenue Book" rerender="thePanel" /> 
  <apex:form >
        <apex:CommandButton
        <apex:outputPanel id="thePanel">
        <apex:panelGrid columns="6" id="theGrid" width="80%">
            <b>Revenue Types:</b> 
            <apex:outputText value="Month 1" id="Month1"/> 
            <apex:outputText value="Month 2" id="Month2"/>
            <apex:outputText value="Month 3" id="Month3"/>
            <apex:outputText value="Quarter" id="Quarter"/>
            <apex:outputText value="Total" id="Total"/>
            
            <apex:outputText value="Revenue: " id="Revenue"/>
            <apex:inputField value="{!Object__c.Revenue_Month1__c}"/> 
            <apex:inputField value="{!Object__c.Revenue_Month2__c}"/>
            <apex:inputField value="{!Object__c.Revenue_Month3__c}"/>
            <apex:inputField value="{!Object__c.Revenue_Quarter__c}"/>
            <apex:outputField value="{!Object__c.Revenue_Total__c}"/>
    
        </apex:panelGrid>
      </apex:outputPanel>
  </apex:form>
</apex:page>

 When I go to the page it looks right - the input fields show up in a grid as expected. However, when I add a value to one of the input fields and hit the update button, the entire page refreshes within the VF section.

What I want to happen is to just have the outputpanel refresh with updated numbers in the Total field.

 

Its probably something obvious, but its stumping me. Any suggestions and solutions appreciated.

I'm probably doing this wrong, but I've set up a process to get a set of Campaign reports from Google Analytics which is failing.

 

The problem appears o be that I nee twodifferent callouts: one for the authenitication, another for the actual query once I've received the authentication token.

 

I'm not an expert on callouts but is ther some way to combine the authentication with the query??

 

Here's what I have:

 

Authenntication:

Http m_http = new Http();
HttpRequest req = new HttpRequest();

String content = 'accountType=GOOGLE&Email='+username+'&Passwd='+passwd+'&service='+service;

req.setEndpoint('https://www.google.com/accounts/ClientLogin');
req.setHeader('Content-Type','application/x-www-form-urlencoded');
req.setHeader('User-Agent','salesforce-toolkit-googledata/21');
req.setMethod('POST');
req.setBody(content);

httpResponse response = m_http.send(req);

 The response returns the clientLoginToken, which I thought would allow me to then callout to GA to get the report data I want:

 

 

HttpRequest req = new HttpRequest();
HttpResponse response = new HttpResponse();

req.setEndpoint(URL);
req.setMethod('GET');
req.setHeader('content-type', CONTENT_TYPE_URL );
req.setHeader('Authorization','GoogleLogin auth='+clientLoginToken);
req.setHeader('Accept-Encoding','compress, gzip');

Http http = new Http();
response = http.send(req);

 

 

As far as I know, and I have to believe I have it wrong, this is the process for getting ay data out of Google Analytics, unless there is some way to combine the login request with the query in the same callout, which I don't know how to do if it is possible.

 

This is being used to update Campaigns in SFDC, for which there may be quite a few and for which a Batch Process needs to be employed.

 

Any help or pointers are appreciated.

 

Thanks

ODB

 

I have all Workspace and Content privileges associated with my User. Previously, after archiving a Content record, clicking the Edit button on the record would show the option to unArchive the content. Now it only shows the option to delete the content. Again, I have all Content privileges, and I am the Author of the Content record.

 

Was an un-documented change implemented in the sandbox Spring'11 version that removes the ability to unarchive Content records???

 

I have a required custom field which is also used to fire associated triggers. As long as the document isn't associated with a workspace, the field doesn't exist.

 

The problem I'm having is that when I emulate the manual insert, all of the custom field processes have to happen in an update. But when I insert a ContentWorkspaceDoc in my test for the just-inserted document, all the custom fields suddenly become live as a result of associating it with a Workspace. As the required field doesn't have a value, the ContentWorkspaceDoc insert fails because the associated ContentVersion record update fails without the required field. .

 

So, in my test methods:

1) I can't add a required custom field value into a ContentVersion record unless it is associated with Workspace via the insertion of a ContentWorkspaceDoc, and

2) I can't insert a ContentWorkspaceDoc for a ContentVersion record unless the required custom field has a value.

 

The triggers are working in practice. The updates are occuring as expected based on the trigger.old required field being null ( as it didn't exist on the record when it was first inserted without a workspace reference) during the before update phase.

 

Seems weird to not be able to test the triggers written for the Content object, even though those triggers are working in practice. Anybody know how to do this??

 

Searching thyrough the API I don't find any isArchived or similar field on either the ContentDocument or the Content Version object. I would like to run a trigger process when a document is archived in Content. How is the archived status indicated in the document object and how can I access it as a trigger criteria?

 

If its essentially the same as deleting then I could use an 'After Delete' trigger, but otherwise there is no such thing as an After Archive trigger, so I'm guessing the document has to be updated to some archived status in some way, but the API document goves no indication of how that status is set.

 

Suggestions?

I have a page with two commandbuttons and two action methods in the controller.

 

The page is built using the OppLineItem standardController and is using the lineitem to derive field to create a custom Object record - an Order in this case.

 

The buttons are called 'Cancel' and 'SaveOrder'

 

The Cancel method, is just a pagereference going back to the previous page.

 

The SaveOrder method captures the data from the inputfields on the page adds them to a new Order record and inserts, and then redirects the user to the Opportunity record. 

 

Straightforward stuff. The Cancel button works perfectly. The SaveOrder button does nothing but refresh the page (in fact it does this twice, runs through the entire process of setting up the page twice and quits).Not even the debug statement I put in the first line of the method shows up in the debug log.

 

Here's the weird part. If I switch the action method names - call the Save method 'Cancel', and the Cancel method 'SaveOrder', and then click the Cancel button - the method works!!!!! It creates the record and redirects the user.But if I click the saveOrder button in this case - I get the same behavior - it just refreshes the page.

 

Here is the relevant code:

 

    public PageReference cancel()
    {
    	returnPage = new PageReference('/apex/ManageOrders_QC?id='+OLI.OpportunityId).setRedirect(true);
    	return returnPage;
    }
    public PageReference saveOrder()
    {
    	system.debug('Start Save');
        ... other code

        returnPage = new PageReference('/apex/ManageOrders_QC?id='+OLI.OpportunityId).setRedirect(true);
    	return returnPage;
    }

<apex:page standardController="OpportunityLineItem" extensions="Controller_NewManualOrder" >
    <apex:form >
         <apex:pageBlock id="OrderFields">
             <apex:pageBlockButtons id="Buttons">
                <apex:CommandButton id="SaveButton" value="Save Order" action="{!saveOrder}"/>
                <apex:CommandButton id="cancelButton" value="Cancel" action="{!cancel}"/>
                <apex:CommandButton id="returnButton" value="Return to Opportunity" action="{!ReturnToOpp}"/>
                
            </apex:pageBlockButtons>
            ...PageBlocktable showing fields
         </apex:pageBlock>
    </apex:form >
</apex:page>

 What is going on here?

 

 

I realize that test methods can't test web services, however it also brings the test itself to a standstill, so that any test operation after the webservice call doesn't run. Basically the test treats the web service as a fatal error. Is there some way to write the call in the test method in such a way as to allow the error to occur, but move to the next step in the test. I tried using a try-catch statement, but I don't think that will work.

 

If not, is there some way Salesforce can alter this behavior so that the error can be caught, allowing us to add any expected values directly, or return a page reference, and move on with steps after the call??

I have a method in my controller that is not being sween by the page, even though the names are identical

 

I am using a commandLink in a pageblocktable for each line. the action for the link goes to a method that requries a class object for its argument. Whereas each of the lines on the page are made up of these class objects, I apparently have to associate the line object with a property in the controller. So, the line object code is:

 

 

public LineQuote generateLQ;
    
    public LineQuote getGenerateLQ()
    {
        return generateLQ;
    }
    
    public void setGenerateLQ(id lqID)
    {
        system.debug('Set LQ LineQuote from apex:param');
        generateLQ = null;
        for (LineQuote GL :Ws_QOALQs)
        {
            if (lqID == GL.OppItem.ID)
            {
                generateLQ = GL;
                system.debug('Found CreateLineItem assigned to LQ');
            }
        }
    }

 

 

So the page code for the link in the line is:

 

 

<apex:pageBlockTable id="ProductsTable" style="text-align: center" value="{!Ws_QOALQs}"  var="LQ" columns="10" align="center" >
    <apex:column headerValue="Click to Generate RequestID" width="10%">
         <apex:CommandLink value="Generate RequestID" action="{!GenerateRequestID}" reRender="theMessages">
              <apex:param name="LQ" value="{!LQ.OppItem.ID}" assignTo="{!generateLQ}" />
         </apex:CommandLink>
    </apex:column>
</apex:pageBlockTable>

 

 

So, the CommandLink calls the GenerateRequestID method in the controller (shown below), and uses the parameter tag to assign the line's Id to the setGenerateLQ method where it is used by the controller in this method:

 

 

 public PageReference GenerateRequestId(LineQuote LQ)
    {
        PageReference returnPage;
        returnPage = new PageReference(Ws_QOA.QOA_DetailedQuote_Create(LQ)).setRedirect(true);
        return returnPage;
    }

 

 

So, currently the page doesn't recognize this method. However, if I remove the LineQuote LQ argument, it sees the method, for example

 

 

public PageReference GenerateRequestId(){return null;}

 

 

So, I don't know if I'm using the param tag incorrectly, or if I'm calling the method incorrectly, or if I even need to send the LQ object to the method at all. I believe I do as an almost exact copy of the process is working for another page on another controller, but I can't identify the significant difference.

 

Any ideas on why my page recognizes one version of the method, but not the other, and is it the way I'm using the param tag or something else??

 

 

Seems like the guide is trying to be clear about this, but not for me. Most of the examples in other questions I've found about this topic are WAYYYY too long to read through, so I'll try to make mine simple:

 

Here's the first part of my controller extension:

 

 

public class Controller_OppItemEdit_OverRide
{

OpportunityLineItem OLI public Controller_OppItemEdit_OverRide (ApexPages.StandardController stdController) { this.OLI = (OpportunityLineItem)stdController.getRecord(); }

Now according to the APEX Guide:

"Note that only the fields that are referenced in the associated Visualforce markup are available for querying on this SObject. All other fields, including fields from any related objects, must be queried using a SOQL expression."

 

That would seem to mean that if I reerence a field that is on the Controller Object in the VF Page, I don't have to query for it using SOQL. But from my experence, I'm not sure I believe this. To continue:

 

 

public OpportunityLineItem getOLI()
    {
    	return OLI;
    }
    
    public void setOLI(OpportunityLineItem LI)
    {
    	this.OLI = LI;
    }

 

 

Adding these getter and setter methods or the standard Controller seems redundant to me, but someone else did this in an example and said it worked for them in their instance, so I include it here. Maybe that;s the problem, maybe not - I don't know.

 

 

public PageReference Save()
    {
system.debug('MRC is '+OLI.MRC__c+' and NRC is '+OLI.NRC__c);
    	
OLI.TotalPrice = OLI.MRC__c + OLI.NRC__c;
    	
update OLI;

return null;

}

 

 

That's it for the Controller code in its simplest form. All of the fields are referenced in the VF Page as inputFields. So, I would assume that if I change one of those inputFields, and click a button that calls an Update to the record, that the record would be updated with the new values.

This assumption is clearly wrong as the record does not get updated.

Here is the essence of the Page:

 

 

<apex:page standardController="OpportunityLineItem" extensions="Controller_OppItemEdit_OverRide" >
<apex:form >
<apex:outputPanel id="thePanel">
<apex:pageBlock id="theBlock" >
<apex:pageBlockButtons >

<apex:CommandButton action="{!save}" value="Save Changes" rerender="thePanel"/>

 </apex:pageBlockButtons>
<apex:PanelGrid columns="2"> New MRC:&nbsp; <apex:inputField value="{!OpportunityLineItem.MRC__c}"/> New NRC:&nbsp; <apex:inputField value="{!OpportunityLineItem.NRC__c}"/> </apex:PanelGrid> </apex:pageBlock> </apex:outputPanel> </apex:form> </apex:page>

  So that's pretty much it. I add a value to the inputField, and click the Save button. The values in the page remain, however the debug statement indicates the values being set are still null, even though the debug log says the update went through as expected. Nows the previously saved values for the record are appearing in the page, but the new values do not appear to be getting to the database.

 

To resolve this I added a query for the Line Item record in the Constructor method:

 

 

OpportunityLineItem OLI;

public Controller_OppItemEdit_OverRide (ApexPages.StandardController stdController) 
    {
        this.OLI = (OpportunityLineItem)stdController.getRecord();
         OLI=[SELECT id, OpportunityID, MRC__c, NRC__c, ...
    		 FROM OpportunityLineItem
    		 WHERE id = :OLI.id];
    }

// And then I added individual properties for each of the fields:

    public decimal MRC {get; set;}
    public decimal NRC {get; set;}

 

 

Now, I can change the inputFields into InputText boxes in the page. And because there is now a property to receive and provide these values, I can now set the OLI record values from the properties:

 

 

public PageReference Save()
    {
        if (MRC != null)
    		OLI.MRC__c = MRC;
    	if (NRC != null)
    		OLI.NRC__c = NRC;
    update OLI;
    }

 

 

This does update the values in the record, which is great - except that I'm having to write customized logic for what should be already available by virtue of using a standard controller and inputFields. I would go ahead and use this except that one of the fields I need is a picklist, and setting up the SelectOptions for a field that is already available on the object means the list of values has to be updated whenevfer someone changes them in SFDC. I realize I could write some long getDescribe method to extrsact the current set of field values, but that seems kind of stupid in this case.

When I add the inputField for this field, all of the current options are already availavble for selection - except the selection doesn't save.

 

I can only guess at this point that I'm declaring the extension incorrectly, or overwriting something but the Dev guide is pretty clear:

 

 

public class myControllerExtension {

    private final Account acct;
    
    public myControllerExtension(ApexPages.StandardController stdController) {
        this.acct = (Account)stdController.getRecord();
    }

By the way, above this example is the following statement:

   ApexPages.StandardController sc = new ApexPages.StandardController(sObject);

The example below it doesn't use this statement. Obviously its a way to create and instantiate a new Standard Controller variable, but there is no indication as to why I would want to use this statement, or if I would need to use it, or if the example below is the equivalent of this statement when used as part of an extension.

 

So, in order to actually get the values I input into the inputFields in a page using a StandardController extension, what am I missing??

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

sdf

After reading through the Introduction to Exception Handling guide, I was able to construct a Custom Exception class..

 

public class QException extends Exception{}

 

 

..., and in the inside of a try{} catch{} statement I have:

 

 

try
{
   if (condition)
   {
       throw new QException();
   }
} catch (QException e)
{
   e.setMessage('Error Message')
   Apex.addMessages(e);
}

 

 

In this case, the error message shows up in the debug log, but not on the page. Also, the scipt continues to run after the catch statement - when I actually want to the script to stop and the message to be displayed to the Page. I thought that was the point of using a custom Exception - probably wrong about that.

 

Now if I put the entire try-catch statement into a for loop, I can use the break; statement to stop the script and display the message:

 

 

for (loop condition)
{
   
   try
   {
      if (condition)
      {
          throw new QException();
      }
   } catch (QException e)
   {
      e.setMessage('Error Message')
      Apex.addMessages(e);
      break;
   }
}

 

 

This works!

 

So it seems like I'm doing something wrong with the first example, with subsequent code running after the Exception is thrown, or else the loop/break process provides some additional code-stopping capability that I can take advantage of here. However, not all Exceptions happen in loops, and it seems silly to force one's code into a loop to be able to use the try/catch process for exceptions - which seems to be the tried and true method from what I've seen.

 

Also, adding an id to the PageMessages and reRendering (reRender="Messages") it doesn't seem to work either, but I'm probably doing that wrong as well.

 

Any replies, suggestions, explanations are appreciated.

 

 

 

 

This should be fairly simple

 

I have a pageTable with one column dedicated to a selectCheckbox for the row item. If the user click the pageBlockButton while no item is selected, I was hiping to either use the ApexPages Message component, or if that's overkill, just display a Javascript alert when the button is pushed.

 

I've tried creating a boolean checking method on the display list

 

 

public boolean checkMethod (list<object> objectList)
{
    boolean check = false;
    for (Object obj :ObjectList)
    {
        if (obj.Selected = true)
            check = true;
    }
     return check
}

 I then call this as part of the method referenced by the button:

 

public Pagereference processItems()
{
   if (!objectList.isEmpty())
   {
       if (!checkSelection(ObjectList)
       {
           ApexPages.Message err = new ApexPages.Message(
              ApexPages.Severity.ERROR, 'No selection has been made. Select an item before continuing');
           ApexPages.addMessage(err);
       }
   }
   else
   ...run Method

 however, this does not display anything in the page when using either <apex:PageMessages></apex:PageMessages>, or using <apex:Messages>.

 

 

The other idea was to put logic into the action attribute of the commandButton. I created a boolean property called checkSelection, I changed the above checkSelection method to 'getCheckSelection', and then wrote the action attribute as

action="{!IF checkSelection, processItems, alert('Please select item before continuing')}"

 

but that didn't work either.

 

Suggestions and solutions are most appreciated

 

ODB

 

It seems like I've read several solutions to this, none of which appear to work for me

 

I have a page that will have two tables. WHich one is rendered depends on a picklist option in a selectList.

 

Relevant Apex Code:

 

public string LineType;

public string getLineType()    // This is the selectOption value from the selectList
    {
        return LineType;
    }
    public void setLineType(string LT)
    {
        this.LineType = LT;
    }


    public list<OpportunityLineItem> LineItems;
    
    public list<OpportunityLineItem> getLineItems()  // for the Opp Line Item table
    {
        
        LineItems = [SELECT id, TotalPrice, PriceBookEntry.Product2.Name, Opportunity.Name
                     FROM OpportunityLineItem
                     WHERE OpportunityID = :ApexPages.currentPage().getParameters().get('Id')];
        return LineItems;
    }
    
    public list<QuoteLineItem> QuoteLines;
    
    public list<QuoteLineItem> getQuoteLines()     // for the Quote Line Item Table
    {
        QuoteLines = [SELECT id, Quantity, UnitPrice, PriceBookEntry.Product2.Name 
                      FROM QuoteLineItem
                      WHERE Quote.OpportunityId = :Opp.Id];
        return QuoteLines;
    }

 

 

And the Apex Code

 

<apex:page standardcontroller="Opportunity" extensions="QOA_ManageQuotesController" >
<h1> Manage Quotes for {!Opportunity.Name} </h1>
<apex:form >

<apex:pageBlock id="LineItemsTable">
<h1> Select Line Type </h1>
<apex:selectList id="TableSelect" value="{!LineType}" size="1" >
<apex:selectOption itemValue="Products" itemLabel="Products"/>
<apex:selectOption itemValue="QOA" itemLabel="QOA"/>
<apex:selectOption itemValue="SFDC Lite" itemLabel="SFDC Lite"/>
</apex:selectList>



<apex:pageBlockTable id="Table" value="{!LineItems}" var="item" columns="6" rendered="{!LineType == 'Products'}" >
<apex:column headervalue="Products">
<apex:outputLink value="/{!item.id}" id="theLink">{!item.PriceBookEntry.Product2.Name}</apex:outputLink>
</apex:column>
<apex:column value="{!item.TotalPrice}"/>
<apex:column headerValue="Create" width="5%">
<apex:commandButton action="{!CreateQuote}"/ value="Create Quote">
</apex:column>
<apex:column headerValue="View" width="5%">
<apex:commandButton action="{!ViewQuote}"/ value="View Quote">
</apex:column>
<apex:column headerValue="Refresh" width="5%">
<apex:commandButton action="{!RefreshQuote}"/ value="Refresh Quote">
</apex:column>
<apex:column headerValue="Delete" width="5%">
<apex:commandButton action="{!DeleteQuote}"/ value="Delete Quote">
</apex:column>
</apex:pageBlockTable>


</apex:pageBlock>
</apex:form>
</apex:page>

 

 

The results of this is that the table is not rendered when the Products value is selected.

 

If I remove the 'rendered="{!LineType =='Products'}"' attribute, the LineItems page renders as expected. I've tried using

{!IF(LineType = 'Products', true, false)}, which doesn't work, although both

 

rendered="{!LineType != 'Products'}" and {!IF(LineType = 'Products', false, true)} works just fine, except its wrong.

 

Clearly the LineType value isn't being set, or else the Table component isn't seeing it. Can someone tell me where I'm going wrong here??

I have a VF Page where the constructor access a get method which queries a list of Accounts for display in a PageBlockTable.

 

If the list gets loaded, the page displays correctly with the table of Accounts.

 

However, if no Accounts are loaded from the query, the page is blank. What I want to do is redirect to a different page with a message saying No Accounts are available with a button to return back to another page. 

 

I haven't been able to figure how to add this redirect though. 

 

I have a PageReference method which is set correctly, and the constructor reads

 

 

public class AccountList { public AccountList() { EligibleAccts = getEligibleAccts(); if (getEligibleAccts().isEmpty()) { NoEligibleAccts(); } system.debug('EligibleAccts size is '+EligibleAccts.size()); }

 

public Account[] getEligibleAccts()

{

  EligibleAccts = [QUERY];
return EligibleAccts;

} public Pagereference NoEligibleAccts() { PageReference PR = new PageReference('/apex/NoEligibleAccts'); PR.setRedirect(true); }

 

 THE PAGE CODE

 

<apex:page Controller="AccountList" sidebar="false" standardStylesheets="true"

 <apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:CommandButton action="{!TRStatusSet}" value="Set Transfer Status"/>
<apex:CommandButton action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!EligibleAccts}" var="acc" >

....PageBlockTable columns

</apex:pageBlockTable>

</apex:pageBlock>
</apex:form>

 

</apex:page>

 

 

So, this doesn't work. The page loads as a blank white page.

 

So I'm not sure of the best method for doing this, and none of my attempts have worked. I suspect this is due to my lack of understanding of JavaScript, which I am learning slowly. Maybe an answer to this will help.

 

So, should I

1) Try to use an 'action' process on the <apex:page> that could redirect, if I can create a conditional statement at that point in the code

2) Tweak my constructor method to make the above process work?

3) Adapt the link that calls the page - currently I'm just using a URL for the Custom Link. I believe I've seen an OnClick JavaScript syntax before which can direct the user to a different page, but can I access the controller's getEligibleAccts method to check for a result before I set which VF Page to sned the user???

 

Any help is appreciated

 

ODB

 

 

 

 

Don't know quite what's up with this. Seems like it should be simple. Here's the relevant code:

 

<apex:pageBlockSection rendered="{!IF(Opp.Utility__c = "CA-SDGE","true","false")}"
            title="Login ..." id="Login"> 
     <apex:pageBlockSectionItem >
           <bUsername:</b>&nbsp;&nbsp; <apex:inputText value="{!username}" label="Username" required="true"/>
     </apex:pageBlockSectionItem>
     <apex:pageBlockSectionItem />
     <apex:pageBlockSectionItem >
           <b>Password:</b>&nbsp;&nbsp; <apex:inputSecret value="{!password}" label="Password" required="true"/>
     </apex:pageBlockSectionItem>
</apex:pageBlockSection>

 If I remove the rendered statement the page works fine. With the statement, I get the following error:

 

"The element type "apex:pageBlockSection" must be terminated by the matching end-tag "</apex:pageBlockSection>""

 

I have the matching end tag, and the same rendered statement is working to render a button on the page.

 

Any ideas why this isn't working?

Hi, I need to know if is possible to use a AutoNumber field before an update/insert.

Let me explain:

 

Trigger -->  Class

 

Inside my class, I need to use the field MyNumber (AutoNumber ) for some calculus and write inside other field.

 

When I try to use it the result is always null :

 

System.debug(MyNumber__c);

 

Could someone help me?

 

Thank you in advance,

Alessandro

I am able to embed the VF page I want into a custom controller, but its behavior is very weird.

 

I have a series of currency values that I am putting in a panel grid. The VF Code looks like this:

 

<apex:page standardController="Object__c" extensions="RevenueBookController">
   <apex:CommandButton action="{!save}" value="Update Revenue Book" rerender="thePanel" /> 
  <apex:form >
        <apex:CommandButton
        <apex:outputPanel id="thePanel">
        <apex:panelGrid columns="6" id="theGrid" width="80%">
            <b>Revenue Types:</b> 
            <apex:outputText value="Month 1" id="Month1"/> 
            <apex:outputText value="Month 2" id="Month2"/>
            <apex:outputText value="Month 3" id="Month3"/>
            <apex:outputText value="Quarter" id="Quarter"/>
            <apex:outputText value="Total" id="Total"/>
            
            <apex:outputText value="Revenue: " id="Revenue"/>
            <apex:inputField value="{!Object__c.Revenue_Month1__c}"/> 
            <apex:inputField value="{!Object__c.Revenue_Month2__c}"/>
            <apex:inputField value="{!Object__c.Revenue_Month3__c}"/>
            <apex:inputField value="{!Object__c.Revenue_Quarter__c}"/>
            <apex:outputField value="{!Object__c.Revenue_Total__c}"/>
    
        </apex:panelGrid>
      </apex:outputPanel>
  </apex:form>
</apex:page>

 When I go to the page it looks right - the input fields show up in a grid as expected. However, when I add a value to one of the input fields and hit the update button, the entire page refreshes within the VF section.

What I want to happen is to just have the outputpanel refresh with updated numbers in the Total field.

 

Its probably something obvious, but its stumping me. Any suggestions and solutions appreciated.

I'm probably doing this wrong, but I've set up a process to get a set of Campaign reports from Google Analytics which is failing.

 

The problem appears o be that I nee twodifferent callouts: one for the authenitication, another for the actual query once I've received the authentication token.

 

I'm not an expert on callouts but is ther some way to combine the authentication with the query??

 

Here's what I have:

 

Authenntication:

Http m_http = new Http();
HttpRequest req = new HttpRequest();

String content = 'accountType=GOOGLE&Email='+username+'&Passwd='+passwd+'&service='+service;

req.setEndpoint('https://www.google.com/accounts/ClientLogin');
req.setHeader('Content-Type','application/x-www-form-urlencoded');
req.setHeader('User-Agent','salesforce-toolkit-googledata/21');
req.setMethod('POST');
req.setBody(content);

httpResponse response = m_http.send(req);

 The response returns the clientLoginToken, which I thought would allow me to then callout to GA to get the report data I want:

 

 

HttpRequest req = new HttpRequest();
HttpResponse response = new HttpResponse();

req.setEndpoint(URL);
req.setMethod('GET');
req.setHeader('content-type', CONTENT_TYPE_URL );
req.setHeader('Authorization','GoogleLogin auth='+clientLoginToken);
req.setHeader('Accept-Encoding','compress, gzip');

Http http = new Http();
response = http.send(req);

 

 

As far as I know, and I have to believe I have it wrong, this is the process for getting ay data out of Google Analytics, unless there is some way to combine the login request with the query in the same callout, which I don't know how to do if it is possible.

 

This is being used to update Campaigns in SFDC, for which there may be quite a few and for which a Batch Process needs to be employed.

 

Any help or pointers are appreciated.

 

Thanks

ODB

 

Hi,

 

I'm trying to write unit tests for Content. It seems that it is impossible to create a Workspace record in Apex, so I guess we have to use an existing one in the org?

 

Bigger question: If I create a Content record, relate it to an existing workspace using FirstPublishLocationId, and insert it, and then try to make an update to that Content record, I get this error:

 

Document with ID: 06930000000YPbp already has an owning Workspace

 

I get the same error whether or not this is in a test class. If I do it outside of a test class, and just use the record Id a few seconds later to do my update, it will work. So, it seems to be time-based... Is it not possible to update a newly created Content record from within a test class?

 

Thanks,

Tom

I have a method in my controller that is not being sween by the page, even though the names are identical

 

I am using a commandLink in a pageblocktable for each line. the action for the link goes to a method that requries a class object for its argument. Whereas each of the lines on the page are made up of these class objects, I apparently have to associate the line object with a property in the controller. So, the line object code is:

 

 

public LineQuote generateLQ;
    
    public LineQuote getGenerateLQ()
    {
        return generateLQ;
    }
    
    public void setGenerateLQ(id lqID)
    {
        system.debug('Set LQ LineQuote from apex:param');
        generateLQ = null;
        for (LineQuote GL :Ws_QOALQs)
        {
            if (lqID == GL.OppItem.ID)
            {
                generateLQ = GL;
                system.debug('Found CreateLineItem assigned to LQ');
            }
        }
    }

 

 

So the page code for the link in the line is:

 

 

<apex:pageBlockTable id="ProductsTable" style="text-align: center" value="{!Ws_QOALQs}"  var="LQ" columns="10" align="center" >
    <apex:column headerValue="Click to Generate RequestID" width="10%">
         <apex:CommandLink value="Generate RequestID" action="{!GenerateRequestID}" reRender="theMessages">
              <apex:param name="LQ" value="{!LQ.OppItem.ID}" assignTo="{!generateLQ}" />
         </apex:CommandLink>
    </apex:column>
</apex:pageBlockTable>

 

 

So, the CommandLink calls the GenerateRequestID method in the controller (shown below), and uses the parameter tag to assign the line's Id to the setGenerateLQ method where it is used by the controller in this method:

 

 

 public PageReference GenerateRequestId(LineQuote LQ)
    {
        PageReference returnPage;
        returnPage = new PageReference(Ws_QOA.QOA_DetailedQuote_Create(LQ)).setRedirect(true);
        return returnPage;
    }

 

 

So, currently the page doesn't recognize this method. However, if I remove the LineQuote LQ argument, it sees the method, for example

 

 

public PageReference GenerateRequestId(){return null;}

 

 

So, I don't know if I'm using the param tag incorrectly, or if I'm calling the method incorrectly, or if I even need to send the LQ object to the method at all. I believe I do as an almost exact copy of the process is working for another page on another controller, but I can't identify the significant difference.

 

Any ideas on why my page recognizes one version of the method, but not the other, and is it the way I'm using the param tag or something else??

 

 

Seems like the guide is trying to be clear about this, but not for me. Most of the examples in other questions I've found about this topic are WAYYYY too long to read through, so I'll try to make mine simple:

 

Here's the first part of my controller extension:

 

 

public class Controller_OppItemEdit_OverRide
{

OpportunityLineItem OLI public Controller_OppItemEdit_OverRide (ApexPages.StandardController stdController) { this.OLI = (OpportunityLineItem)stdController.getRecord(); }

Now according to the APEX Guide:

"Note that only the fields that are referenced in the associated Visualforce markup are available for querying on this SObject. All other fields, including fields from any related objects, must be queried using a SOQL expression."

 

That would seem to mean that if I reerence a field that is on the Controller Object in the VF Page, I don't have to query for it using SOQL. But from my experence, I'm not sure I believe this. To continue:

 

 

public OpportunityLineItem getOLI()
    {
    	return OLI;
    }
    
    public void setOLI(OpportunityLineItem LI)
    {
    	this.OLI = LI;
    }

 

 

Adding these getter and setter methods or the standard Controller seems redundant to me, but someone else did this in an example and said it worked for them in their instance, so I include it here. Maybe that;s the problem, maybe not - I don't know.

 

 

public PageReference Save()
    {
system.debug('MRC is '+OLI.MRC__c+' and NRC is '+OLI.NRC__c);
    	
OLI.TotalPrice = OLI.MRC__c + OLI.NRC__c;
    	
update OLI;

return null;

}

 

 

That's it for the Controller code in its simplest form. All of the fields are referenced in the VF Page as inputFields. So, I would assume that if I change one of those inputFields, and click a button that calls an Update to the record, that the record would be updated with the new values.

This assumption is clearly wrong as the record does not get updated.

Here is the essence of the Page:

 

 

<apex:page standardController="OpportunityLineItem" extensions="Controller_OppItemEdit_OverRide" >
<apex:form >
<apex:outputPanel id="thePanel">
<apex:pageBlock id="theBlock" >
<apex:pageBlockButtons >

<apex:CommandButton action="{!save}" value="Save Changes" rerender="thePanel"/>

 </apex:pageBlockButtons>
<apex:PanelGrid columns="2"> New MRC:&nbsp; <apex:inputField value="{!OpportunityLineItem.MRC__c}"/> New NRC:&nbsp; <apex:inputField value="{!OpportunityLineItem.NRC__c}"/> </apex:PanelGrid> </apex:pageBlock> </apex:outputPanel> </apex:form> </apex:page>

  So that's pretty much it. I add a value to the inputField, and click the Save button. The values in the page remain, however the debug statement indicates the values being set are still null, even though the debug log says the update went through as expected. Nows the previously saved values for the record are appearing in the page, but the new values do not appear to be getting to the database.

 

To resolve this I added a query for the Line Item record in the Constructor method:

 

 

OpportunityLineItem OLI;

public Controller_OppItemEdit_OverRide (ApexPages.StandardController stdController) 
    {
        this.OLI = (OpportunityLineItem)stdController.getRecord();
         OLI=[SELECT id, OpportunityID, MRC__c, NRC__c, ...
    		 FROM OpportunityLineItem
    		 WHERE id = :OLI.id];
    }

// And then I added individual properties for each of the fields:

    public decimal MRC {get; set;}
    public decimal NRC {get; set;}

 

 

Now, I can change the inputFields into InputText boxes in the page. And because there is now a property to receive and provide these values, I can now set the OLI record values from the properties:

 

 

public PageReference Save()
    {
        if (MRC != null)
    		OLI.MRC__c = MRC;
    	if (NRC != null)
    		OLI.NRC__c = NRC;
    update OLI;
    }

 

 

This does update the values in the record, which is great - except that I'm having to write customized logic for what should be already available by virtue of using a standard controller and inputFields. I would go ahead and use this except that one of the fields I need is a picklist, and setting up the SelectOptions for a field that is already available on the object means the list of values has to be updated whenevfer someone changes them in SFDC. I realize I could write some long getDescribe method to extrsact the current set of field values, but that seems kind of stupid in this case.

When I add the inputField for this field, all of the current options are already availavble for selection - except the selection doesn't save.

 

I can only guess at this point that I'm declaring the extension incorrectly, or overwriting something but the Dev guide is pretty clear:

 

 

public class myControllerExtension {

    private final Account acct;
    
    public myControllerExtension(ApexPages.StandardController stdController) {
        this.acct = (Account)stdController.getRecord();
    }

By the way, above this example is the following statement:

   ApexPages.StandardController sc = new ApexPages.StandardController(sObject);

The example below it doesn't use this statement. Obviously its a way to create and instantiate a new Standard Controller variable, but there is no indication as to why I would want to use this statement, or if I would need to use it, or if the example below is the equivalent of this statement when used as part of an extension.

 

So, in order to actually get the values I input into the inputFields in a page using a StandardController extension, what am I missing??

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

sdf

This should be fairly simple

 

I have a pageTable with one column dedicated to a selectCheckbox for the row item. If the user click the pageBlockButton while no item is selected, I was hiping to either use the ApexPages Message component, or if that's overkill, just display a Javascript alert when the button is pushed.

 

I've tried creating a boolean checking method on the display list

 

 

public boolean checkMethod (list<object> objectList)
{
    boolean check = false;
    for (Object obj :ObjectList)
    {
        if (obj.Selected = true)
            check = true;
    }
     return check
}

 I then call this as part of the method referenced by the button:

 

public Pagereference processItems()
{
   if (!objectList.isEmpty())
   {
       if (!checkSelection(ObjectList)
       {
           ApexPages.Message err = new ApexPages.Message(
              ApexPages.Severity.ERROR, 'No selection has been made. Select an item before continuing');
           ApexPages.addMessage(err);
       }
   }
   else
   ...run Method

 however, this does not display anything in the page when using either <apex:PageMessages></apex:PageMessages>, or using <apex:Messages>.

 

 

The other idea was to put logic into the action attribute of the commandButton. I created a boolean property called checkSelection, I changed the above checkSelection method to 'getCheckSelection', and then wrote the action attribute as

action="{!IF checkSelection, processItems, alert('Please select item before continuing')}"

 

but that didn't work either.

 

Suggestions and solutions are most appreciated

 

ODB

 

It seems like I've read several solutions to this, none of which appear to work for me

 

I have a page that will have two tables. WHich one is rendered depends on a picklist option in a selectList.

 

Relevant Apex Code:

 

public string LineType;

public string getLineType()    // This is the selectOption value from the selectList
    {
        return LineType;
    }
    public void setLineType(string LT)
    {
        this.LineType = LT;
    }


    public list<OpportunityLineItem> LineItems;
    
    public list<OpportunityLineItem> getLineItems()  // for the Opp Line Item table
    {
        
        LineItems = [SELECT id, TotalPrice, PriceBookEntry.Product2.Name, Opportunity.Name
                     FROM OpportunityLineItem
                     WHERE OpportunityID = :ApexPages.currentPage().getParameters().get('Id')];
        return LineItems;
    }
    
    public list<QuoteLineItem> QuoteLines;
    
    public list<QuoteLineItem> getQuoteLines()     // for the Quote Line Item Table
    {
        QuoteLines = [SELECT id, Quantity, UnitPrice, PriceBookEntry.Product2.Name 
                      FROM QuoteLineItem
                      WHERE Quote.OpportunityId = :Opp.Id];
        return QuoteLines;
    }

 

 

And the Apex Code

 

<apex:page standardcontroller="Opportunity" extensions="QOA_ManageQuotesController" >
<h1> Manage Quotes for {!Opportunity.Name} </h1>
<apex:form >

<apex:pageBlock id="LineItemsTable">
<h1> Select Line Type </h1>
<apex:selectList id="TableSelect" value="{!LineType}" size="1" >
<apex:selectOption itemValue="Products" itemLabel="Products"/>
<apex:selectOption itemValue="QOA" itemLabel="QOA"/>
<apex:selectOption itemValue="SFDC Lite" itemLabel="SFDC Lite"/>
</apex:selectList>



<apex:pageBlockTable id="Table" value="{!LineItems}" var="item" columns="6" rendered="{!LineType == 'Products'}" >
<apex:column headervalue="Products">
<apex:outputLink value="/{!item.id}" id="theLink">{!item.PriceBookEntry.Product2.Name}</apex:outputLink>
</apex:column>
<apex:column value="{!item.TotalPrice}"/>
<apex:column headerValue="Create" width="5%">
<apex:commandButton action="{!CreateQuote}"/ value="Create Quote">
</apex:column>
<apex:column headerValue="View" width="5%">
<apex:commandButton action="{!ViewQuote}"/ value="View Quote">
</apex:column>
<apex:column headerValue="Refresh" width="5%">
<apex:commandButton action="{!RefreshQuote}"/ value="Refresh Quote">
</apex:column>
<apex:column headerValue="Delete" width="5%">
<apex:commandButton action="{!DeleteQuote}"/ value="Delete Quote">
</apex:column>
</apex:pageBlockTable>


</apex:pageBlock>
</apex:form>
</apex:page>

 

 

The results of this is that the table is not rendered when the Products value is selected.

 

If I remove the 'rendered="{!LineType =='Products'}"' attribute, the LineItems page renders as expected. I've tried using

{!IF(LineType = 'Products', true, false)}, which doesn't work, although both

 

rendered="{!LineType != 'Products'}" and {!IF(LineType = 'Products', false, true)} works just fine, except its wrong.

 

Clearly the LineType value isn't being set, or else the Table component isn't seeing it. Can someone tell me where I'm going wrong here??

I realize that the DMO Options do not apply to Accounts or Territories, however I am still looking for a good way to assign a Territory to an Account in APEX.

 

Currently we have an assignment rule which assigns the Territory to the Account where the Territory Name matches a Picklist value in the Account. I figured that if I set the Picklist value in APEX and update the Account, the assignment rule should catch it - apparently not - although updating the account again (changing no values) directly in SF does call the assignment rule and attaches the Territory as expected. I'm guessing that running the update Account command twice in APEX won't work either.

 

Since Workflows are evaluated after the Assignment Rules, I don't think a workflow based on the picklist value will work.

 

So, would creating an AccountShare record connecting the Account to the Group that is related to the Territory do the trick??  This is based on the likely mistaken premise that a Territory attached to an Account represents the AccountShare rule that was created - create the AccountShare, and the Territory is connected and should show up in the Account. Seems like flawed thinking to me, but I'm not sure why.

 

I know I'm not the first to encounter this, so I'm hoping someone out there might have the best solution for this.

 

Thanks

 

ODB

I have a very simple Batch class and I am trying to write a unit test to cover it but the execute method in this batch class is never executing. I'm stumped.

 

Batch Class:

global class ideaCleanBatch implements Database.Batchable<sObject>{

global Database.QueryLocator start(Database.BatchableContext bc){
//We want to process all Ideas
return Database.getQueryLocator('select Id from Idea');
}

global void execute(Database.BatchableContext bc, List<sObject> objects){
Set<Id> ideaIds = new Set<Id>();
for(sObject s : objects){
Idea i = (Idea)s;
ideaIds.add(i.Id);
}
//Send ideas to ideaClean for processing
ideaClean.recalcNumbers(ideaIds);
}

global void finish(Database.BatchableContext bc){
system.debug('All done.');
}
}

Test Method:

static testMethod void ideaBatchTest(){
List<Idea> ideas = new List<Idea>();
Id communityId = [select Id from Community limit 1].Id;
for(Integer i = 0; i < 200; i++){
ideas.add(new Idea(Title = 'myIdea' + i, CommunityId = communityId));
}
insert ideas;

Test.startTest();
ideaCleanBatch job = new ideaCleanBatch();
ID batchprocessid = Database.executeBatch(job);
Test.stopTest();
}

Coverage:

 

Thanks,

Jason

 

  • October 30, 2009
  • Like
  • 0
I am new to Apex Code development and am trying to get a trigger to call a web service (imported into Apex Code via wsdl).

This is a simple web service hitting http://www.webservicex.net/WCF/ServiceDetails.aspx?SID=51 (a whois lookup service) for a test.

The wsdl imported correctly and I am now trying to utilze the web service in an Apex trigger.  Here's the code for the call.

trigger helloWorldTrigger on Account (before insert) {
Account[] accs = Trigger.new;
MyHelloWorld.addHelloWorld(accs);
}
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger helloWorldTrigger caused an unexpected exception, contact  your administrator: helloWorldTrigger: execution of BeforeInsert caused by: System.CalloutException: Callout from triggers are currently not supported.: Class.wxWhois.whoisSoap.GetWhoIS: line 19, column 13

I'm reading this error as an indication that Apex triggers currently cannot perform an interaction with web services.  Am I interpreting this error correctly?