• Sylvain@RibbonFish
  • NEWBIE
  • 125 Points
  • Member since 2013

  • Chatter
    Feed
  • 5
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 20
    Replies
Hi everyone,
I got an issue with my controller and my visualforce page:
When I click on the first button save it display my second section and hide the first one.
When I try to click on the Show All link the time it is doing nothing and I got this exception by javascript:
Uncaught TypeError: Cannot read property 'document' of null
And then I click again and the commandlink is working.
So if you have any idea.
See an example of the code below :)
Thanks
RB

<apex:page standardController="Object__c"  extensions="ObjectPage" >
<style type="text/css">

.checkBoxColumn
{
  max-width: 20px;
}

.headerStyle
{
  background-color:#FFFECD;
  font-weight:normal;
}
</style>
<apex:sectionHeader title="Object Edit" subtitle="Object"/>
       <apex:form >
       <apex:outputPanel id="thePanel">
                  <apex:pageMessages id="msgs" escape="false" rendered="{!hasError}"/>
         
        </apex:outputPanel>
       <apex:outputPanel id="section1">
       <apex:pageBlock title="Object Edit" mode="Edit" rendered="{!IF(isSave = false,true,false)}" >
    
     
        <apex:pageBlockButtons location="top">
   
                
            <apex:commandLink action="{!verificationBeforeSaving}" immediate="true" value="Save" styleClass="btn" style="color:black;text-decoration:none" reRender="section2,section1"/>
                
        </apex:pageBlockButtons>
      
     
        <apex:pageBlockSection title="Object Information" columns="1" >
         
     
            <apex:pageblocksectionitem >

                    <apex:outputlabel id="hiddenElementId" >Object</apex:outputlabel>
                    <apex:outputpanel layout="block" styleClass="requiredInput">
                        <apex:outputpanel layout="block" styleClass="requiredBlock"></apex:outputpanel>
                       <apex:actionRegion >
                       <apex:selectList  size="1" value="{!selectedObject}"  >
              <apex:selectOptions value="{!ObjectOption}" />
             
              <apex:actionSupport event="onchange" action="{!resetValues}"/>
           
            </apex:selectList>
</apex:actionRegion>
                    </apex:outputpanel>
                </apex:pageblocksectionitem>

              
         
        </apex:pageBlockSection>
       </apex:pageBlock>

       </apex:outputPanel>

       <apex:outputPanel id="section2" >
       <apex:pageBlock title="Apply Object to following Object?" rendered="{!IF(isSave = true,true,false)}"  >
    
        <apex:pageBlockButtons location="top">
                  <apex:commandLink action="{!verificationBeforeSaving}" value="Apply to Selected Object" styleClass="btn" style="color:black;text-decoration:none" >
                <apex:param assignTo="{!applyObject}" value="true" name="applyObject"/>
                  </apex:commandLink>
                
          </apex:pageBlockButtons>
      
        <apex:outputPanel id="tableContainerObject">

 
<div style="max-height:160px;overflow:auto;">

<apex:commandLink id="test" immediate="true" style="font-size:small;text-align:right;" value="  Show all results" action="{!showAll}"  reRender="test,section2,tableObject"/>

  <apex:pageBlockTable value="{!listToDisplay}" var="a" id="tableObject" headerClass="headerStyle">
<apex:facet name="header"><apex:outputText rendered="{!isHeaderVisible}">Results are narrowed down by criteria set by the administrator. </apex:outputText> </apex:facet>
  <apex:column styleClass="checkBoxColumn">
  <!-- This is our selected   Boolean property in our wrapper class -->
  <apex:inputCheckbox value="{!a.isSelected}"></apex:inputCheckbox>
   
</apex:column>


              </apex:pageBlockTable>
            </div>
          </apex:outputPanel>
     
       </apex:pageBlock>
       </apex:outputPanel>
      </apex:form>
     </apex:page>

--------------------------------------------------------------------------------------------------------------------------------------

