• pdost
  • NEWBIE
  • 5 Points
  • Member since 2011

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

I have a very simple page that was working in my Customer Portal previous to the current release, but no longer does.  The page works fine in the general User environment, but when used in my Customer Portal, it no longer works.  Below is the page.  Also, my Profiles and Customer Portal have access to the page.

 

 Page

<apex:page showHeader="false" standardController="Product_Sales__c" recordSetVar="productsales" tabStyle="Product_Sales__c">
    <apex:form >
        <apex:pageBlock title="Update Product Sales">
        <apex:pageBlockButtons location="top">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
        </apex:pageBlockButtons>
        <apex:pageBlockTable var="ps" value="{!selected}">
            <apex:column value="{!ps.Product_Category__c}"/>
            <apex:column value="{!ps.Product__c}"/>
            <apex:column value="{!ps.Product_Purchases_from_Sales_Rep__c}"/>
            <apex:column headerValue="{!$ObjectType.Product_Sales__c.Fields.Total_Customer_Wallet__c.Label}">
                <apex:inputField value="{!ps.Total_Customer_Wallet__c}"/>
            </apex:column>
            <apex:column headerValue="{!$ObjectType.Product_Sales__c.Fields.Estimated_Percentage_of_Wallet__c.Label}">
                <apex:inputField value="{!ps.Estimated_Percentage_of_Wallet__c}"/>
            </apex:column>
            <apex:column value="{!ps.Purchase_Potential_Growth__c}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

  • March 03, 2012
  • Like
  • 0

I am trying to get complete coverage for my test class and cannot get there as I cannot get passed 56%.  Can anyone point me in the right direction?

 

Class

public class oitemController
{
    public List<Product_Bundle__c> lstbundle = new List<Product_Bundle__c>();
    public List<Order_Item_Junction__c> lstoitem {get;set;}
    public ID<Order__c> oid {get;set;}
    public string orderid;
    public integer iqty;
    public boolean proceed {get;set;}
    
    public boolean setproceed()
    {
        return true;
    }
    
    public PageReference saveitems()
    {
        //Save item relationships
        List<Order_Item_Junction__c> insitems = new List<Order_Item_Junction__c>();
        try{
            for(integer i=0;i<lstoitem.size();i++)
                {
                if(lstoitem[i].Quantity__c > 0)
                    {
                    Order_Item_Junction__c qtyitem = new Order_Item_Junction__c();
                    qtyitem.Order__c = oid;
                    qtyitem.Product_Bundle__c = lstbundle[i].Id;
                    qtyitem.Quantity__c = lstoitem[i].Quantity__c;
                    insitems.add(qtyitem);
                    }
                }
            if(insitems.size()>0)
                insert insitems;
        }catch(Exception ex){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Error:'+ ex.getMessage()));
            System.debug(ex.getMessage());
        }
        return null; 
    }
    
    public oitemController(ApexPages.StandardController controller)
    {
        //Order ID
        orderid = ApexPages.currentPage().getparameters().get('oid');
        //Record Type
        string orecordtype = ApexPages.currentPage().getparameters().get('rectype');
        
            if(orecordtype == 'New Order')
            {            
                //Fetch all Product Bundles where Order_Availability__c = New Order
                lstbundle = [Select Order_Availability__c, Name, Id From Product_Bundle__c where Order_Availability__c =:'New Order' and Completed__c =: TRUE order by Name];
            }
            else if(orecordtype == 'Return Order')
            {
                //Fetch all Product Bundles where Order_Availability__c = Return Oder
                lstbundle = [Select Order_Availability__c, Name, Id From Product_Bundle__c where Order_Availability__c =:'Return Order' and Completed__c =: TRUE order by Name];
            }
        
        lstoitem = new List<Order_Item_Junction__c>();
        oid = orderid;
        
        try{
        for(integer i=0;i<lstbundle.size();i++)
        {
            Order_Item_Junction__c oitem = new Order_Item_Junction__c();
            oitem.Product_Bundle__c = lstbundle[i].Id;
            oitem.Order__c = oid;
            oitem.Quantity__c = 0;
            lstoitem.add(oitem);
            
        }
        }catch(Exception ex){
            // Adding exeption message onto the page
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Error:'+ ex.getMessage()));
            System.debug(ex.getMessage());
        }
    }   
}

 

 

Page

