• Gopal Rathore
  • NEWBIE
  • 60 Points
  • Member since 2014


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 12
    Replies
Ok so I am trying to create a Select List in Visualforce of a list that was just deDuped with this code below:

public with sharing class CustomerHealth{

Set<String> cmSet = new Set<String>();

public CustomerHealth() {
    for(Customer_Health__c ch : [SELECT Customer_Success_Manager__c FROM Customer_Health__c                                                     WHERE Customer_Success_Manager__c <> ' ']){
             cmSet.add(ch.Customer_Success_Manager__c);
       }//END for
   }//END public 

public List<SelectOption> getCSMItems() {
        List<SelectOption> csmoptions= new List<SelectOption>();
        Decimal i;
        for (i=0; i < cmSet.size(); i++) {
            options.add(new SelectOption(cmSet[i], cmSet[i]));
        }
        return csmoptions;
    }


}//END public with sharing

When I do this the public List<SelectOption> won't let me save i get this Error: "Expression must be a list type: SET<String>" The line is: "options.add" line
 
This is what im trying to output it in in visualforce:
<apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!CSMFilter}" onchange="RefreshTable1()">
   <apex:selectOption value="{!cmSet}"></apex:selectOption>
</apex:selectList>
Now i have and actiofunction tied to it but its not relevant, This is before i tried adding the for loop. which i did a get of the deduped list to call that list and output it but i get this error when i do that: "Invalid selectOptions found. Use SelectOption type in Apex."

Help please :)
 

Hi all,

Wondering if you can help please...  I need to update a custom field "Contract_end_date__c" on my Account record when a Contract is Activated.

Although it seems this -should- be able to be done either by adding a formula field, roll-up summary field or a workflow - it doesn't seem that the Account/Contract Master/Detail relationship works in the same way that many of the others do and therefore there doesn't seem to be a way to do this without code.

I'm not a developer, and would really appreciate any help I can get.

Thanks,
Keri-An
iam unable add background image in vf pages by below code
css code: 


<style type="text/css">
body { background-image: url("{!URLFOR($Resource.myStyles, 'images/logo1.gif')}")
}
 
and i zipped image and css file added into  static source

apex code:

<apex:page showHeader="false" sidebar="false">
<apex:stylesheet value="{!URLFOR($Resource.example, 'example.css')}"/>
</apex:page>


please solve my problem
I have developed a VF Component and want to do the following so was wondering if its possible and any code will be great help

So if The logged in persons Role is  NOT a  Programmer i want to display the following BLOCK

<apex:component  controller="MyController">   
    <apex:pageBlock title="Products">
        <apex:pageBlockTable >
        </apex:pageBlockTable>
    </apex:pageBlock>

and If the role is programmer i want to display a message

<div> You are not the user </div>

1) How to check the role of current logged in used in APEX
2) How to use IF Else Condition in APEX
BAIDU MAPS(china) intigration with salesforce.

Hi,

Can any one provide me the steps and any javascript to run/ show the maps in VF page by using "BAIDU MAPS", because google is blocked in chaina.

Thanks in advance

Rakesh
+91-8826430808
public with sharing class CustomerHealth {

Public String CSMFilter {get ; set;}
public Set<String> cmSet {get; set;}

public CustomerHealth() {
       cmSet = new Set<String>();
    for(Customer_Health__c ch : [SELECT Customer_Success_Manager__c FROM Customer_Health__c   WHERE Customer_Success_Manager__c <> ' ']){
             cmSet.add(ch.Customer_Success_Manager__c);
       }//END for
   }//END public

public List<SelectOption> getCSMItems() {
        List<SelectOption> csmoptions= new List<SelectOption>();
        for (String s : cmSet) {
            csmoptions.add(new SelectOption(s, s));
        }
        return csmoptions;
    }
}
I created this an now want to create two more selct list the same as this but i get an error "Argument 1 cannot be null"