public with sharing class ObjectPage {

  ApexPages.StandardController GstdController;
    public Boolean hasError {get; set;}
    public Boolean saveAndNew {get; set;}
    Object__c object {get; set;}
    public Id objectId {get; set;}
  
   
    public SelectOption[] objectTypeOption {get; set;}
    public String selectedObjectType {get; set;}

    public Boolean isSave {get; set;}

    public List<Object__c> listToDisplay {get; set;}

    public Boolean applyObject {get; set;}

    public Boolean isHeaderVisible {get; set;}

    // The extension constructor initializes the private member
    // variable mysObject by using the getRecord method from the standard
    // controller.
    public ObjectPage(ApexPages.StandardController stdController) {
      
        GstdController = stdController;
        object = (Object__c)GstdController.getRecord();

        //Get the contact id if we get from the contact page
        if(ApexPages.currentPage().getParameters().get('objectId')!=null)
        {
            objectId =  ApexPages.currentPage().getParameters().get('objectId');

        }

        isSave = false;
        isHeaderVisible = true;
        hasError = true;
        saveAndNew = false;
        applyProduct = false;
        object.Status__c = 'Test';

    }

  

    //This method is call to reset automatically the values when we click a blurb type available in the page
    public void resetValues()
    {
       //Retrive the selected blurb type value
       obj = (Object__c)GstdController.getRecord();

       ObjectType__c currentObjectTypeSelected = informationsByAvailableObjectType.get(selectedObjectType);

    }

    public PageReference verificationBeforeSaving()
    {
        hasError = true;
        object = (Object__c)GstdController.getRecord();
      
        if(selectedObjectType != null )
        {
            object.ObjectType__c = selectedObjectType;
        }

        if(!isSave)
        {
            isSave = true;
            loadObjectUpdateSection();
        }
        else
        {
            return finishRedirectToObject();
        }


        return null;
    }

    //Get the corresponding product to extract the project
    public void loadObjectUpdateSection()
    {
      
        List<Object__c> myList = [Select ID From Object__c Where Status__c = 'Test' Limit 10];
        for(Object obj :myList)
        {
              cObject custObject = new cObject();
              custObject.Test__c = obj;
              listToDisplay.add(custObject);
        }
    }

    public PageReference showAll()
    {
        if(isHeaderVisible)
        {
            isHeaderVisible = false;
            List<Object__c> myList = [Select ID From Object__c  Limit 100];
        for(Object obj :myList)
        {
              cObject custObject = new cObject();
              custObject.Test__c = obj;
              listToDisplay.add(custObject);
        }

        return null;
        }
        else
            isHeaderVisible = true;

        return null;

    }

    public void selectAll()
    {
        for(Object obj : listToDisplay)
        {
            obj.isSelected = true;
        }
    }

    public void deselectAll()
    {
        for(Object obj : listToDisplay)
        {
            obj.isSelected = false;
        }
    }


    public PageReference finishRedirectToObject()
    {
        if(applyObject)
        {
          
            //do something
        }

         
        PageReference pr =  GstdController.save();
      
        if(pr == null)
        {
            hasError = true;
            return pr;
        }
        else{
          
            hasError = false;

          
          
                pr = new PageReference('/' + objectId);
                pr.setRedirect(true);
                return pr;
          
          
        }
    }
}

Hi,

I would like to know something:

I got a hierarchy in account. I have build a report for sales opportunity to extract data by a custom field in the Account link to the Sale Opportunity. When I add the report in the page layout of Account I'm not able to filter by the custom field which is used to get the data from the report. There is a way to filter the report by a custom field from the layout in the setup ? 

Thanks

RibbonFish

Hi,

This code was working previously since one month I can't run it:

