• OldDeadBug
  • NEWBIE
  • 55 Points
  • Member since 2007

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

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

 

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?