• Chris987654321
  • NEWBIE
  • 125 Points
  • Member since 2007

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 48
    Questions
  • 69
    Replies

Just curious (being new to VisualForce dev), but can anyone explain to me the difference between:

apex:pageBlock
and

 

 

apex:repeat

 

Both seem to iterate over data in the same method?  Thanks in advance!

I vaugly remember reading in a recent release that it is now possible to share methods across unit tests so you don't have to duplicate code across unit tests. Does anyone know where I can find more information on the topic? I can't seem to find the information about it.

 

Thanks 

I am writing a VF page which will be used to reassign a user's opportunities to a set of other users in a Round Robin fashion. This part is working. 

 

However, I was told to make this reassignment asynchronous (@future) and disable the button on the VF page until the process is finished so the user cannot keep clicking the button on the VF page.  Is this possible to do? How can I track when the @future process is finished?

 

Thanks,

Chris

I am having trouble with doing relationship queries in C#. I'm using the Partner WSDL

 

 

 string query = "select Account.Id, Account.Name, Id from Contact LIMIT 10";
                        
 DataTable table = GetSforceData(query, 200);
 dataGridView1.DataSource = table;

 

DataTable GetSforceData(string strSQL, int iBatchSize)
        {
            DataTable dt = null;
            
            SforceService binding = new SforceService();
            
           
            //get account name, account password and security token here            
            LoginResult lr = binding.login(strAccountName,strAccountPassword + strSecurityToken);

            if (!lr.passwordExpired)
            {
                binding.Url = lr.serverUrl;
                binding.SessionHeaderValue = new partnerWSDL.SessionHeader();
                binding.SessionHeaderValue.sessionId = lr.sessionId;

                partnerWSDL.QueryResult qr = null;
                binding.QueryOptionsValue = new partnerWSDL.QueryOptions();
                binding.QueryOptionsValue.batchSize = iBatchSize;
                binding.QueryOptionsValue.batchSizeSpecified = true;
                try
                {
                    qr = binding.query(strSQL);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString(), "Error peforming query");
                    return null;
                }

                bool done = false;

                if (qr.size > 0)
                {
                    dt = new DataTable();
                    partnerWSDL.sObject sOtmp = (partnerWSDL.sObject)qr.records[0];
                    
                    for (int i = 0; i < sOtmp.Any.Length; i++)
                    {
                        dt.Columns.Add(sOtmp.Any[i].LocalName);
                    }
                    string[] prValues = new string[sOtmp.Any.Length];
                    while (!done)
                    {
                        for (int i = 0; i < qr.records.Length; i++)
                        {
                            sOtmp = (partnerWSDL.sObject)qr.records[i];
                            for (int j = 0; j < sOtmp.Any.Length; j++)
                            {
                                if (sOtmp.Any[j].ChildNodes.Count > 1)
                                {
                                    prValues.SetValue(sOtmp.Any[j].ChildNodes[2].InnerText, j);
                                }
                                else
                                {
                                    prValues.SetValue(sOtmp.Any[j].InnerText, j);
                                }
                            }

                            dt.Rows.Add(prValues);
                        }

                        if (qr.done)
                        {
                            done = true;
                        }
                        else
                        {
                            qr = binding.queryMore(qr.queryLocator);
                        }
                    }
                }
            }

            return dt;
             
        }

 

 

So the results will only show the Account.Id not the Account.Name.

 

But it if I remove the Account.Id from the query then it will show the Account.Name.

 

It seems like it only can handle one __r type of field per query? Is this a limitation of the API?

 

 

Thanks,

Chris

I noticed that in Apex when you perform an upsert, there's an overloaded version of the method which allows for a boolean which indicates how Salesforce will handle duplicates. If it's false then if there's an error with upserting one record it will not fail the whole batch. If it is true then it will.

 

I do not see this overloaded version of upserting available through the API in either the partner or enterprise WSDL. Is this not available through the API by design?

 

Thanks,

Chris

When you write an application that logs in through the API, is there something in the API that allows you to control what shows up in a user's login history? So instead of it saying Other API in the login history it could put in the name of your application that logged into Salesforce?

 

