• nellymnj
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 11
    Replies

Hello,

i've created a VF page using

Example Code for In-Place Editing in Visualforce

for adding new items to Opportunity Inventory (Move_Inventory_Item__c is a custom object),

and it works fine if there are already Inventory Items added to this Opportunity, but if you try to add a first Item, page just does not do anything. Can anybody see what is wrong here? - thank you very much.

Here is the page:

<apex:page sidebar="false" controller="MoveInventoryController" tabStyle="Inventory_Item__c" action="{!init}" >
<style>
  .alphaOn{font-weight:bold;text-decoration:none;}
  .bPageBlock .pbTitle {width:100%;}
  .bPageTitle {margin-bottom:5px;}
  </style>
<apex:sectionHeader title="Manage Move Inventory" subtitle="{!Opp.Name}"/>
    <apex:outputPanel ><apex:outputLink value="/{!Opp.Id}">« Return to Opportunity</apex:outputLink></apex:outputPanel>
    <apex:pageMessages />
    <apex:form >
    <apex:pageBlock title="Add Non-Standard Inventory Item">
        Name:   <apex:inputField value="{!newItem.Name}"/>
        Size:   <apex:inputField value="{!newItem.Size__c}"/>  
        Weight:   <apex:inputField value="{!newItem.Weight__c}"/>
        Quantity:   <apex:inputField value="{!newItem.Quantity__c}"/>  
        <apex:commandButton value="Add" action="{!add}"/>
    </apex:pageBlock>
    </apex:form>
    <apex:form >
    <apex:pageBlock title="Existing Opportunity Inventory Items  - {!Opp.Volume2__c} cubic feet, {!Opp.Weight__c} lbs" id="inventoryTitle">
    <apex:outputPanel id="inventoryList">
    <table>
        <tr>
            <th style="width:20px"> </th>
            <th style="width:20px"> </th>
            <th style="width:140px">Name</th>
            <th style="width:50px">Size</th>
            <th style="width:50px">Weight</th>
            <th style="width:50px">Quantity</th>
            <th style="width:50px">Total Volume</th>
            <th style="width:50px">Total Weight</th>        
        </tr>
        <apex:repeat value="{!OppInventory}" var="it">
        <tr style="height:20px">
            <apex:outputPanel id="editRow" layout="none" rendered="{!it.Id == editItem.Id}">
                <td><apex:commandLink action="{!cancelEdit}" rerender="inventoryList">Cancel</apex:commandLink></td>
                <td><apex:commandLink action="{!saveEdit}" rerender="inventoryList">Save</apex:commandLink></td>
                <td><apex:inputText size="40" rendered="{!it.Id == editItem.Id}" onkeypress="if (event.keyCode == 13) saveEdit()"
                        value="{!editItem.Name}"/></td>
                <td><apex:inputField rendered="{!it.Id == editItem.Id}" value="{!editItem.Size__c}"/></td>
                <td><apex:inputField rendered="{!it.Id == editItem.Id}" value="{!editItem.Weight__c}"/></td>
                <td><apex:inputField rendered="{!it.Id == editItem.Id}" value="{!editItem.Quantity__c}"/></td>
            </apex:outputPanel>
            <apex:outputPanel id="viewRow" layout="none" rendered="{!it.Id != editItem.Id}">
                <td>
                    <apex:commandLink action="{!del}" onclick="return confirm('Are you sure you want to delete this item?')">Del
                        <apex:param name="delid" value="{!it.Id}"/>
                    </apex:commandLink>
                </td>
                <td>
                    <apex:commandLink action="{!edit}" rerender="inventoryList">Edit
                        <apex:param name="editid" value="{!it.Id}"/>
                    </apex:commandLink>
                </td>
                <td>{!it.Name}</td>
                <td>{!it.Size__c}</td>
                <td>{!it.Weight__c}</td>
                <td>{!it.Quantity__c}</td>
                <td>{!it.Cubic_Feet__c}</td>
                <td>{!it.Total_Weight__c}</td>
                
            </apex:outputPanel>
        </tr>
        </apex:repeat>
    </table>
    </apex:outputPanel>
    </apex:pageBlock>
</apex:form>

</apex:page>

 

and the controller:

 