What My code looks like with multiple select list:
Controller:
public with sharing class CustomerHealth {

public Set<String> cmSet {get; set;}
public Set<String> amset {get; set;}
public Set<String> seset {get; set;}

public CustomerHealth() {
       cmSet = new Set<String>();
    for(Customer_Health__c ch : [SELECT Customer_Success_Manager__c FROM Customer_Health__c   WHERE Customer_Success_Manager__c <> ' ']){
             cmSet.add(ch.Customer_Success_Manager__c);
       }//END for
       amset = new Set<String>();
    for(Customer_Health__c cha : [SELECT Account_Manager__c FROM Customer_Health__c]){
             amset.add(cha.Account_Manager__c);
            }

    seset = new Set<String>();
    for(Customer_Health__c chs : [SELECT Support_Engineer__c FROM Customer_Health__c]){
             seset.add(chs.Support_Engineer__c);
            }
   }//END public

public List<SelectOption> getCSMItems() {
        List<SelectOption> csmoptions= new List<SelectOption>();
        for (String s : cmSet) {
            csmoptions.add(new SelectOption(s, s));
        }
        return csmoptions;
    }
public List<SelectOption> getSEItems() {
        List<SelectOption> seoptions = new List<SelectOption>();
        seoptions.add(new SelectOption('No Filter', 'Support Engineer'));
        seoptions.add(new SelectOption(' ', 'No SE'));
        for (String a : seset) {
            seoptions.add(new SelectOption(a, a));
        }
        system.debug('***' + seoptions);
        return seoptions;
    }

    public List<SelectOption> getAMItems() {
        List<SelectOption> amoptions = new List<SelectOption>();
        amoptions.add(new SelectOption('No Filter', 'Account Manager'));
        for (String d : amset) {
            amoptions.add(new SelectOption(d, d));
        }
        system.debug('***' + amoptions);
        return amoptions;
    }
}

Visual Force Page:
<apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!CSMFilter}" onchange="RefreshTable1()">
     <apex:selectOptions value="{!CSMItems}"></apex:selectOptions>
</apex:selectList> 
<span class="divider"></span>
<apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!SEFilter}" onchange="RefreshTable1()">
     <apex:selectOptions value="{!SEItems}"></apex:selectOptions>
</apex:selectList>
<span class="divider"></span>
<apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!AMFilter}" onchange="RefreshTable1()">
    <apex:selectOptions value="{!AMItems}"></apex:selectOptions>
</apex:selectList>


Ok so I am trying to create a Select List in Visualforce of a list that was just deDuped with this code below:

public with sharing class CustomerHealth{

Set<String> cmSet = new Set<String>();

public CustomerHealth() {
    for(Customer_Health__c ch : [SELECT Customer_Success_Manager__c FROM Customer_Health__c                                                     WHERE Customer_Success_Manager__c <> ' ']){
             cmSet.add(ch.Customer_Success_Manager__c);
       }//END for
   }//END public 

public List<SelectOption> getCSMItems() {
        List<SelectOption> csmoptions= new List<SelectOption>();
        Decimal i;
        for (i=0; i < cmSet.size(); i++) {
            options.add(new SelectOption(cmSet[i], cmSet[i]));
        }
        return csmoptions;
    }


}//END public with sharing

When I do this the public List<SelectOption> won't let me save i get this Error: "Expression must be a list type: SET<String>" The line is: "options.add" line
 
This is what im trying to output it in in visualforce:
<apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!CSMFilter}" onchange="RefreshTable1()">
   <apex:selectOption value="{!cmSet}"></apex:selectOption>
</apex:selectList>
Now i have and actiofunction tied to it but its not relevant, This is before i tried adding the for loop. which i did a get of the deduped list to call that list and output it but i get this error when i do that: "Invalid selectOptions found. Use SelectOption type in Apex."

Help please :)
 

Here is my Apex trigger:

trigger AccountAssignment on Contact (after insert, after update) {
    
        List<Contact> conToInsert = [select id, accountid from contact  where id in: trigger.newmap.keyset()];


        Account defaultAccount = [SELECT ID FROM account Where ID  = '001i0000010asN9' limit 1]; 
       
        //record id of Dummy Account is 001i0000010asN9
     
          for (Contact c : conToInsert) {            
                      
                if( c.accountid == NULL)
              {        
             
                c.accountid = defaultAccount.id;    
                 
               conToInsert.add(c);           
            
               }           
        }    
        }
Hi all,

Wondering if you can help please...  I need to update a custom field "Contract_end_date__c" on my Account record when a Contract is Activated.

Although it seems this -should- be able to be done either by adding a formula field, roll-up summary field or a workflow - it doesn't seem that the Account/Contract Master/Detail relationship works in the same way that many of the others do and therefore there doesn't seem to be a way to do this without code.

I'm not a developer, and would really appreciate any help I can get.

Thanks,
Keri-An
vfpage-

<apex:page standardController="Account" extensions="productconfig1">
  <apex:form >
  
   <apex:pageblock >
           <apex:panelGrid columns="5">
            Select Node &nbsp;<apex:selectList size="1" value="{!SelectedNode}">
                   <apex:selectOptions value="{!SelectedNodes}"/>
                  <apex:actionSupport event="onchange" reRender="a"/>
              </apex:selectList> 
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select Product &nbsp;<apex:selectList size="1" value="{!product}" id="a">
                   <apex:selectOptions value="{!products}"/>
                   <apex:actionSupport event="onclick" reRender="Details"/>
                 </apex:selectList>
         </apex:panelGrid>
         <apex:outputPanel id="Details">
             <apex:outputText value="The Product you Selected is {!product} " rendered="{!product != null}" />
         </apex:outputPanel>
      </apex:pageblock>
    
    </apex:form>

</apex:page>


Controller--

public with sharing class productconfig1
{
      Public String SelectedNode{get;set;}
     Public String Product{get;set;}
      Public String SelectedProduct{get;set;}
      
         public productconfig1(ApexPages.StandardController controller){
       
        }

  
     public List<SelectOption> getSelectedNodes()
   {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','--- None ---'));     
        options.add(new SelectOption('N1','N1'));
        options.add(new SelectOption('N2','N2'));
        options.add(new SelectOption('N3','N3'));     
        return options;
    }
  
    public List<SelectOption> getProducts()
    {
      List<SelectOption> options = new List<SelectOption>();
      if(SelectedNode == 'N1')
      {    
          options.add(new SelectOption('CPU','CPU'));
            options.add(new SelectOption('MOUSE','MOUSE'));
        }
        else if(SelectedNode == 'N2')
      {    
            options.add(new SelectOption('N/W','N/W'));
         
        }
       else if(SelectedNode == 'N3')
       {    
           options.add(new SelectOption('MONITOR','MONITOR'));
        
       }
       else
       {
             options.add(new SelectOption('None','--- None ---'));
        }   
        return options;
     }    

    }

not that you would ever need this, however it appears that the AJAX sforceClient does not like 15 charID's in Retrieve, so I ported this late last night from the java version posted elsewhere.

only tested for a short time, but it appears to work.

function normaliseSforceID( id) { // fluff up a 15 char id to return an 18 char id
 if (id == null) return id;
 id = id.replace(/\"/g, ''); // scrub quotes from this id
 if (id.length != 15) {
  //print('well, id is not 15, bye' + id + ' ' + id.length);
  return null;
 }
 var suffix = "";
 for (var i = 0; i < 3; i++) {
  var flags = 0;
  for (var j = 0; j < 5; j++) {
   var c = id.charAt(i * 5 + j);
   if (c >= 'A' && c <= 'Z') {
    flags += 1 << j;
   }
  }
  if (flags <= 25) {
   suffix += "ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(flags);
  } else {
   suffix += "012345".charAt(flags-26);
  }
 }
 return id + suffix;
}