<apex:page id="orderpage1" standardController="Order_Item_Junction__c" extensions="oitemController" sidebar="false" showheader="false" >
<script language="JavaScript" type="text/javascript">
function CloseAndRefresh()
{
    window.opener.location.href="/{!$CurrentPage.parameters.oid}";
    window.top.close();
      
}
</script>
    <apex:form id="form1">
        <apex:pageBlock title="Add Order Items" id="order">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Save" action="{!saveitems}" oncomplete="CloseAndRefresh()" />
                <apex:commandButton value="Cancel" onclick="CloseAndRefresh()" />
            </apex:pageBlockButtons>
                <apex:pageBlockSection id="pbsbundle" title="Available Product Bundles" rendered="true" columns="1">
                    <apex:pageBlockTable id="pbtbundles" value="{!lstoitem}" var="l" width="100%">
                        <apex:column headerValue="Order" value="{!l.Order__c}" width="40%"/>
                        <apex:column headervalue="Product Bundle Name" value="{!l.Product_Bundle__c}" width="40%"/>
                        <apex:column headerValue="Quantity" id="iqty" width="20%">
                            <apex:inputField value="{!l.Quantity__c}"/>
                        </apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!saveitems}" oncomplete="CloseAndRefresh()" />
                <apex:commandButton value="Cancel" onclick="CloseAndRefresh()" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

Test Class

@isTest
private class oitemControllerTest
{
    static testmethod void testorderNew1()
    {
        delete [Select Order_Availability__c, Name, Id From Product_Bundle__c where Order_Availability__c =:'New Order' and Completed__c =: TRUE order by Name];

        RecordType recnew = [select ID, Name from RecordType where Name = 'New Order' and SObjectType = 'Order__c'];
        RecordType recreturn = [select ID, Name from RecordType where Name = 'Return Order' and SObjectType = 'Order__c'];
        
        Order__c order1 = new Order__c(recordtypeid=recnew.Id);
        insert order1;
        
        Order__c order2 = new Order__c(recordtypeid=recreturn.Id);
        insert order2;
        
        RecordType recopen = [select ID, Name from RecordType where Name = 'Open' and SObjectType = 'Product_Bundle__c'];
        RecordType recreturnbun = [select ID, Name from RecordType where Name = 'Open' and SObjectType = 'Product_Bundle__c'];
        
        Product_Bundle__c bundle1 = new Product_Bundle__c(recordtypeid = recopen.id, Name = 'TestBundle1', Description__c = 'Testing1', Completed__c = TRUE, Order_Availability__c = 'New Order');
        Product_Bundle__c bundle2 = new Product_Bundle__c(recordtypeid = recreturnbun.id, Name = 'TestBundle2', Description__c = 'Testing2', Completed__c = TRUE, Order_Availability__c = 'Return Order');
        Product_Bundle__c bundle3 = new Product_Bundle__c(recordtypeid = recopen.id, Name = 'TestBundle3', Description__c = 'Testing3', Completed__c = FALSE, Order_Availability__c = 'New Order');
        Product_Bundle__c bundle4 = new Product_Bundle__c(recordtypeid = recreturnbun.id, Name = 'TestBundle1', Description__c = 'Testing4', Completed__c = FALSE, Order_Availability__c = 'Return Order');
        Product_Bundle__c [] bundle_array = new Product_Bundle__c []{bundle1,bundle2,bundle3,bundle4};
        insert bundle_array;
        
        Order_Item_Junction__c oi1 = new Order_Item_Junction__c(Order__c = order1.Id,Product_Bundle__c = bundle1.id, Quantity__c = 1);
        Order_Item_Junction__c oi2 = new Order_Item_Junction__c(Order__c = order1.Id,Product_Bundle__c = bundle2.id, Quantity__c = 2);
        Order_Item_Junction__c oi3 = new Order_Item_Junction__c(Order__c = order2.Id,Product_Bundle__c = bundle3.id, Quantity__c = 1);
        Order_Item_Junction__c oi4 = new Order_Item_Junction__c(Order__c = order2.Id,Product_Bundle__c = bundle4.id, Quantity__c = 2);        
        Order_Item_Junction__c [] oi_array = new Order_Item_Junction__c []{oi1,oi2};
        insert oi_array;
        
        PageReference pref1 = Page.orderpage;
        pref1.getParameters().put('oid',order1.Id);
        pref1.getParameters().put('orecordtype',recnew.Name);
        Test.setCurrentPage(pref1);
        
        ApexPages.StandardController stdcon1 = new ApexPages.StandardController(oi_array[0]);
        oitemController oicon1 = new oitemController(stdcon1);
        oicon1.setproceed();
        oicon1.saveitems();

        PageReference pref2 = Page.orderpage;
        pref2.getParameters().put('oid',order2.Id);
        pref2.getParameters().put('orecordtype',recreturn.Name);
        pref2.getParameters().put('orecordtype',recreturn.Name);
        Test.setCurrentPage(pref2);
        
        ApexPages.StandardController stdcon2 = new ApexPages.StandardController(oi_array[5]);
        oitemController oicon2 = new oitemController(stdcon2);
        oicon1.setproceed();
        oicon1.saveitems();
            
    }
}

 

 

  • March 01, 2012
  • Like
  • 0