Product2 pdt2 = new Product2(Name='Test',ProductCode = '222');
        Product2 pdt3 = new Product2(Name='Test',ProductCode = '222');

  
        insert pdt2;
        insert pdt3;

        Pricebook2 pBook = [Select Id, Name, IsActive From Pricebook2 where IsStandard = true LIMIT 1];
        PricebookEntry pBookEntry = new PricebookEntry(UnitPrice=35,Pricebook2Id=pBook.Id,Product2Id=pdt2.Id,IsActive=true,UseStandardPrice=false);
        insert pBookEntry;

 The error:

 

Products do not have a standard price.

 

Thanks

Hi,

I would like to add related to certain profile like Standard plateform user or plateform User.

When I create the field with the related list associated, I tick the checkox overwrtie user personnal cust...

The profile was also tick in the Visible property.

So why the related list doesn't show at all in the page ?

It's shows only for SA and some other profiles..

Thanks

 

Hi,

I would like to extract the SObject (not the properties by using ar.get(x)) from an aggregateResult object.

There is no way to do that ?

Like:

 

AggregateResult ar;

Product2 p = ar;

 

(give me this error: Invalid conversion from runtime type SOBJECT:AggregateResult to SOBJECT:Product2)

Thanks

Hi,

We got this situation:

Salesforce>VPN>webservice distant.

For now I can connect to a webservice, did salesforce can connect to a webservice behind a VPN ?

Or salesforce can connect to the VPN and consume the web service ?

THanks for help ! 

 

Hello.

I got a long list of questions about the Mobile development with salesforce.com.

I have developed an application (App) for a client. This application got 4 tabs use object from salesforce.com and custom object. This app is setting up with custom settings. 

If my client want to access by web with tab or phone, How about touch screen with the existing code? this is working normally? Did I have to activate something ?

There is a SDK Mobile platform. My client want to use a part of the application with an other development. Can I reuse my apex code to build a Aplpication with the mobile SDK plus the other specifications ?

Or I have to redo it from scratch?

Thanks a lot

 

Hi everyone,

I would like to know if there is a way to implement this situation on salesforce:

CustomObjectA=>productA,ProductB

CustomObjectB=>productB,ProductE

CustomObjectC=>productA,ProductE

 

For now I used lookup relationship but a product can be attached to only one customObject...

How I can attached the same product to different CustomObject?

Thanks

Sylvain

Hi everyone,

There is an approach to do something like that (picture):

http://i41.tinypic.com/w6tqab.jpg

 

So I got the list of Account link by AccountContactRole to the contact object.

I got the list of contact for each Account from the ContactID of the AccountContactRole.

The input search is already done.

I got a wrapper for each object with the selected property inside.

How todo the pageblocktable with a pageblocktable inside and expand it when we tick the account?

(I want to display only if the account is tick and if we tick another account the first will be still tick and collapse automatically). 

Or there is another way ?

Thanks for help.

 

 

 

 

 

Hi,

See the following example:

global class TestController {

	global cAccountCollection cAccountColl {get; set;}
	
	public BulkSampleController(){
		cAccountColl = new cAccountCollection('Account');
		
	}
	
	
	global PageReference ccSearch()
	{
	        cAccountColl.cSearch('Select Type, Name From Account');
		return null;
		
	}

	global PageReference WebSearch(String query)
		{
			
			
			cAccountColl.cSearch(query);
			
			return null;
			
		}

	
	 webService static cAccountCollection webSccSearch(String query)
	 {
	 	
	 	BulkSampleController test2 = new BulkSampleController();
	 	test2.WebSearch(query);
	 	
	 	
	 	return test2.cAccountColl;
	 }
	
	
	webService static BaseModelCollection webSccSearch2(String query)
	 {
	 	
	 	BulkSampleController test2 = new BulkSampleController();
	 	test2.WebSearch(query);
	 	
	 	return test2.cAccountColl;
	 }
	
	
}

 I access this by using a web reference in c# (visual studio).

When I receive the object by using the web service, visual studio recognize the object type as cAccountCollection but I can't access property of this object.

Someone know why this happen?

Thanks

Sylvain