public with sharing class MoveInventoryController {
    public Move_Inventory_Item__c newItem { get; set; }
    public Move_Inventory_Item__c editItem { get; set; }
    public Opportunity opp { get; set; }

    public MoveInventoryController() {
        newItem = new Move_Inventory_Item__c();
    }
    public PageReference init() {
        try{
            opp = [select Id, Name, Volume2__c, Weight__c
                    from Opportunity
                    where Id = :ApexPages.currentPage().getParameters().get('oppid') LIMIT 1];
        } catch (Exception e) {
            ApexPages.addMessages(e);
        }    
        return null;
    }
    
    public Move_Inventory_Item__c[] getOppInventory() {
        return [select Id, Name, Size__c, Weight__c, Quantity__c, Cubic_Feet__c, Total_Weight__c, Opportunity__c
                    from Move_Inventory_Item__c
                    where Opportunity__c = :ApexPages.currentPage().getParameters().get('oppId')];
    }
    
    public String getParam(String name) {
        return ApexPages.currentPage().getParameters().get(name);    
    }
    
    public PageReference add() {
        try {
            newItem.Opportunity__c = ApexPages.currentPage().getParameters().get('oppId');
            INSERT newItem;
            // if successful, reset the new project for the next entry
            newItem = new Move_Inventory_Item__c();
        } catch (Exception e) {
            ApexPages.addMessages(e);
        }
        return null;
    }
    
    public PageReference del() {
        try {
            String delid = getParam('delid');
            Move_Inventory_Item__c item = [SELECT Id FROM Move_Inventory_Item__c WHERE ID=:delid];
            DELETE item;
        } catch (Exception e) {
            ApexPages.addMessages(e);
        }
        return null;
    }
    
    public PageReference edit() {
        String editid = getParam('editid');
        editItem = [SELECT Id, Name, Size__c, Weight__c, Quantity__c, Cubic_Feet__c, Total_Weight__c
            FROM Move_Inventory_Item__c WHERE Id=:editid];
        return null;
    }
    
    public PageReference cancelEdit() {
        editItem = null;
        return null;
    }
    
    public PageReference saveEdit() {
        try {
            UPDATE editItem;
            editItem = null;
        } catch (Exception e) {
            ApexPages.addMessages(e);
        }
        return null;
    }
}

Hello,