I am trying to use the $ObjectType Global Variable to reference the value of my Save button so when a Spanish-speaking users sees the Visualforce page, it shows in Spanish...however, I cannot find documentation on how to reference the Button value in my VF page.  Anyone now where this is documented?

  • October 19, 2011
  • Like
  • 1

I am trying to use the $ObjectType Global Variable to reference the value of my Save button so when a Spanish-speaking users sees the Visualforce page, it shows in Spanish...however, I cannot find documentation on how to reference the Button value in my VF page.  Anyone now where this is documented?

  • October 19, 2011
  • Like
  • 1

I have a very simple page that was working in my Customer Portal previous to the current release, but no longer does.  The page works fine in the general User environment, but when used in my Customer Portal, it no longer works.  Below is the page.  Also, my Profiles and Customer Portal have access to the page.

 

 Page

<apex:page showHeader="false" standardController="Product_Sales__c" recordSetVar="productsales" tabStyle="Product_Sales__c">
    <apex:form >
        <apex:pageBlock title="Update Product Sales">
        <apex:pageBlockButtons location="top">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
        </apex:pageBlockButtons>
        <apex:pageBlockTable var="ps" value="{!selected}">
            <apex:column value="{!ps.Product_Category__c}"/>
            <apex:column value="{!ps.Product__c}"/>
            <apex:column value="{!ps.Product_Purchases_from_Sales_Rep__c}"/>
            <apex:column headerValue="{!$ObjectType.Product_Sales__c.Fields.Total_Customer_Wallet__c.Label}">
                <apex:inputField value="{!ps.Total_Customer_Wallet__c}"/>
            </apex:column>
            <apex:column headerValue="{!$ObjectType.Product_Sales__c.Fields.Estimated_Percentage_of_Wallet__c.Label}">
                <apex:inputField value="{!ps.Estimated_Percentage_of_Wallet__c}"/>
            </apex:column>
            <apex:column value="{!ps.Purchase_Potential_Growth__c}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

  • March 03, 2012
  • Like
  • 0

I tried to deploy a change set to production today and I hit the following error on the following piece of APEX which came from a SFDC Labs app.

Milestone1_Task_Chatter_Tst 

Milestone1_Task_Chatter_Tst.testChatterTaskReassignment 
System.DmlException: Update failed. First exception on row 0 with id a1b40000000JGYIAA4; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, This user cannot follow any other users or records: []: []
Class.Milestone1_Task_Chatter_Tst.testChatterTaskReassignment: line 95, column 9 External entry point

I do not understand this error and believe it has something to do with Chatter. Additionally, the debug log seemed to imply that a Portal User was being used for the execution of the test. I think the APEX is using the portal user, who of course does not have access to Chatter, and that's causing the failure.

This error is now preventing us from deploying code and changes sets to production.  Premiere support suggested uninstalling the app which of course means I lose all the data.  I was hoping a patch could be deployed to the app so I can fix the issue directly in prod.  Otherwise we'll have to uninstall and frankly probably won't bother putting it back.

 

Please advise.

  • January 05, 2012
  • Like
  • 0

I am trying to use the $ObjectType Global Variable to reference the value of my Save button so when a Spanish-speaking users sees the Visualforce page, it shows in Spanish...however, I cannot find documentation on how to reference the Button value in my VF page.  Anyone now where this is documented?

  • October 19, 2011
  • Like
  • 1