• Iago Felicio
  • NEWBIE
  • 10 Points
  • Member since 2017


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 7
    Replies
My Map looks like this: 
myMap = Map<Id,Set<myObject__c>>
If I try to access the collection of myObject__c by using the following:
<apex:repeat value="{!myMap[exampleofID]}" var="myobject">
     <apex:repeat value="{!myobject}" var="myset">
I get null in myset.

Considerations:
If I access myMap in my controller by using the solution below I access the infos I need. But, I need to access it in my page.
myMap.get(Id).keyset()
Pleeease, someone help me! 
I'm currently trying the following solution to solve my problem:

In my first controller I'm instantiating a custom variable:
public class myFirstPageController {
   public Integer myCustomVar {get; set;}
}

public myFirstController(ApexPages.StandardController controller) {
   myCustomVar = 999;
}
[...]

Then, in my myFirstPage.page I have the following code:
 
<apex:page standardController="myCustomObjetc__c" extensions="myFirstController">

[...]

<apex:outputPanel>
    <c:COMP compAttribute="{!myCustomVar}"> </c:COMP>
</apex:outputPanel>

[...]
My COMP.component looks like this:
 
<apex:component controller="COMPController" access="global" allowDML="true">
   <apex:attribute type="Integer" name="compAttribute" required="false" access="global"/>

[...]
<!-- I did the following test that ran successfully-->

<apex:pageBlockSectionItem>
   <apex:outputText value="Printing the value I received from my FirstPage.page"/>{!compAttribute}   
</apex:pageBlockSectionItem>
So, Im trying to send the value of my variable compAttribute to a variable in my COMPController!
As part of my solution, I tried the following:
 
<apex:component controller="COMPController" access="global" allowDML="true">
   <apex:attribute type="Integer" name="compAttribute" required="false" access="global"/>

[...]
<apex:pageBlockSectionItem>
   <apex:outputText value="Printing the value I received from my FirstPage.page"/>{!compAttribute}   
</apex:pageBlockSectionItem>

[...]
<!-- Attempt bellow: -->
<apex:param value="{!compAttribute}" assignTo="{!finalVariable}"></apex:param>

And finally, my last controller, which is the COMPController, looks like:
 
public class COMPController {

public Integer finalVariable;
    
   public void setFinalVariable (Integer fv) {
      finalVariable = fv;
   }
   
   public Integer getTipoPessoa() {
      return finalVariable;
  } 
}

public COMPController (){
   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Value of my finalVariable:  ' + finalVariable));
}


Unfortunatelly, I'm getting null in my finalVariable!!

Does anyone know where are my mistake and how to solve it? There is another way to have the same funcionality using other resources?
 

Ps.: I must get the value of this finalVariable in my COMPController! :D

My Map looks like this: 
myMap = Map<Id,Set<myObject__c>>
If I try to access the collection of myObject__c by using the following:
<apex:repeat value="{!myMap[exampleofID]}" var="myobject">
     <apex:repeat value="{!myobject}" var="myset">
I get null in myset.

Considerations:
If I access myMap in my controller by using the solution below I access the infos I need. But, I need to access it in my page.
myMap.get(Id).keyset()
Pleeease, someone help me! 
I'm currently trying the following solution to solve my problem:

In my first controller I'm instantiating a custom variable:
public class myFirstPageController {
   public Integer myCustomVar {get; set;}
}

public myFirstController(ApexPages.StandardController controller) {
   myCustomVar = 999;
}
[...]

Then, in my myFirstPage.page I have the following code:
 
<apex:page standardController="myCustomObjetc__c" extensions="myFirstController">

[...]

<apex:outputPanel>
    <c:COMP compAttribute="{!myCustomVar}"> </c:COMP>
</apex:outputPanel>

[...]
My COMP.component looks like this:
 
<apex:component controller="COMPController" access="global" allowDML="true">
   <apex:attribute type="Integer" name="compAttribute" required="false" access="global"/>

[...]
<!-- I did the following test that ran successfully-->

<apex:pageBlockSectionItem>
   <apex:outputText value="Printing the value I received from my FirstPage.page"/>{!compAttribute}   
</apex:pageBlockSectionItem>
So, Im trying to send the value of my variable compAttribute to a variable in my COMPController!
As part of my solution, I tried the following:
 
<apex:component controller="COMPController" access="global" allowDML="true">
   <apex:attribute type="Integer" name="compAttribute" required="false" access="global"/>

[...]
<apex:pageBlockSectionItem>
   <apex:outputText value="Printing the value I received from my FirstPage.page"/>{!compAttribute}   
</apex:pageBlockSectionItem>

[...]
<!-- Attempt bellow: -->
<apex:param value="{!compAttribute}" assignTo="{!finalVariable}"></apex:param>

And finally, my last controller, which is the COMPController, looks like:
 
public class COMPController {

public Integer finalVariable;
    
   public void setFinalVariable (Integer fv) {
      finalVariable = fv;
   }
   
   public Integer getTipoPessoa() {
      return finalVariable;
  } 
}

public COMPController (){
   ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Value of my finalVariable:  ' + finalVariable));
}


Unfortunatelly, I'm getting null in my finalVariable!!

Does anyone know where are my mistake and how to solve it? There is another way to have the same funcionality using other resources?
 

Ps.: I must get the value of this finalVariable in my COMPController! :D

Hi,

I want populate a custom picklist on Opportunity page with all Campaign that exist.

I can get a list of all names of the campaign, but I don't know how populate the custom picklist with these values.

Here is the code with list of the campaign name.

public class PegarCampanhas{

public List<SelectOption> getCampanhas(){
    List<SelectOption> options = new List<SelectOption>();
    List<Campaign> campanhas = [SELECT Id, Name, IsActive FROM Campaign WHERE IsActive = true];

    for(Campaign c:campanhas){
        options.add(new SelectOption(c.Name, c.Name));
    }
    return options;   
}
}

Here is what I'm traying to insert:

trigger InserirCampanhas on Opportunity (before insert, before update) {

        List<SelectOption> options = new List<SelectOption>();
        PegarCampanhas pegar = new PegarCampanhas();
        options = pegar.getCampanhas();
        System.debug(options);
        
        for(Opportunity opty : Trigger.new){
            if(options!=null){
                opty.Campanha__c = options.get(i).getValue();
                System.debug(opty.Campanha__c);
            }
        }
}

When I test it occurs this error:
Line: 2, Column: 1
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, InserirCampanhas: data changed by trigger for field Campanha: valor incorreto para campo de lista de opções restrita: GC Product Webinar - Jan 7, 2002: []

I think this occurs because my trigger don't insert the value on the field, but is trying to select a value that don't exist on the picklist.

Can someone help me?

Regards
Rafael