I need to get summary data for every month, so in an apex class, I get the initial date as a parameter, it is date datatype, I convert it to datetime (that's what a need to send to the external web service) and iterate through the months. the problem is that i am getting incorrect month number from both datetime.month() and datetime.format('yyyy-MM-dd') functions for 3-rd and 4-th iterations.

Here is sysdem.debug otput for 4 iteratios. First value is the initial datetime dtfrom, second value is the result of datetime dttask = dtfrom.addMonths(i) (i changes from 0 to 3), third value is a result of formatting dttask.format('yyyy-MM-dd'), and 4-th values is dttask.month():

i = 0:

20091211155205.873:Class.Forecasting.GetTasks: line 298, column 4: 2009-10-01 07:00:00
20091211155205.873:Class.Forecasting.GetTasks: line 300, column 4: 2009-10-01 07:00:00
20091211155205.873:Class.Forecasting.GetTasks: line 302, column 4: 2009-10-01
20091211155205.873:Class.Forecasting.GetTasks: line 308, column 4: 10

i = 1:

 

20091211155205.873:Class.Forecasting.GetTasks: line 298, column 4: 2009-10-01 07:00:00
20091211155205.873:Class.Forecasting.GetTasks: line 300, column 4: 2009-11-01 07:00:00
20091211155205.873:Class.Forecasting.GetTasks: line 302, column 4: 2009-11-01
20091211155205.873:Class.Forecasting.GetTasks: line 308, column 4: 11

i = 2

 

20091211155205.873:Class.Forecasting.GetTasks: line 298, column 4: 2009-10-01 07:00:00
20091211155205.873:Class.Forecasting.GetTasks: line 300, column 4: 2009-12-01 07:00:00
20091211155205.873:Class.Forecasting.GetTasks: line 302, column 4: 2009-11-30
20091211155205.873:Class.Forecasting.GetTasks: line 308, column 4: 11
i=3
 20091211155205.873:Class.Forecasting.GetTasks: line 298, column 4: 2009-10-01 07:00:00
20091211155205.873:Class.Forecasting.GetTasks: line 300, column 4: 2010-01-01 07:00:00
20091211155205.873:Class.Forecasting.GetTasks: line 302, column 4: 2009-12-31
20091211155205.873:Class.Forecasting.GetTasks: line 308, column 4: 12
so for third iteration formatting returns the previous day and month is the previous month.
what's wrong with that? van anybody please help? Thank you very much for any input. 
Hello.
I've build a VisualForce page based on custom controller. Custom controller has 2 public getter method; both methods return list of accounts: Lapsed Members and Inactive Members. Account is set up as person account and I want to show 2 contact custom field on a page: Membership_Type__pc and Membership_Status__pc.
Here is  the page code:
<apex:page controller="ResetMember" tabStyle="Account">
  <apex:pageBlock title="Accounts with incorrect membership status"> 
          <apex:pageBlockTable value="{!lpsAccounts}" var="item">
          <apex:facet name="header">Lapsed Accounts</apex:facet>
          <apex:column value="{!item.name}"></apex:column>
          <!--<apex:column value="{!item.Membership_Type__pc}"></apex:column>-->
          <apex:column headerValue="Membership Status">
              <apex:outputText>Active Member</apex:outputText>
          </apex:column>
      </apex:pageBlockTable> 
      </apex:form>      
  </apex:pageBlock>
</apex:page>
 
As soon as i uncomment the line:
<!--<apex:column value="{!item.Membership_Type__pc}"></apex:column>-->
the page displays an error:
Invalid field Membership_Type__c for SObject Account
Is there a known problem with person account custom field in VisualForce or I am doing somthing wrong?
 
Thank you very much for any input
Hello,
I've written S-control that calls external web service. It works on development site, but I could not deploy it on production site. For s-control to work I've generated classes from the external web service wsdl, and written TestMethods for these classes (got 83% test coverage),

the error is : Methods defined as TestMethods do not support Web service callouts, test skipped

//Generated by wsdl2apex

global class localhostSoap {

public class Root_PortType {

public String endpoint_x = 'http://localhost/soap/';

private String[] ns_map_type_info = new String[]{'http://localhost/soap/types', 'localhostSoapTypes', 'http://localhost/soap/', 'localhostSoap'};

public Integer deleteTable(String server_name,Integer port,String table_name) {

localhostSoapTypes.deleteTable_element request_x = new localhostSoapTypes.deleteTable_element();

localhostSoapTypes.deleteTableResponse_element response_x;

request_x.server_name = server_name;

request_x.port = port;

request_x.table_name = table_name;

Map<String, localhostSoapTypes.deleteTableResponse_element> response_map_x = new Map<String, localhostSoapTypes.deleteTableResponse_element>();

response_map_x.put('response_x', response_x);

WebServiceCallout.invoke(

this,

request_x,

response_map_x,

new String[]{endpoint_x,

'deleteTable',

'http://localhost/soap/types',

'deleteTable',

'http://localhost/soap/types',

'deleteTableResponse',

'localhostSoapTypes.deleteTableResponse_element'}

);

response_x = response_map_x.get('response_x');

return response_x.result;

}

// other methods here

// added test method

public static testMethod void testdeleteTable(){

localhostSoap lhsoap = new localhostSoap();

localhostSoap.Root_PortType rport = new localhostSoap.Root_PortType();

System.assertEquals(0, rport.deleteTable('localhost',3579,'test') );

}

}

What i am doing wrong here?

thank you very much

Hi all,
 
I am new to Apex programming and am getting weird little error when i try to attach a PDF to Notes and Attachments.  I'm rendering a Visualforce page as a PDF, with an extension to an "EstimateProposal" Apex class.  The project compiles fine, but when I run it in the UI, I get an error "EXCEPTION_THROWN|[70,24]|System.VisualforceException: Too many nested getContent calls."  Funny thing is, the code block works when I execute it anonymously, just not it's part of my VF controller execution flow.  Anyone seen this before or could point me to a resource to fix it?  Any help would be greatly appreciated!
 
****APEX CLASS**** 
    public PageReference attachQuote() {
        PageReference pdfPage = Page.GenerateProposal;
        pdfPage.getParameters().put('id',this.opp.Id);
        Blob pdfBlob = pdfPage.getContent(); 
        Attachment proposalPDF = new Attachment (parentId = this.opp.Id, name=this.opp.name + '.pdf', body = pdfBlob);
        insert proposalPDF;
        return null;  
    } 
}
 

 
****VISUAL FORCE PAGE****
<apex:page standardController="Opportunity" extensions="EstimateProposal" renderAs="pdf" showHeader="false" sidebar="false" >
  • March 31, 2010
  • Like
  • 0
Hello.
I've build a VisualForce page based on custom controller. Custom controller has 2 public getter method; both methods return list of accounts: Lapsed Members and Inactive Members. Account is set up as person account and I want to show 2 contact custom field on a page: Membership_Type__pc and Membership_Status__pc.
Here is  the page code:
<apex:page controller="ResetMember" tabStyle="Account">
  <apex:pageBlock title="Accounts with incorrect membership status"> 
          <apex:pageBlockTable value="{!lpsAccounts}" var="item">
          <apex:facet name="header">Lapsed Accounts</apex:facet>
          <apex:column value="{!item.name}"></apex:column>
          <!--<apex:column value="{!item.Membership_Type__pc}"></apex:column>-->
          <apex:column headerValue="Membership Status">
              <apex:outputText>Active Member</apex:outputText>
          </apex:column>
      </apex:pageBlockTable> 
      </apex:form>      
  </apex:pageBlock>
</apex:page>
 
As soon as i uncomment the line:
<!--<apex:column value="{!item.Membership_Type__pc}"></apex:column>-->
the page displays an error:
Invalid field Membership_Type__c for SObject Account
Is there a known problem with person account custom field in VisualForce or I am doing somthing wrong?
 
Thank you very much for any input
We're building a help system, one with a similar hierarchy as the salesforce help.  I've been having trouble finding documentation on structuring and populating nested lists using visualforce.  We have our content divided into custom objects as follows...

application - top level, not displayed, used to control the content being displayed in multiple customer portals
grouping - Above the list, names act as headers above the tree
category - these categories exand out to show topics
topic - When clicked these open directions in a div to the right of the menu.

so where I'm at...

I have a custom controller that populates the grouping list.  I'm not sure if this should even be a list since its the header for the lists contained with .

public class CODhelp {

List<grouping__c> grouping;

public List<grouping__c> getgrouping() {
if(grouping == null) grouping = [select name from Grouping__c where application__r.name = 'cod'];
return grouping;
}
}


Then I'm creating the list in the visualforce page using the following markup...

<apex:dataList value="{!grouping}" var="grouping__c" id="theList">
<apex:outputText value="{!grouping__c.name}" styleclass="treeHeader"/>
</apex:dataList>


This currently works to populate a list of grouping names for the application "cod".  However I need to go deeper for categories, topics and then the directions (which is a custom field of topic).

The html needed to generate our menu looks like this...

<ul class="tree">
<dt class="treeHeader">Grouping</dt>
<li class="closed"><a href="#">Category 1</a>
<ul>
<li><a href="directions">Topic 1</a></li>
<li><a href="directions">Topic 2</a></li>
</ul>
</li>
</ul>

Unfortunately, I'm at a loss on how to generate this structure using visualforce and populate it with the data from our custom objects.  I would greatly appreciate any suggestions or assistance on how to successfully achieve the desired result.

Thanks.


Hello,
I've written S-control that calls external web service. It works on development site, but I could not deploy it on production site. For s-control to work I've generated classes from the external web service wsdl, and written TestMethods for these classes (got 83% test coverage),

the error is : Methods defined as TestMethods do not support Web service callouts, test skipped

//Generated by wsdl2apex

global class localhostSoap {

public class Root_PortType {

public String endpoint_x = 'http://localhost/soap/';

private String[] ns_map_type_info = new String[]{'http://localhost/soap/types', 'localhostSoapTypes', 'http://localhost/soap/', 'localhostSoap'};

public Integer deleteTable(String server_name,Integer port,String table_name) {

localhostSoapTypes.deleteTable_element request_x = new localhostSoapTypes.deleteTable_element();

localhostSoapTypes.deleteTableResponse_element response_x;

request_x.server_name = server_name;

request_x.port = port;

request_x.table_name = table_name;

Map<String, localhostSoapTypes.deleteTableResponse_element> response_map_x = new Map<String, localhostSoapTypes.deleteTableResponse_element>();

response_map_x.put('response_x', response_x);

WebServiceCallout.invoke(

this,

request_x,

response_map_x,

new String[]{endpoint_x,

'deleteTable',

'http://localhost/soap/types',

'deleteTable',

'http://localhost/soap/types',

'deleteTableResponse',

'localhostSoapTypes.deleteTableResponse_element'}

);

response_x = response_map_x.get('response_x');

return response_x.result;

}

// other methods here

// added test method

public static testMethod void testdeleteTable(){

localhostSoap lhsoap = new localhostSoap();

localhostSoap.Root_PortType rport = new localhostSoap.Root_PortType();

System.assertEquals(0, rport.deleteTable('localhost',3579,'test') );

}

}

What i am doing wrong here?

thank you very much