global BatchUpdateAdmissionsGoals(String q, String e, String f, String v){
		Query=q; Entity=e; Field=f;Value=v;
		opportunityList = new List <Opportunity> ();
global Database.QueryLocator start(Database.BatchableContext BC){		
		
		return Database.getQueryLocator(query);		
	} 
	
	global void execute(Database.BatchableContext BC, List<sObject> scope){
		//List <Admissions_Goal__c> goalsToUpdate = new List<Admissions_Goal__c>();
		Integer totalLeads, weeklyLeads;
		for(sObject s : scope){
				if(s.getsObjectType() == Opportunity.sObjectType) {
			 	
				 	Opportunity o = (Opportunity)s;
				 	opportunityList.add(o);		
				}
		}
		System.debug('*** Opp list size ' + opportunityList.size());
}


global void finish(Database.BatchableContext BC){
System.debug('*** Opp list size ' + opportunityList.size());
}

 

I am trying to write some batch Apex. When the following anonymous code block

 string query = 
            'SELECT Id, OwnerID, Academic_Start_Date__c, Date_Booked__c  ' +
            'FROM Opportunity WHERE ID=\'006S0000003imhy\''; 
             
         
        BatchUpdateAdmissionsGoals updateAdmissionsGoalsJob = new BatchUpdateAdmissionsGoals (query, '', '', '');
        ID admissionsGoalsBatchJobID = Database.executeBatch(updateAdmissionsGoalsJob); 

 

:

 

When I call the the debug statement that gets the opportunityList.size() the first time and I get 1 as expected. But when I call it in the Finish() method again, I get 0. It doesn't seem to keep the the items in opportunityList when it gets to the Finish() method

We need to make a very complex report which acts upon many objects. So it would end up needing to be several different reports.

 

Is it possible to reference a report in a Visual Force page? Would I would like to do is build the several reports and then bring them in on one Visual Force page so that a user can see all the reports in one place.

Is it possible to remove the Required Information part on a Visual Force page? When you add a <apex:pageblocksection> it automatically puts a line that says Required Information on the first pageBlockSection. I want to remove it because I read that you cannot easily put that red line on custom text fields like <apex:outputText>. So I didn't want to confuse the user by saying that the red line denotes a required field.

Does the Opportunity Stage History object have any link to the opportunity? When I look in the schema browser in Eclipse and do a query on the Opportunity Stage History I don't see any link to the Opportunity that the history record is associated with.I need to query that object in Apex but I don't see a way to know what record is assocated with what opportunity.

 

Please let me know if there is something I am missing

 

Thanks,

Chris

I am noticing a very strange problem. On my page I have a <apex:selectList> with a rerender actionsupport method that calls campusChanged() that happens on the onChange event.

 

For some reason when I change the value in the selectList, I get an Insufficient Priveldges message. This was working yesterday but now does not work since I have added some code. But now I have commented out much of the code and it still happens. It happens when I use with sharing or not. It even happens when I am logged in as a System Administrator. I commented so much out that the rerender just calls campusChanged() and all that does is send a debug message. So I am really confused.

 

I checked the debug logs and when I change the select list it does not even get to my System.debug() call.

 

 

public with sharing class DOAReportController {
    public DOAReportController() {
        
        selectedCampus = campuses[0].getValue();
        
        distinctOppOwnersSet = new Set<String>();
        
        distinctOppOwners = [SELECT OwnerID FROM Opportunity GROUP BY OwnerID];
       
		for (AggregateResult ar : distinctOppOwners) {
			System.debug('OwnerID: '+ar.get('OwnerID') );
			distinctOppOwnersSet.add(ar.get('OwnerID')+'');
			
		}
		
		opportunities = [select Id, OwnerID, CreatedDate, AccountID FROM Opportunity];
        
        getCampusContacts();
       
       

    }
    
    private Opportunity [] opportunities;
    private AggregateResult[] distinctOppOwners;
    private Campus_Contacts__c [] campusContacts;
    private Map <Id, Id> oppIdToOwner;
    private Map <String, Id> userIdToName;
    private Set<String> distinctOppOwnersSet;
    
    public String weeklyAppointments { get; set; }

    public String HitRate { get; set; }

    public String SuccessfulCalls { get; set; }

    public String calls { get; set; }

    public String contactPercent { get; set; }

    public String numberOfUnContactedLeads { get; set; }

    public List<SelectOption> campuses {
        get {
            
            Account [] campus = [Select Id, Name FROM Account];
            List<SelectOption> options = new List<SelectOption>();
            
            for (Account a:campus) {
                options.add(new SelectOption(a.Id,a.Name));
            } 
            System.debug ('----- Options size ' + options.size());
            return options;
        }
        
        set;        
    }
    
    public string selectedCampus {get; set;}
    
    public List <string> nameOfReps;
    
    public void campusChanged(){
    	//campusContacts = null;  
    	System.debug('--- Selected Campus = '+selectedCampus);	
        //getNameOfReps();
        //getnumberOfLeads();
    }
    
    
    
    private void getCampusContacts() {
    	//Get the names of employees that are of the title 'Program Manager / Admissions Representative' 
    	//and are associated with the selected campus
    	campusContacts = [select Employee__r.Id, Organization__c, TItle__c, Employee__r.Name 
	                        FROM Campus_Contacts__c
	                        WHERE TItle__c = 'Program Manager / Admissions Representative' 
	                        AND Employee__r.isActive = true                 
	                        ];
        
    }
    
    public List<string> getNameOfReps() {           
        List <string> repNames = new List <string>();   
        /*
        
        if (campusContacts==null)
        	getCampusContacts();
        
        //and the names to the reNames list to display on the report
        for (Campus_Contacts__c c:campusContacts)   {
            if (c.Organization__c == selectedCampus) {        		
        	
        		repNames.add(c.Employee__r.Name);
            }
        }   
        */                
        return repNames;
    }
    
    public List <Integer> numberOfLeads;
    
    public List <Integer> getnumberOfLeads() {        
    	Date dateRangeStart = Date.newInstance(2010, 1, 1);
    	Date dateRangeEnd = Date.newInstance(2010, 4, 31);
    		
        //if (campusContacts==null)
        //	getCampusContacts();
        
        List <Integer> numLeads = new List <Integer>();
        /*
        Integer count = 0;	        
        
        for (Campus_Contacts__c c : campusContacts) {
        	 if (c.Organization__c == selectedCampus) {   
            	count = 0;
            	if (distinctOppOwnersSet.contains(c.Employee__r.Id+'')){
            		//figure out how many opps that rep owns
            		for (Opportunity o : opportunities) {
	        			if (o.ownerId == c.Employee__r.Id) {
	        				
	        				Date oppCreateDate = Date.newInstance(o.CreatedDate.year(), o.CreatedDate.month(), o.CreatedDate.day());
	        				
	        				if (oppCreateDate >= dateRangeStart &&
	        					oppCreateDate <= dateRangeEnd) {
	        						count++;
	        					}
	        			}
	        		
	       			}
	       			numLeads.add(count);	
            	}
            	
            	else {
            		//if the distinct owner list does not have the rep's id then place a 0 and move on
            		numLeads.add(0);
            		continue;
            	}
        	}
        }
        */
        numLeads.add(0);numLeads.add(0);numLeads.add(0);
        return numLeads;
	}
        
    
}

 

 

 

 

 

<apex:page controller="DOAReportController" >
    <apex:form >            
        
        <apex:selectList value="{!selectedCampus}" multiselect="false" size="1">
            <apex:selectOptions value="{!campuses}"/>
            <apex:actionSupport event="onchange" action="{!campusChanged}" 
                                            immediate="false" rerender="LastWeek"/>
        </apex:selectList>
        <br/><br/>
        <apex:outputPanel id="LastWeek">
            <table border="1" width="100%">
                <!-- Names of Reps -->
                
                
                
                
            </table>
        </apex:outputPanel>
    </apex:form>
</apex:page>

 

 

 

If I use 

<apex:pageblocktable>

 

the behavior is that it will let me put a value which can be associated with an array in my controller so it will be a variable number of rows depending upon how many elements are in that array.

 

Is there a way, instead, to have value indicate how many columns I have. I essentially want to flip what the rows and columns are. The reason is because in the table I want a variable number of columns and a set number of rows because I know that there will be more rows than columns. Even though the number of columns would be variable, it will be no more than maybe 6 or 7. But my number of set rows will be about 20. So it would be hard to read if there are 20 columns and only 6 or so rows. 

 

I saw a dir attribute on pageblocktable, but that said it indicated left to right. Any help would be appreciated. 

If I have a VF page that is being called from a <apex:commandlink> is there a way to control the size of the page that is being called. I wanted the VF page to open in a new window which I believe I can do with the target="_blank" attribute of commandlink.

 

Once it is opened in a new window how can I control the width and height of that new window?  

We are using Sites with Customer Portal so that the customer has to log in. 

 

My question is that when you use the logout 

{domain}/secur/logout.jsp 

 

 it logs the customer out however, they can hit the back button twice and get back to the customer portal session. How can I correct this?

I'm coding dependant picklists using re-rendering. In the following code,

 

 

<tr>
<td align="right">
Campus:
</td>
<td align="left">
<apex:outputPanel id="campusPanel">
<apex:selectList id="campusPicklist" value="{!campusId}" size="1">
<apex:selectOptions value="{!campuses}"/>
<apex:actionSupport event="onchange" action="{!campusChanged}"
status="programStatus" immediate="false" rerender="programPanel"/>
</apex:selectList>
<font color="red">*</font>
</apex:outputPanel>
</td>
</tr>


<tr>
<td align="right">
Program:
</td>
<td align="left">
<apex:outputPanel id="programPanel">
<apex:actionStatus id="programStatus" startText="(Loading programs...)">
<apex:facet name="stop">
&nbsp;
<apex:selectList id="programPicklist" value="{!programId}" size="1">
<apex:selectOptions value="{!programs}"/>
<apex:actionSupport event="onchange" action="{!programChanged}"
status="dateStatus" immediate="false"/>
</apex:selectList>
</apex:facet>
</apex:actionStatus>
<font color="red">*</font>
</apex:outputPanel>
</td>
</tr>

 

 

 

 When you select a Campus in the first dropdown it is supposed to refresh the list of Programs offered at that campus in the second dropdown. It actually does refresh once but then if I try changing the campus once more either to a different selection or back to the original selection it does not seem to refresh the list again.

 

Does the onChange event only occur when the dropdown is changed the 1st time? Should I use a different event?

 

Message Edited by Chris987654321 on 02-16-2010 11:09 AM

I am getting the following error when making a call to a webservice that we host through apex code:

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

 

I have done some research and found that it has to do with certificates. Our certificate is signed by Verisign. I saw that your certificate has to be added to the keystore. Does it have to be added to the keystore if we are not using 2 way trust? Also, does my Apex code have to send the certificate to the webservice somehow or is that not necessary?

 

 

public class CallESB{
@Future(callout=true)
public static void getRasID(String SSN_nodashes, string id) {
rasmussenidentificationservice.ServiceHTTPBehaviour newSSn = new rasmussenidentificationservice.ServiceHTTPBehaviour();
string output = newSSn.GetRasIDBySSN(SSN_nodashes);
// String output back to the contact record
System.debug('RasID: '+output);
if (output!=null) {
Contact c=[select rasid__c,id FROM Contact where id=:id];
c.RasId__c=output;

try{
update c;
}

catch(Exception e){
System.debug('Error ' + e.getMessage() );
}
}

}
}

 

 

 

I am getting the following error when trying to call a webservice from a trigger:

Callout from triggers are currently not supported: Class.esbLearntodayInfo.ServiceHTTPBehaviour.GetRasIDBySSN: line 78, column 13

 

I read on another post that there must be an @future, but I am uncertain where I should put it. I tried to put it right before  public String GetRasIDBySSN(String ssn) { but it said that @future must be in the upper most class. 

 

This is the class for the webservice:

 

//Generated by wsdl2apex

public class esbLearntodayInfo {

public class GetRasIDByFirstAndLastNameAndEmailAddress_element {
public String firstname;
public String lastname;
public String emailAddress;
private String[] firstname_type_info = new String[]{'firstname','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] lastname_type_info = new String[]{'lastname','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] emailAddress_type_info = new String[]{'emailAddress','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'https://esb.learntoday.info/','true','false'};
private String[] field_order_type_info = new String[]{'firstname','lastname','emailAddress'};
}
public class GetRasIDByFirstAndLastNameAndEmailAddressResponse_element {
public String GetRasIDByFirstAndLastNameAndEmailAddressResult;
private String[] GetRasIDByFirstAndLastNameAndEmailAddressResult_type_info = new String[]{'GetRasIDByFirstAndLastNameAndEmailAddressResult','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'https://esb.learntoday.info/','true','false'};
private String[] field_order_type_info = new String[]{'GetRasIDByFirstAndLastNameAndEmailAddressResult'};
}
public class GetRasIDBySSN_element {
public String ssn;
private String[] ssn_type_info = new String[]{'ssn','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'https://esb.learntoday.info/','true','false'};
private String[] field_order_type_info = new String[]{'ssn'};
}
public class GetRasIDBySSNAndDOBResponse_element {
public String GetRasIDBySSNAndDOBResult;
private String[] GetRasIDBySSNAndDOBResult_type_info = new String[]{'GetRasIDBySSNAndDOBResult','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'https://esb.learntoday.info/','true','false'};
private String[] field_order_type_info = new String[]{'GetRasIDBySSNAndDOBResult'};
}
public class GetRasIDBySSNAndDOB_element {
public String ssn;
public String dob;
private String[] ssn_type_info = new String[]{'ssn','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] dob_type_info = new String[]{'dob','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'https://esb.learntoday.info/','true','false'};
private String[] field_order_type_info = new String[]{'ssn','dob'};
}
public class GetRasIDByFirstAndLastNameAndEmailAddressAndStudentIDResponse_element {
public String GetRasIDByFirstAndLastNameAndEmailAddressAndStudentIDResult;
private String[] GetRasIDByFirstAndLastNameAndEmailAddressAndStudentIDResult_type_info = new String[]{'GetRasIDByFirstAndLastNameAndEmailAddressAndStudentIDResult','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'https://esb.learntoday.info/','true','false'};
private String[] field_order_type_info = new String[]{'GetRasIDByFirstAndLastNameAndEmailAddressAndStudentIDResult'};
}
public class GetRasIDBySSNResponse_element {
public String GetRasIDBySSNResult;
private String[] GetRasIDBySSNResult_type_info = new String[]{'GetRasIDBySSNResult','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'https://esb.learntoday.info/','true','false'};
private String[] field_order_type_info = new String[]{'GetRasIDBySSNResult'};
}
public class GetRasIDByFirstAndLastNameAndEmailAddressAndStudentID_element {
public String firstname;
public String lastname;
public String emailAddress;
public String studentID;
private String[] firstname_type_info = new String[]{'firstname','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] lastname_type_info = new String[]{'lastname','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] emailAddress_type_info = new String[]{'emailAddress','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] studentID_type_info = new String[]{'studentID','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'https://esb.learntoday.info/','true','false'};
private String[] field_order_type_info = new String[]{'firstname','lastname','emailAddress','studentID'};
}
public class ServiceHTTPBehaviour {
public String endpoint_x = 'https://esb.learntoday.info/RasmussenIdentificationService.svc';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
private String[] ns_map_type_info = new String[]{'https://esb.learntoday.info/', 'esbLearntodayInfo'};
public String GetRasIDBySSN(String ssn) {
esbLearntodayInfo.GetRasIDBySSN_element request_x = new esbLearntodayInfo.GetRasIDBySSN_element();
esbLearntodayInfo.GetRasIDBySSNResponse_element response_x;
request_x.ssn = ssn;
Map<String, esbLearntodayInfo.GetRasIDBySSNResponse_element> response_map_x = new Map<String, esbLearntodayInfo.GetRasIDBySSNResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'https://esb.learntoday.info/IRasmussenIdentificationService/GetRasIDBySSN',
'https://esb.learntoday.info/',
'GetRasIDBySSN',
'https://esb.learntoday.info/',
'GetRasIDBySSNResponse',
'esbLearntodayInfo.GetRasIDBySSNResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.GetRasIDBySSNResult;
}
public String GetRasIDByFirstAndLastNameAndEmailAddress(String firstname,String lastname,String emailAddress) {
esbLearntodayInfo.GetRasIDByFirstAndLastNameAndEmailAddress_element request_x = new esbLearntodayInfo.GetRasIDByFirstAndLastNameAndEmailAddress_element();
esbLearntodayInfo.GetRasIDByFirstAndLastNameAndEmailAddressResponse_element response_x;
request_x.firstname = firstname;
request_x.lastname = lastname;
request_x.emailAddress = emailAddress;
Map<String, esbLearntodayInfo.GetRasIDByFirstAndLastNameAndEmailAddressResponse_element> response_map_x = new Map<String, esbLearntodayInfo.GetRasIDByFirstAndLastNameAndEmailAddressResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'https://esb.learntoday.info/IRasmussenIdentificationService/GetRasIDByFirstAndLastNameAndEmailAddress',
'https://esb.learntoday.info/',
'GetRasIDByFirstAndLastNameAndEmailAddress',
'https://esb.learntoday.info/',
'GetRasIDByFirstAndLastNameAndEmailAddressResponse',
'esbLearntodayInfo.GetRasIDByFirstAndLastNameAndEmailAddressResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.GetRasIDByFirstAndLastNameAndEmailAddressResult;
}
public String GetRasIDBySSNAndDOB(String ssn,String dob) {
esbLearntodayInfo.GetRasIDBySSNAndDOB_element request_x = new esbLearntodayInfo.GetRasIDBySSNAndDOB_element();
esbLearntodayInfo.GetRasIDBySSNAndDOBResponse_element response_x;
request_x.ssn = ssn;
request_x.dob = dob;
Map<String, esbLearntodayInfo.GetRasIDBySSNAndDOBResponse_element> response_map_x = new Map<String, esbLearntodayInfo.GetRasIDBySSNAndDOBResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'https://esb.learntoday.info/IRasmussenIdentificationService/GetRasIDBySSNAndDOB',
'https://esb.learntoday.info/',
'GetRasIDBySSNAndDOB',
'https://esb.learntoday.info/',
'GetRasIDBySSNAndDOBResponse',
'esbLearntodayInfo.GetRasIDBySSNAndDOBResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.GetRasIDBySSNAndDOBResult;
}
public String GetRasIDByFirstAndLastNameAndEmailAddressAndStudentID(String firstname,String lastname,String emailAddress,String studentID) {
esbLearntodayInfo.GetRasIDByFirstAndLastNameAndEmailAddressAndStudentID_element request_x = new esbLearntodayInfo.GetRasIDByFirstAndLastNameAndEmailAddressAndStudentID_element();
esbLearntodayInfo.GetRasIDByFirstAndLastNameAndEmailAddressAndStudentIDResponse_element response_x;
request_x.firstname = firstname;
request_x.lastname = lastname;
request_x.emailAddress = emailAddress;
request_x.studentID = studentID;
Map<String, esbLearntodayInfo.GetRasIDByFirstAndLastNameAndEmailAddressAndStudentIDResponse_element> response_map_x = new Map<String, esbLearntodayInfo.GetRasIDByFirstAndLastNameAndEmailAddressAndStudentIDResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'https://esb.learntoday.info/IRasmussenIdentificationService/GetRasIDByFirstAndLastNameAndEmailAddressAndStudentID',
'https://esb.learntoday.info/',
'GetRasIDByFirstAndLastNameAndEmailAddressAndStudentID',
'https://esb.learntoday.info/',
'GetRasIDByFirstAndLastNameAndEmailAddressAndStudentIDResponse',
'esbLearntodayInfo.GetRasIDByFirstAndLastNameAndEmailAddressAndStudentIDResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.GetRasIDByFirstAndLastNameAndEmailAddressAndStudentIDResult;
}
}
}

 

 This is the trigger

 

trigger ESB_Trigger on Enrollment_Application__c (before update) {
// Check if the thing that changed was the Student_Approval__c checkbox at the end of the Enrollment App when the student indicates
// that they have finished
if (trigger.new[0].Student_Approval__c==true && trigger.old[0].Student_Approval__c==false) {

// include the student information (ssn) here
Contact c = [select SSN__c FROM Contact WHERE Id=:trigger.old[0].Contact__c];
string SSN=c.SSN__c;
System.debug('SSN='+SSN);

if (SSN!=null) {
string [] splitSSN = SSN.split('-');
string SSN_nodashes = splitSSN[0] + splitSSN[1] + splitSSN[2];
System.debug('SSN_nodashes='+SSN_nodashes);

esbLearntodayInfo.ServiceHTTPBehaviour newSSn = new esbLearntodayInfo.ServiceHTTPBehaviour();
string output = newSSn.GetRasIDBySSN(SSN_nodashes);
// String output back to the contact record
System.debug('RasID: '+output);
}
}
}

 

 

 

 

 

I have a nested query that looks like this:

 

sectionList = [SELECT Id,
Section__c.Column_Count__c,
Section_Number__c,
Section_Header__c,
(Select i.Type__c,
i.Spacer_Height__c,
i.Section__c,
i.Required__c,
i.Read_Only__c,
i.Object_Name__c,
i.Field_Name__c,
i.Display_Label__c,
i.Display_Label_Location__c,
i.Dependency_Required_for_Value__c,
i.Dependency_Field__c,
i.Content__c,
i.Column_Number__c
from Items__r i order by i.Column_Row_Number__c )
from Section__c ];

 

 I am getting an error "Inline query has too many rows for direct assignment, use FOR loop". My question is when you use nested queries like this, how many rows will it return?

 

For instance let's say there were 10 Section__c records and each section had 5 Item__c records. Would the query return 50 records or just 10?

 

 I am trying to have Salesforce send an email when a new Lead is created through a Web To Lead form. I have tried doing this using a Workflow and a Trigger. Either way, the email is never sent. If I create a Lead manually, the email is sent.

 

Is there something about Web To Lead functionality that inhibits sending emails via Workflows and Triggers? Any help would be appreciated.

I am unable to update a Date field in Salesforce via C#.

 

I read the post here: http://community.salesforce.com/sforce/board/message?board.id=NET_development&thread.id=4069. I attempted to install the patch (NDP20-KB925272-X86.exe) but received a message saying that the program to be updated does not exist on my computer. I have C# Express, not the full version. Perhaps that is the problem?

 

I have also tried editing the WSDL by remarking out the xsd:date and changing all fields which are date to DateTime in the WSDL.  

 

Perhaps I am not coding it properly. This is what I have tried so far:

 

string LDA_Date = parsedCSVData[(i * NUM_COLUMNS) + 8]; DateTime dt = System.DateTime.Parse(LDA_Date); String dt2 = dt.ToUniversalTime().ToString("M-d-yyyy"); Log.Text += dt2.ToString() + "\n"; DateTime dt3 = Convert.ToDateTime(dt2); LDARecs[i].LDA__c = dt3;

 

I have also tried formatting it using "yyyy-MM-dd"  and "MM-dd-yyyy"

 

I have been able to update string fields. LDA__c is a Date (not DateTime) field in Salesforce.

 

 Thanks for any help that could be provided,

Chris 

 

In the querySample() code, how does VS know what the Contact data type is? I get this error message:

 

Error    1    The type or namespace name 'Contact' could not be found (are you missing a using directive or an assembly reference?)   

 

I added WSDL to the web references and named it sForce.And I am using the following libraries.

 

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services.Protocols;
using Program.sforce;

 

 

 



namespace Program
{
class Program
{
static public SforceService binding;

static void Main(string[] args)
{


Console.Write("Enter username: ");
string username = Console.ReadLine();
Console.Write("Enter password: ");
string password = Console.ReadLine();

// Create a service object
binding = new SforceService();

// Timeout after a minute
binding.Timeout = 60000;

// Try logging in
LoginResult lr;
try
{
Console.WriteLine("LOGGING IN NOW...");
lr = binding.login(username, password);
}
// ApiFault is a proxy stub generated from the WSDL contract when
// the web service was imported
catch (SoapException e)
{
// Write the fault code to the console
Console.WriteLine(e.Code);

// Write the fault message to the console
Console.WriteLine("An unexpected error has occurred: " + e.Message);

// Write the stack trace to the console
Console.WriteLine(e.StackTrace);
}

Console.ReadLine();
}

private void querySample()
{
//The results will be placed in qr
QueryResult qr = null;

//We are going to increase our return batch size to 250 items
//Setting is a recommendation only, different batch sizes may
//be returned depending on data, to keep performance optimized.
binding.QueryOptionsValue = new QueryOptions();
binding.QueryOptionsValue.batchSize = 250;
binding.QueryOptionsValue.batchSizeSpecified = true;

try
{
qr = binding.query("select FirstName, LastName from Contact");
bool done = false;
if (qr.size > 0)
{
Console.WriteLine("Logged-in user can see "
+ qr.records.Length + " contact records.");
while (!done)
{
Console.WriteLine("");
for (int i = 0; i < qr.records.Length; i++)
{
Contact con = (Contact)qr.records[i];
string fName = con.FirstName;
string lName = con.LastName;
if (fName == null)
Console.WriteLine("Contact " + (i + 1) + ": " + lName);
else
Console.WriteLine("Contact " + (i + 1) + ": " + fName
+ " " + lName);
}
if (qr.done)
{
done = true;
}
else
{
qr = binding.queryMore(qr.queryLocator);
}
}
}
else
{
Console.WriteLine("No records found.");
}
}
catch (Exception ex)
{
Console.WriteLine("\nFailed to execute query succesfully," +
"error message was: \n{0}", ex.Message);
}
Console.WriteLine("\n\nHit enter to exit...");
Console.ReadLine();
}
}
}

 

I am writing a VF page which will be used to reassign a user's opportunities to a set of other users in a Round Robin fashion. This part is working. 

 

However, I was told to make this reassignment asynchronous (@future) and disable the button on the VF page until the process is finished so the user cannot keep clicking the button on the VF page.  Is this possible to do? How can I track when the @future process is finished?

 

Thanks,

Chris

I am having trouble with doing relationship queries in C#. I'm using the Partner WSDL

 

 

 string query = "select Account.Id, Account.Name, Id from Contact LIMIT 10";
                        
 DataTable table = GetSforceData(query, 200);
 dataGridView1.DataSource = table;

 

DataTable GetSforceData(string strSQL, int iBatchSize)
        {
            DataTable dt = null;
            
            SforceService binding = new SforceService();
            
           
            //get account name, account password and security token here            
            LoginResult lr = binding.login(strAccountName,strAccountPassword + strSecurityToken);

            if (!lr.passwordExpired)
            {
                binding.Url = lr.serverUrl;
                binding.SessionHeaderValue = new partnerWSDL.SessionHeader();
                binding.SessionHeaderValue.sessionId = lr.sessionId;

                partnerWSDL.QueryResult qr = null;
                binding.QueryOptionsValue = new partnerWSDL.QueryOptions();
                binding.QueryOptionsValue.batchSize = iBatchSize;
                binding.QueryOptionsValue.batchSizeSpecified = true;
                try
                {
                    qr = binding.query(strSQL);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString(), "Error peforming query");
                    return null;
                }

                bool done = false;

                if (qr.size > 0)
                {
                    dt = new DataTable();
                    partnerWSDL.sObject sOtmp = (partnerWSDL.sObject)qr.records[0];
                    
                    for (int i = 0; i < sOtmp.Any.Length; i++)
                    {
                        dt.Columns.Add(sOtmp.Any[i].LocalName);
                    }
                    string[] prValues = new string[sOtmp.Any.Length];
                    while (!done)
                    {
                        for (int i = 0; i < qr.records.Length; i++)
                        {
                            sOtmp = (partnerWSDL.sObject)qr.records[i];
                            for (int j = 0; j < sOtmp.Any.Length; j++)
                            {
                                if (sOtmp.Any[j].ChildNodes.Count > 1)
                                {
                                    prValues.SetValue(sOtmp.Any[j].ChildNodes[2].InnerText, j);
                                }
                                else
                                {
                                    prValues.SetValue(sOtmp.Any[j].InnerText, j);
                                }
                            }

                            dt.Rows.Add(prValues);
                        }

                        if (qr.done)
                        {
                            done = true;
                        }
                        else
                        {
                            qr = binding.queryMore(qr.queryLocator);
                        }
                    }
                }
            }

            return dt;
             
        }

 

 

So the results will only show the Account.Id not the Account.Name.

 

But it if I remove the Account.Id from the query then it will show the Account.Name.

 

It seems like it only can handle one __r type of field per query? Is this a limitation of the API?

 

 

Thanks,

Chris

 i am developing an integration application in .net with salesforce, users are allowded to choose objects and its corresponding fields at run time, after that how to code it dynamically using enterprise WSDL to insert the object by using C#.

When you write an application that logs in through the API, is there something in the API that allows you to control what shows up in a user's login history? So instead of it saying Other API in the login history it could put in the name of your application that logged into Salesforce?

 

global BatchUpdateAdmissionsGoals(String q, String e, String f, String v){
		Query=q; Entity=e; Field=f;Value=v;
		opportunityList = new List <Opportunity> ();
global Database.QueryLocator start(Database.BatchableContext BC){		
		
		return Database.getQueryLocator(query);		
	} 
	
	global void execute(Database.BatchableContext BC, List<sObject> scope){
		//List <Admissions_Goal__c> goalsToUpdate = new List<Admissions_Goal__c>();
		Integer totalLeads, weeklyLeads;
		for(sObject s : scope){
				if(s.getsObjectType() == Opportunity.sObjectType) {
			 	
				 	Opportunity o = (Opportunity)s;
				 	opportunityList.add(o);		
				}
		}
		System.debug('*** Opp list size ' + opportunityList.size());
}


global void finish(Database.BatchableContext BC){
System.debug('*** Opp list size ' + opportunityList.size());
}

 

I am trying to write some batch Apex. When the following anonymous code block

 string query = 
            'SELECT Id, OwnerID, Academic_Start_Date__c, Date_Booked__c  ' +
            'FROM Opportunity WHERE ID=\'006S0000003imhy\''; 
             
         
        BatchUpdateAdmissionsGoals updateAdmissionsGoalsJob = new BatchUpdateAdmissionsGoals (query, '', '', '');
        ID admissionsGoalsBatchJobID = Database.executeBatch(updateAdmissionsGoalsJob); 

 

:

 

When I call the the debug statement that gets the opportunityList.size() the first time and I get 1 as expected. But when I call it in the Finish() method again, I get 0. It doesn't seem to keep the the items in opportunityList when it gets to the Finish() method

Just curious (being new to VisualForce dev), but can anyone explain to me the difference between:

apex:pageBlock
and

 

 

apex:repeat

 

Both seem to iterate over data in the same method?  Thanks in advance!

Is it possible to remove the Required Information part on a Visual Force page? When you add a <apex:pageblocksection> it automatically puts a line that says Required Information on the first pageBlockSection. I want to remove it because I read that you cannot easily put that red line on custom text fields like <apex:outputText>. So I didn't want to confuse the user by saying that the red line denotes a required field.

Does the Opportunity Stage History object have any link to the opportunity? When I look in the schema browser in Eclipse and do a query on the Opportunity Stage History I don't see any link to the Opportunity that the history record is associated with.I need to query that object in Apex but I don't see a way to know what record is assocated with what opportunity.

 

Please let me know if there is something I am missing

 

Thanks,

Chris

I am noticing a very strange problem. On my page I have a <apex:selectList> with a rerender actionsupport method that calls campusChanged() that happens on the onChange event.

 

For some reason when I change the value in the selectList, I get an Insufficient Priveldges message. This was working yesterday but now does not work since I have added some code. But now I have commented out much of the code and it still happens. It happens when I use with sharing or not. It even happens when I am logged in as a System Administrator. I commented so much out that the rerender just calls campusChanged() and all that does is send a debug message. So I am really confused.

 

I checked the debug logs and when I change the select list it does not even get to my System.debug() call.

 

 

public with sharing class DOAReportController {
    public DOAReportController() {
        
        selectedCampus = campuses[0].getValue();
        
        distinctOppOwnersSet = new Set<String>();
        
        distinctOppOwners = [SELECT OwnerID FROM Opportunity GROUP BY OwnerID];
       
		for (AggregateResult ar : distinctOppOwners) {
			System.debug('OwnerID: '+ar.get('OwnerID') );
			distinctOppOwnersSet.add(ar.get('OwnerID')+'');
			
		}
		
		opportunities = [select Id, OwnerID, CreatedDate, AccountID FROM Opportunity];
        
        getCampusContacts();
       
       

    }
    
    private Opportunity [] opportunities;
    private AggregateResult[] distinctOppOwners;
    private Campus_Contacts__c [] campusContacts;
    private Map <Id, Id> oppIdToOwner;
    private Map <String, Id> userIdToName;
    private Set<String> distinctOppOwnersSet;
    
    public String weeklyAppointments { get; set; }

    public String HitRate { get; set; }

    public String SuccessfulCalls { get; set; }

    public String calls { get; set; }

    public String contactPercent { get; set; }

    public String numberOfUnContactedLeads { get; set; }

    public List<SelectOption> campuses {
        get {
            
            Account [] campus = [Select Id, Name FROM Account];
            List<SelectOption> options = new List<SelectOption>();
            
            for (Account a:campus) {
                options.add(new SelectOption(a.Id,a.Name));
            } 
            System.debug ('----- Options size ' + options.size());
            return options;
        }
        
        set;        
    }
    
    public string selectedCampus {get; set;}
    
    public List <string> nameOfReps;
    
    public void campusChanged(){
    	//campusContacts = null;  
    	System.debug('--- Selected Campus = '+selectedCampus);	
        //getNameOfReps();
        //getnumberOfLeads();
    }
    
    
    
    private void getCampusContacts() {
    	//Get the names of employees that are of the title 'Program Manager / Admissions Representative' 
    	//and are associated with the selected campus
    	campusContacts = [select Employee__r.Id, Organization__c, TItle__c, Employee__r.Name 
	                        FROM Campus_Contacts__c
	                        WHERE TItle__c = 'Program Manager / Admissions Representative' 
	                        AND Employee__r.isActive = true                 
	                        ];
        
    }
    
    public List<string> getNameOfReps() {           
        List <string> repNames = new List <string>();   
        /*
        
        if (campusContacts==null)
        	getCampusContacts();
        
        //and the names to the reNames list to display on the report
        for (Campus_Contacts__c c:campusContacts)   {
            if (c.Organization__c == selectedCampus) {        		
        	
        		repNames.add(c.Employee__r.Name);
            }
        }   
        */                
        return repNames;
    }
    
    public List <Integer> numberOfLeads;
    
    public List <Integer> getnumberOfLeads() {        
    	Date dateRangeStart = Date.newInstance(2010, 1, 1);
    	Date dateRangeEnd = Date.newInstance(2010, 4, 31);
    		
        //if (campusContacts==null)
        //	getCampusContacts();
        
        List <Integer> numLeads = new List <Integer>();
        /*
        Integer count = 0;	        
        
        for (Campus_Contacts__c c : campusContacts) {
        	 if (c.Organization__c == selectedCampus) {   
            	count = 0;
            	if (distinctOppOwnersSet.contains(c.Employee__r.Id+'')){
            		//figure out how many opps that rep owns
            		for (Opportunity o : opportunities) {
	        			if (o.ownerId == c.Employee__r.Id) {
	        				
	        				Date oppCreateDate = Date.newInstance(o.CreatedDate.year(), o.CreatedDate.month(), o.CreatedDate.day());
	        				
	        				if (oppCreateDate >= dateRangeStart &&
	        					oppCreateDate <= dateRangeEnd) {
	        						count++;
	        					}
	        			}
	        		
	       			}
	       			numLeads.add(count);	
            	}
            	
            	else {
            		//if the distinct owner list does not have the rep's id then place a 0 and move on
            		numLeads.add(0);
            		continue;
            	}
        	}
        }
        */
        numLeads.add(0);numLeads.add(0);numLeads.add(0);
        return numLeads;
	}
        
    
}

 

 

 

 

 

<apex:page controller="DOAReportController" >
    <apex:form >            
        
        <apex:selectList value="{!selectedCampus}" multiselect="false" size="1">
            <apex:selectOptions value="{!campuses}"/>
            <apex:actionSupport event="onchange" action="{!campusChanged}" 
                                            immediate="false" rerender="LastWeek"/>
        </apex:selectList>
        <br/><br/>
        <apex:outputPanel id="LastWeek">
            <table border="1" width="100%">
                <!-- Names of Reps -->
                
                
                
                
            </table>
        </apex:outputPanel>
    </apex:form>
</apex:page>

 

 

 

I need to create a visual force page wherewhen a student enrolls into the college

 

1) the student enter all the personal info 

 

2) then he fills in all the application details 

 

3) then he submits any documents if he has any 

 

 

I need to create an another visual force page where in this student writes the teacher email address and contact info who is willing to recommend the respective student.Then as soon as the student enters this , then an email should be sent to the concerned teacher and the teach should be having a link in the email. this link is an visual force page which has the student info of whom she is recommending.

 

I would really appreciate any inputs, approaches , solutions , ideas ..anything..

 

thank you 

 

  • April 01, 2010
  • Like
  • 0
If I use 

<apex:pageblocktable>

 

the behavior is that it will let me put a value which can be associated with an array in my controller so it will be a variable number of rows depending upon how many elements are in that array.

 

Is there a way, instead, to have value indicate how many columns I have. I essentially want to flip what the rows and columns are. The reason is because in the table I want a variable number of columns and a set number of rows because I know that there will be more rows than columns. Even though the number of columns would be variable, it will be no more than maybe 6 or 7. But my number of set rows will be about 20. So it would be hard to read if there are 20 columns and only 6 or so rows. 

 

I saw a dir attribute on pageblocktable, but that said it indicated left to right. Any help would be appreciated. 

I'm receiving this error on a very large (5000+ lines) VisualForce page that is used to display forms for users to fill out. The page supports several different forms, and displays whichever form is necessary based on the name of the form to be displayed (name of the form object record).

 

I have well over 100 fields from the object on this page. I added a few more fields today, and when I try to display them in an inputField component, I'm suddenly getting the:  SObject row was retrieved via SOQL without querying the requested field error. I tried putting the field at the top of the page as an <apex:inputhidden> component, and also as an <apex:outputtext rendered="false> component as referenced in this thread:

 

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=19680

 

 Still, I'm getting the error message.  If I put this field on another visualforce page (much smaller with only 1 or 2 fields) it displays with no problem. is there some kind of limit to how many fields from an object are queried by the Standard Controller? If anyone knows what may be going on here, please let me know. A snippet from my page is below:

 

<apex:page id="SDQA" standardController="SDQA__c" extensions="NewSDQAExtension" showHeader="false"> <apex:form> <apex:inputHidden value="{!SDQA__c.OperatorStamp45__c}" /> ...Lots and lots of code.... <apex:inputField value="{!SDQA__c.OperatorStamp45__c}" required="true" /> </apex:form> </apex:page>

 

 

 

 

 

Does anyone know if I can change the colors of UI theme by providing my own CSS?

Has anyone tried it? Can you tell me how can I do that?

  • March 29, 2010
  • Like
  • 0

I'm coding dependant picklists using re-rendering. In the following code,

 

 

<tr>
<td align="right">
Campus:
</td>
<td align="left">
<apex:outputPanel id="campusPanel">
<apex:selectList id="campusPicklist" value="{!campusId}" size="1">
<apex:selectOptions value="{!campuses}"/>
<apex:actionSupport event="onchange" action="{!campusChanged}"
status="programStatus" immediate="false" rerender="programPanel"/>
</apex:selectList>
<font color="red">*</font>
</apex:outputPanel>
</td>
</tr>


<tr>
<td align="right">
Program:
</td>
<td align="left">
<apex:outputPanel id="programPanel">
<apex:actionStatus id="programStatus" startText="(Loading programs...)">
<apex:facet name="stop">
&nbsp;
<apex:selectList id="programPicklist" value="{!programId}" size="1">
<apex:selectOptions value="{!programs}"/>
<apex:actionSupport event="onchange" action="{!programChanged}"
status="dateStatus" immediate="false"/>
</apex:selectList>
</apex:facet>
</apex:actionStatus>
<font color="red">*</font>
</apex:outputPanel>
</td>
</tr>

 

 

 

 When you select a Campus in the first dropdown it is supposed to refresh the list of Programs offered at that campus in the second dropdown. It actually does refresh once but then if I try changing the campus once more either to a different selection or back to the original selection it does not seem to refresh the list again.

 

Does the onChange event only occur when the dropdown is changed the 1st time? Should I use a different event?

 

Message Edited by Chris987654321 on 02-16-2010 11:09 AM

I am getting the following error when making a call to a webservice that we host through apex code:

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

 

I have done some research and found that it has to do with certificates. Our certificate is signed by Verisign. I saw that your certificate has to be added to the keystore. Does it have to be added to the keystore if we are not using 2 way trust? Also, does my Apex code have to send the certificate to the webservice somehow or is that not necessary?

 

 

public class CallESB{
@Future(callout=true)
public static void getRasID(String SSN_nodashes, string id) {
rasmussenidentificationservice.ServiceHTTPBehaviour newSSn = new rasmussenidentificationservice.ServiceHTTPBehaviour();
string output = newSSn.GetRasIDBySSN(SSN_nodashes);
// String output back to the contact record
System.debug('RasID: '+output);
if (output!=null) {
Contact c=[select rasid__c,id FROM Contact where id=:id];
c.RasId__c=output;

try{
update c;
}

catch(Exception e){
System.debug('Error ' + e.getMessage() );
}
}

}
}

 

 

 

Looking at writing a simple Apex trigger to update a lead or contact field based on a task being added.

 

Have written an after insert Task trigger.  Quick question...

 

What is the best way to determine if the WhatID references a lead or contact?  Can the ID field be treated as a string and what are the ID prefixes for the Lead and Contact table?

 

Thanks!