• Terry411
  • NEWBIE
  • 95 Points
  • Member since 2010
  • Certified Application & System Architect
  • Home Team Consulting


  • Chatter
    Feed
  • 3
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 53
    Replies
I'm having an issue with Database.DuplicateError not consistently identifying matching duplicates. Has anyone else ran into this issue?

The code below is a snippet from a webservice that is inserting a single account record.
Database.UpsertResult ur = Database.upsert(a, false);

        boolean foundDupAccount = false;
        if (ur.isSuccess()){
            System.debug('---------- Successfully created Account. AccountID: ' + ur.getId() + ' ----------');                    
            a.Id = ur.getId();
        } else {
            system.debug('---------- FAILED to create Account ----------');
            for (Database.Error error : ur.getErrors()) {
                // Process only duplicates and not other errors (e.g., validation errors)
                if (error instanceof Database.DuplicateError) {
                    String failedDML = error.getMessage();

                    // Handle the duplicate error by first casting it as a DuplicateError class
                    Database.DuplicateError duplicateError = (Database.DuplicateError)error;
                    Datacloud.DuplicateResult duplicateResult = duplicateError.getDuplicateResult();

                    // Display duplicate error message as defined in the duplicate rule
                    // system.debug('Duplicate Error: ' + duplicateResult.getErrorMessage());
                    
                    // Get duplicate records
                    // Return only match results of matching rules that find duplicate records
                    Datacloud.MatchResult[] matchResults = duplicateResult.getMatchResults();

                    // Just grab first match result (which contains the duplicate record found and other match info)
                    Datacloud.MatchResult matchResult = matchResults[0];
                    Datacloud.MatchRecord[] matchRecords = matchResult.getMatchRecords();

                    // Add matched record to the duplicate records variable
                    for (Datacloud.MatchRecord matchRecord : matchRecords) {
                        System.debug('MatchRecord: ' + matchRecord.getRecord());
                        ID ExistingAccountID = matchRecord.getRecord().Id;
                        if( ExistingAccountID <> null){
                            System.debug('---------- Using Account Record ID: ' + ExistingAccountID + ' ----------');
                            a.Id = matchRecord.getRecord().Id;
                            foundDupAccount = true;
                            break;
                        }
                    }
                } else {
                    System.debug('---------- The following error has occurred.---------- ');                    
                    System.debug(error.getStatusCode() + ': ' + error.getMessage());
                    System.debug('---------- Account fields that affected this error: ' + error.getFields() + ' ---------- ');
                }
            }
        }

 
I have a lightning component that works great until I put a ui:scrollerWrapper around it.  The scrolling works perfectly but the child component has click events like clone, edit, delete that stop working.  I'm new to this type of development so I'm hoping it's just something simple.
<ui:scrollerWrapper class="sWrapTest">
    <aura:iteration items="{!v.items}" var="item">
        <c:OpportunityLineItem item="{!item}" entries="{!v.entries}" editMode="{!v.editMode}"></c:OpportunityLineItem>
    </aura:iteration>
</ui:scrollerWrapper>
.THIS .sWrapTest {
    height:320px;
    width: 100%;
    clear: both;
}


 
I'm getting the following error:

System.QueryException: No such column 'Location__c' on entity 'Special_Event__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. 
Stack Trace: Class.ORC.<init>: line 81, column 1 Class.ORTests.testORC: line 196, column 1
  • Special_Event__c.Location__c does exist and its a GeoLocation field type
  • It is visable to all profiles.  
  • Special_Event__c is Deployed.
  • I've updated the class to API 38 thinking perhaps it's prior API version didn't support GeoLocation but that didn't help
  • I tried rewriting the soql statement to a string with a database.execute() statement but again no luck.
I'm out of ideas.  Please help with any other idea
I have a client that has a public Force.com Site that walk visitors through a set of VF pages for scheduling appointments.  The first time a user goes through the pages, the performance is very slow (frequently timesout) however the second time they do the very same thing, it's very fast.

My question is more from a performance/indexing view.  Is there a reason the performance would take so much longer, long enough to timeout, on the first time then respond so quickly on following attempts?  There are 5 or 6 objects being queried so I would expect some delays for that, but we're also not talking about very large tables either.  Given the table sizes, I can't imagine it timing out even with un-indexed SOQL queries.  

Hoping for some guidance on what I can look for or how to troubleshoot this.
I'm getting an insufficient privileges error that I cannot understand why.  I have the following pieces of code:
- SalesReportExtension.cls v31
- SalesReport.page v31
- SalesReport.component v31
- Sales_Report.email v31

The user profiles have access to the above code.

Nothing in this code updates or creates Account record however, in-order to run the Sales Report the Profile needs to have Create and Edit rights.  Without both, they will get an insufficient privileges error.  The Account is the Controller but otherwise there are not updates of any object taking place in the code.  It simply is reading sales data associated to the account and summarizing it for the user and allowing them to create a PDF attached to a SF email.  The code works fine as an Admin and it works fine if I give the user Create/Edit rights to the Account.  Help
I'm working on a proof of concept that will allow us to run Reporting Services reports via a SF Action.  The SF1 users will be connected via Good and running within the firewall.  So connectivity will not be a problem.  

What I'm fighting is getting the links on my VF page to know if I'm running within SF1 or running from my Desktop browser.  When I run the code below, both the desktop and SF1 show the alert 'hello mobile'.  How do I get this to work from the Desktop?  The mobile link works perfectly.
<script> 
	function openTab(recid, recname) {
		var url = "http://crastrsrpt01.us.xxxxxx.com/ReportServer/Pages/ReportViewer.aspx?"
		url = url + "%2fProduction%2fTRSSales%2fProducer+Profile" 		
		url = url + "&contact=" + recid
		url = url + "&rs:Format=PDF"
		
		if((typeof sforce == 'undefined') || (sforce == null)) {
    		// Desktop navigation
    		alert('hello desktop - ' + sforce);
			window.location.href = url;
		} else {
    		// Salesforce1 navigation
    		alert('hello mobile - ' + sforce);
    		sforce.one.navigateToURL(url);
		}
	}
</script>


I have a batch process setup that could process upwards of 300,000 contact records.  Do to governor limits, I've setup my code to use batch apex.  All my code is working except for the query call.  

 

TerritoryRefreshBatch trb = new TerritoryRefreshBatch();
trb.query = 'SELECT Id, AccountId, MailingPostalCode, IM_Territory__c, EM_Territory__c, RatingOverride__c ' +
							'FROM Contact ' +
							'WHERE MailingPostalCode IN \'' + zCodes + '\'' +
							'AND RecordTypeId IN \'' + rtIds + '\'';
string batchId = Database.executeBatch(trb);

Syntactically, it's saves but when I exectuce the batch I get a "First error: unexpected token: '{012d0000000Ssj3AAC, 012d0000000Ssj8AAC}'".  That token is my set<string> of values I need for the dynamic query.

 

If I modify my query to pull a specific record, everything processes fine.  So, my question is, how do I structure my query string when using the "IN" clause?

 

I need to trigger the lead assignment rules from a Lead Before trigger but only on some records.  The before trigger is processing some additional requirements so the code below is only a partial set.  I exit the trigger early if if my initial for loop doesn't require me to go do the additional processes.  However, this initial loop is setting the .setOption on all the records so wouldn't that trigger the Lead Assignment Rules regardless?  Because it's not, I thought if i add the .setOption to my second loop, that that would trigger the rules but it does not either.  Where am I going wrong?  (yes... l1.Ignore_Rules__c is false)

 

 

trigger leadBefore on Lead (before insert, before update) {

	Database.DMLOptions dmlOpts = new Database.DMLOptions();
	dmlOpts.assignmentRuleHeader.useDefaultRule = true;
	
	list<Lead> hasPI = new list<Lead>();
	list<Lead> allLeads = new list<Lead>();
    for( Lead l1 : trigger.new ) {
    	if (l1.Ignore_Rules__c == false) l1.setOptions(dmlOpts);
    	allLeads.add(l1);
    	
    	if (l1.Board_Reporting__c == true || l1.Certifier__c == true || l1.CSR__c == true || l1.Funds__c == true || 
    			l1.Private_Reporting__c == true || l1.Recovery_and_Resolution__c == true || l1.SEC_Reporting__c == true || 
    			l1.Section_16__c == true) {
    		
    		hasPI.add(l1);
    	}
    }
	if (hasPI.isEmpty() == true) return;

/*  more code below that processes records in the hasPI list.  
    then eventually we get to the final for loop where I'm setting the .setOptions(dmlOpts) along with several other fields (only showing the setOption below)
*/

    for( Lead l : allLeads ){
		l.setOptions(dmlOpts);
       }

 

 

I'm trying to create a treeview of products for a specified Pricebook.  When my page load, the treeview presents itself perfectly.  However, when I select to a different pricebook, I want to refresh the treeview but it doesn't build out with the collapsible view.  My data changes fine but it seems to me the javascript doesn't or can't re-run to build the treeview of the new data.  

 

I fully admit, I'm not totally sure I get the whole getter setter process either but it does seem from my debug logs that my Products list does reresh with the correct data.  It just doesn't present itself correctly (as a treeview) on the page.  What am I doing wrong?  

 

Visualforce Page:

<apex:page controller="ProductTreeViewController" sidebar="true" showHeader="true">
<html>
<head>
	<link rel="stylesheet" href="{!URLFOR($Resource.jsTreeView,'jquery.treeview.css')}"/>
	<script src="{!URLFOR($Resource.jsTreeView,'lib/jquery.js')}" type="text/javascript"></script>
	<script src="{!URLFOR($Resource.jsTreeView,'lib/jquery.cookie.js')}" type="text/javascript"></script>
	<script src="{!URLFOR($Resource.jsTreeView,'jquery.treeview.js')}" type="text/javascript"></script>

	<script type="text/javascript">
		$(document).ready(function(){
			$("#tree").treeview({
				collapsed: false,
				animated: "medium",
				control:"#sidetreecontrol",
				persist: "location"
			});
		})
	</script>
</head>

<body>
<apex:form id="formId" title="Product Selection Wizard">
	<br/><br/>
	<div style="width:500px;margin-left:30px;">
		<apex:pageBlock title="Product Selector">
			<apex:OutputLabel value="Pricebook:" style="font-weight:bold"/>
			<apex:selectList id="pbList" value="{!PricebookId}" size="1" title="Pricebook">
				<apex:selectOptions value="{!pb}"/>
			</apex:selectList>
  			<apex:commandButton action="{!refreshProducts}" rerender="treeViewPanel" value="Go"/>
			<br/><br/>

			<apex:outputPanel id="treeViewPanel">

				<div class="treeheader" style="height:0px;">&nbsp;</div>
				<div id="sidetreecontrol"><a href="?#"><font style="color:blue;">Collapse All</font></a> | <a href="?#"><font style="color:blue;">Expand All</font></a></div>

				<ul id="tree" class="filetree">
					<apex:repeat value="{!Products}" var="level1">
					<li class="closed"><span class="folder">{!level1.Product2.Cloud__c}</span>
						<ul>
							<apex:repeat value="{!level1.Name}" var="level2">
								<li><span class="file"><a href="/{!level1.Pricebook2Id}" target="_blank">{!level1.Name}</a></span></li>
							</apex:repeat>
						</ul>
					</li>
					</apex:repeat>
				</ul>

			</apex:outputPanel>
		</apex:pageBlock>

	</div>
</apex:form>
</body>
</html>
</apex:page>

 

 

Controller:

public with sharing class ProductTreeViewController {
	public list<selectOption> options = new list<selectOption>(); // list to hold Pricebook options
	public list<PricebookEntry> Products = new list<PricebookEntry>();
	private Id PricebookId;


	public ProductTreeViewController(){
		this.PricebookId = getPricebookId();
		//this.Products = getProducts();
	}


	public list<PricebookEntry> getProducts(){
		list<PricebookEntry> Products = [select Pricebook2Id, Id, ProductCode, Name, Product2.Family, Product2.Cloud__c,
                    Product2.Product_Sub_Family__c from PricebookEntry
                    where IsActive = true and Pricebook2Id = :PricebookId limit 10];

        system.debug('----------------------- PricebookId: ' + PricebookId);
        system.debug('----------------------- this.PricebookId: ' + this.PricebookId);
        system.debug('----------------------- Products: ' + Products);
        return Products;
	}


	public Id getPricebookId(){
		if(PricebookId==null) PricebookId='01s4000000024pn';
        return PricebookId;
    }


    public void setPricebookId(Id PricebookId){
        this.PricebookId = PricebookId;
    }


	public PageReference refreshProducts(){
        system.debug('----------------------- xPricebookId: ' + PricebookId);
        system.debug('----------------------- xthis.PricebookId: ' + this.PricebookId);
        system.debug('----------------------- xProducts: ' + Products);
        return null;
	}


	public List<selectOption> getpb() {
		list<selectOption> options = new list<selectOption>(); //new list for holding all of the picklist options
		for (Pricebook2 pb2 : [select Id, Name from Pricebook2 where IsActive = true]) {
			options.add(new selectOption(pb2.Id, pb2.Name));
		}
		return options;
	}
}

 

I feel like I'm very close to getting this to work.  What I'm trying to do it take the user to enter a Opportunity Contact Role page once they save the Opportunity.  To do so, I'm overriding the Opportunity View button.

 

I'm good with the redirct to the Opportunity Contact Role page but the standard Opportunity page is not coming up.  I get the following error:   

 

java.lang.IllegalArgumentException: Illegal view ID OpportunityRedirect?id=006M0000004ahc8. The ID must begin with /

 

Here's my code:

public with sharing class OpportunityRedirect {
	String oppId;

	public OpportunityRedirect(ApexPages.StandardController stdController) {
		//c = stdController;
		oppId = stdController.getId();
	}
        
	public PageReference redirect() {
		PageReference pageDetail = new PageReference ('/p/opp/ContactRoleEditUi/e?oppid=' + oppId + '&retURL=' + oppId);
		pageDetail.setRedirect(true);
		
		OpportunityContactRole[] ocr = [select ContactId, Role, isPrimary from OpportunityContactRole where OpportunityId = :oppId];
		system.debug('--------------------- ocr: ' + ocr);
		if (ocr.size() == 0) return pageDetail;
		
		//PageReference pageOpportunity = new PageReference('OpportunityRedirect/?id=' + oppId);
		PageReference pageOpportunity = new PageReference('OpportunityRedirect');
		pageOpportunity.getParameters().put('id',oppId);
		pageOpportunity.setRedirect(true);
		return pageOpportunity;
	}
}

 

<apex:page standardController="Opportunity" 
		extensions="OpportunityRedirect" action="{!redirect}">
	<apex:detail />
</apex:page>

 

 

I recently installed the update for the force.com IDE to Spring 12.  When I open an existing project, it asks me to Upgrade it to the newest release.  After the wizard analysis the project, it presents this alert:

 

"The following project source files have changed on the server and will be replaced with the Spring '12 version.  Click on the filename to view differences between the old and new versions."

 

When i click on one to the files, it shows me a before and after comparision.  However, the after comparison appears to then miss a lost of the data I must have had locally.  I'm guessing this is because I hadn't updated the locate source files in a while but I'm not sure of that.  

 

I'm afriad that if I continue with the update, I'll over-write valuble data from the server.  The warning messages don't seem to be clear as to what is being updated.  It doesn't make any sense to me that an update would replace server configurations with local one but I wanted to confirm with the group here before I proceeded.    

 

I have a handful of customer projects that I need to update and don't want to risk replacing server file with my local files. Is it safe to do the update and if not, how can I update my local files to match the server prior to updating the project?

Can anyone help me with this error?  I thought I had it setup the recommended way but I must not.  Thanks!

 

What this code is doing is filling in lookup fields, in essences; it's allowing us to load data without having to use a SF Id for related objects.  For example, we're using Data Loader to load insurance policies (30,000+ records).  The file has external ids like an Agent Id and SSN so we use those ids to find their matching SF Id.

 

Here's my trigger.  Line 23 is the location of the error

for (Contact c:[SELECT Id, Agent_Number__c FROM Contact where Agent_Number__c in:agId])

trigger policyBefore on Policy__c (before insert, before update) {
	// When a policy is created, link the record to the Contact's (Employee) record based on the provided SSN
	// When a policy is created, lookup the Plan Name from the Plan table using the Plan Code
	// When a policy is created, link the record to the Contact's (Agent) record based on the provided Agent Id
	
	// Create a set of all the SSN numbers (Employee ID)
	// Create a set of all the Agent numbers (Agent_Number__c)
	set<string> eeId = new set<string>();
	set<string> agId = new set<string>();
	for (Policy__c p1 :trigger.new) {
		if (p1.Employee_SSN__c <> '') eeId.add(p1.Employee_SSN__c); 
		if (p1.Agent_Number__c <> '') agId.add(p1.Agent_Number__c); 
	}
		
	// Create a map of the Employee ID (SSN) and SF Contact Id.  This will be used to resolve the Policy__c.Employee__c field
	map<string, id> sfContId = new map<string, id>();
	for (Contact c:[SELECT Id, SSN__c FROM Contact where SSN__c in:eeId]){
		sfContId.put(c.SSN__c, c.Id);	
	}
	
	// Create a map of the Agent Id (Agent_Number__c) and SF Contact Id.  This will be used to resolve the Policy__c.Agent__c field
	map<string, id> sfAgentId = new map<string, id>();
	for (Contact c:[SELECT Id, Agent_Number__c FROM Contact where Agent_Number__c in:agId]){
		sfAgentId.put(c.Agent_Number__c, c.Id);	
	}
	
	// Create a map of the Plan Number (Name) and Plan Name.  This will be used to resolve the Policy__c.Plan_Name__c field
	map<string, string> planName = new map<string, string>();
	for (Plan__c p2:[SELECT Name, Plan_Name__c FROM Plan__c]){
		planName.put(p2.Name, p2.Plan_Name__c);	
	}
	
	
	// Spin through each incoming record and set the Employee__c (Contact Id) field for each record
	for (Policy__c p :trigger.new){
		if (p.Name == null) p.Name = p.Policy_Number_DataLoad__c;
		
		if (p.Employee_SSN__c <> null) {
			p.Employee__c = sfContId.get(p.Employee_SSN__c);
		}
		if (p.Agent_Number__c <> null) {
			p.Agent__c = sfAgentId.get(p.Agent_Number__c);
		}
		if (p.Plan_Code__c <> null) {
			p.Plan_Name__c = planName.get(p.Plan_Code__c);
		}
	}	
}

 

I'm confused and hoping somene can point me in the right direction...

 

I have 4 triggers, 1 class and 1 test class.  From the IDE, if perform the "Run Tests" I have 100% coverage on all by 1 trigger which has 97% coverage. 

 

However, i'm not able to get 1 of the triggers to upload (which has 100% coverage).  When I try the "Save to Server" option I get an error saying "Average test coverage across all Apex Classes and Triggers is 64%"  

 

What am I not seeing?  The Org also has all the Non-Profit kits installed which include a ton of managed classes I can't control.  I'd like to assume those are 100% clean.

Gosh guys/gals... sometimes I just don't get it...  I've seen scores of other post with this same issues and feel like I've tried most of them and still can't resolve this error.  I must be missing something but I'm new enough to not know what it is.  Thanks for any help.

 

error: Unknown constructor 'conQuickEmail.conQuickEmail(ApexPages.StandardController controller)'

 

Here's my VF page's controller line:

<apex:page standardController="lead" extensions="conQuickEmail" id="page" tabStyle="lead">

 

Here's my latest try for the controller:

public with sharing class conQuickEmail {

private final ApexPages.StandardSetController stdController;

public conQuickEmail(ApexPages.StandardSetController controller) {
	this.stdController = (Lead)stdcontroller.getRecord();              //  <-- this is line 23

// rest of the code
}

 

Here's my test class which gives me this error:  error: Variable does not exist: ApexPages.StandardSetController

private static testmethod void  quickEmailTests() {
	Lead l = [select id from Lead where EmailBouncedDate = null and email != null limit 1];
	PageReference testPage = Page.Quick_Email;
	testPage.getParameters().put('rec',l.id);
	testPage.getParameters().put('retURL','/home/home.jsp');
	Test.setCurrentPage(testPage);
	
	conQuickEmail controller = new conQuickEmail(ApexPages.StandardSetController(l));
	controller.send();
  
	Lead l2 = [select id from Lead where EmailBouncedDate = null and email != null limit 1];
	testPage = Page.Quick_Email;
	testPage.getParameters().put('rec',l2.id);
	testPage.getParameters().put('retURL','/home/home.jsp');
	Test.setCurrentPage(testPage);
	controller = new conQuickEmail(ApexPages.StandardSetController(l));
	controller.send();
	controller.cancel();

 

 

My code is working but it's certainly not optimized so I'm hoping for tips on how to clean this up...

 

The code is tracking students (Attend_Record__c) who attended attended class (Class__c) on a specific date (Attendance__c).   The object hierarchy would be Attendance__c is the parent to Attend_Record__c.  Class__c is a lookup object to Attendance__c.

 

When attendance is being taken for the student (Attend_Record__c) the only value entered is a Student_Id__c.  Based on that field, I resolve a variety of other fields:

  1. determine the ContactID (the actual student record)
  2. add the Class__c.Id and School (Account ID) fields
  3. determine the status of the student's contract and the type of contract (this will come either from an object that all users have access to (Student_Lookup__c) or from the contract (limited access)

I'm not sure how to implement best practices when I need to retrieve data from 3 or 4 different places.  How would you consolidate this to optimize it?

 

trigger trgAttendRecord_GetContactBasedOnStudentId on Attend_Record__c (before insert, before update) {
  // This trigger populates Attend_Record__c.Student__c based on the data entered in Attend_Record__c.Student_Id__c
  
  // if we already have the status, there is no need to run this code.  Also allows mass data loading
  if (trigger.new[0].Status__c > '') {
    if (trigger.new[0].Update_Status__c == false) return;
    if (trigger.new[0].Update_Status__c == null) return;
  }
  
  
  // step 1 - retrieve the student id from Student_Lookup__c.Student_ContactID__c
  set<string> SI = new set<string>();  
  set<Id> AttendId = new set<Id>();  
  for (Attend_Record__c arc : trigger.new) {
    if (arc.Student_Id__c == null) {
      continue ;
    }
    if (arc.Student_Id__c == '') {
      continue ;
    }
    SI.add(arc.Student_Id__c);
    AttendId.add(arc.Attendance_For__c);
  }
  
  
  // step 2 - create a map of the StudentIds and ContactIds for reference    
  map<string, string> StudentIdMap = new map<string, string>();
  for (Student_Lookup__c s:[select Student_Id__c, Student_ContactID__c from Student_Lookup__c where Student_Id__c IN :SI])  
    StudentIdMap.put(s.Student_Id__c, s.Student_ContactID__c);
  
  
  // step 3 - get parent (Attendance__c) field vaules
  string txtClass = null;
  string txtSchool = null;
  for (Attendance__c[] ac2 : [Select a.Id, a.Class__c, a.Class__r.School__c from Attendance__c a where a.Id IN :AttendId]) {
    for (Attendance__c a : ac2) {
      txtClass = a.Class__c;
      txtSchool = a.Class__r.School__c; 
    }
  }
  
  
  // step 4 - resolve the student id to return the ContactId and status
  for (Attend_Record__c arc2 : Trigger.new) {
    // reset Update_Status__c flag
    arc2.Update_Status__c=false;
    
    // get the Student's ContactId
    arc2.Student__c = StudentIdMap.get(arc2.Student_Id__c);
    
    // Check Student Role - if empty set it to Student
    if (arc2.Role__c == '') arc2.Role__c = 'Student';
    
    // set default for Program name
    arc2.Program__c = '';
    
    // get Student's Class Status
    List<Student_Lookup__c> slc = [Select s.School_ClassID__c, s.School_AccountID__c, s.Program_Name__c from Student_Lookup__c s  where s.Student_ID__c = :arc2.Student_Id__c];
    for (Student_Lookup__c sl: slc) {
      // set Program name
      arc2.Program__c = sl.Program_Name__c;
      
      // set agreement Status
      if (sl.School_ClassID__c == txtClass) {
        arc2.Status__c = 'Student';
      } else if (sl.School_AccountID__c == txtSchool) {
        arc2.Status__c = 'Guest Time';
      } else arc2.Status__c = 'Guest Location';
    }

    if (slc.isEmpty()) {
      // set agreement Status
      List<contract> c = [Select c.EndDate, c.Student__c from Contract c where c.Student_ID__c = :arc2.Student_Id__c order by c.EndDate asc];
      if (c.isEmpty()) {
        arc2.Status__c = 'No Agreement';
      } else {
        for (contract c2 : c) {
          arc2.Student__c = c2.Student__c;
        }
        arc2.Status__c = 'Expired Agreement';
      }
    }    
  }
}

 Thanks

First, my apologize for all of you who feel like you've answered this question a 100 times.  I've read all your responses but am still not able to get my DatePicker to appear.

 

I have a custom controller and an InputText field id="cDate".  Here's what I've done:

 

  • I've downloaded the jQuery library and uploaded the zip file as a Static Recource called "jQueryUI"
  • I've added the following code to the top of my VF page:
<apex:page Controller="conAttendanceTaking">
<apex:form >
<head> 
    <apex:includeScript value="{!URLFOR($Resource.jQueryUI, '/js/jquery-1.4.2.min.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.jQueryUI, '/js/jquery-ui-1.8.10.custom.min.js')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.jQueryUI, 'css/ui-lightness/jquery-ui-1.8.10.custom.css')}"/>


    <script type="text/javascript">
        var j$ = jQuery.noConflict();
        j$(document).ready(function(){
        
            j$("#cDate").datepicker({
                dateFormat: 'yy-mm-dd',
                changeMonth: true,
                changeYear: true});
        });
     </script>
</head>
// VF code continues from here....
  •  Added my text field to the body of my VF page:
            <apex:outputLabel value="Class Date (yyyy-mm-dd)" for="ClassDate"/>
            <apex:inputText disabled="false" id="cDate" value="{!ClassDate}"/>

 

In my controller class is written and my page works fine with the exception of this date.  I'd like to have the datepicker appear when the inputText receives focus.  What am I doing wrong?

 

Thanks!

 

 

conAttendanceTaking

I have a Visualforce page that is building a list of values.  I'd like my "Next Record" button's action to run anytime the user hits ENTER on the keyboard.  Is there a way to make that happen?

 

 

<apex:commandButton title="Next Record" value="NextRec" action="{!NextRec}" />

 

 

I'm using a custom controller and having trouble getting the date/time field to display correctly.

 

<apex:outputLabel value="Class Date" for="ClassDate"/>
<apex:inputText id="ClassDate" value="{!ClassDateTime}"/>

 The field displays as 'Mon Mar 07 10:20:00 GMT 2011'

 

I need this to display, in the correct timezone (SCT), with a 'yyyy-MM-dd HH:mm:ss' format. 

 

Does an apex:pageBlockTable value have to be a data table (ie: data from a table / query)?  What I need to do is display a list of records formed in a LIST. 

 

The RecordList is created in my APEX class and I'm trying to display it in the Visualforce Page.  However, this gives me an Visualforce error Error: Unknown property 'conAttendanceTaking.RecordList'.  I'm assuming its because this is a List and not a data table.  How do I make something like this work?  

 

    public List<Event> RecordList = new List<Event>();

 

 

 

    <apex:pageBlock title="Attendance List">
        <apex:pageBlockTable value="{!RecordList}" var="rl" id="ResultsDataTable" styleClass="tableClass list" rowClasses="odd,even">
            <apex:column value="{!rl.OwnerId}"/>
            <apex:column value="{!rl.DurationInMinutes}"/>
            <apex:column value="{!rl.EndDateTime}"/>
            <apex:column value="{!rl.WhoId}"/>
            <apex:column value="{!rl.WhatId}"/>
            <apex:column value="{!rl.ShowAs}"/>
            <apex:column value="{!rl.StartDateTime}"/>
            <apex:column value="{!rl.Subject}"/>
            <apex:column value="{!rl.Type}"/>
            <apex:column value="{!rl.Attendance_Status__c}"/>
            <apex:column value="{!rl.Class_Role__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>

 

The idea behind my VF Page is to capture data (multiple records) then once all is captured, write the data (RecordList).  Trying to collect all the data without writting it in between each record.

 

What I'm attempting to do here is replicate data from the Contact, Account and Contract objects into a custom object called Student_Lookup__cThe application is for a franchise that has multiple schools and they have security on the accounts that prevent one franchise from seeing another frachises students however, a student can attend class at another franchises location when travelingThis requires the franchises to be able to see limited information about the student to know if they have an active contract.

 

I thought what I'd do is run a nightly job that updates the Student_Lookup__c with the relevant information from the Contact, Account, and Contract objectsBasically duplicating the dataI'm not convinced I'm doing this the easiest way so I'm open to ideasHowever this is what I have so far but I'm receiving the above error on my Map statement.

 

 

public with sharing class clsRefreshStudentLookup {
	public void Refresh() {
		// Create Variable to update all the updates
		List<Student_Lookup__c> SL = New List<Student_Lookup__c>();
		
		// Set Today's Date
		Date dExpDate = date.today();
		
		// Gather Student_Lookup__c ID's to add to the data set below
		Map<String, ID> SList = new Map<String, ID>([Select ContractId__c, ID from Student_Lookup__c where ContractId__c <> '']);		
		
		// Query for Student with active Contracts 
		for (Contract[] Stud : [Select c.AccountId, c.Id, c.OwnerId, c.Program__r.Name, c.Program__r.School__c, 
			c.StartDate, c.EndDate, c.Student__c, c.Student__r.Student_ID__c, c.Student__r.FirstName, c.Student__r.LastName, 
			c.Student__r.Birthdate, c.Student__r.EC_Name__c, c.Student__r.EC_Other_Phone__c, c.Student__r.EC_Phone__c, 
			c.Student__r.EC_Relationship__c from Contract c where c.EndDate >= :dExpDate]) {
		
			for (Contract c : Stud ) {
				ID SLid = SList.get(c.id);
				
				// Update Student_Lookup__c
				Student_Lookup__c SLUpdate = New Student_Lookup__c (
					ID = SLid,
					ContractId__c=c.Id, 
					OwnerId=c.OwnerId,
					Program_Name__c=c.Program__r.Name, 
					Contract_StartDate__c=c.StartDate,
					Contract_EndDate__c=c.EndDate,
					Student_ContactID__c=c.Student__c,
					Student_ID__c=c.Student__r.Student_ID__c, 
					First_Name__c=c.Student__r.FirstName, 
					Last_Name__c=c.Student__r.LastName,  
					Birthdate__c=c.Student__r.Birthdate, 
					EC_Name__c=c.Student__r.EC_Name__c,
					EC_Other_Phone__c=c.Student__r.EC_Other_Phone__c,
					EC_Phone__c=c.Student__r.EC_Phone__c, 
					EC_Relationship__c=c.Student__r.EC_Relationship__c,
					School_AccountID__c=c.AccountID);
				SL.add(SLUpdate);
			}
		}
		upsert SL;
	}
}

 

 

Does an apex:pageBlockTable value have to be a data table (ie: data from a table / query)?  What I need to do is display a list of records formed in a LIST. 

 

The RecordList is created in my APEX class and I'm trying to display it in the Visualforce Page.  However, this gives me an Visualforce error Error: Unknown property 'conAttendanceTaking.RecordList'.  I'm assuming its because this is a List and not a data table.  How do I make something like this work?  

 

    public List<Event> RecordList = new List<Event>();

 

 

 

    <apex:pageBlock title="Attendance List">
        <apex:pageBlockTable value="{!RecordList}" var="rl" id="ResultsDataTable" styleClass="tableClass list" rowClasses="odd,even">
            <apex:column value="{!rl.OwnerId}"/>
            <apex:column value="{!rl.DurationInMinutes}"/>
            <apex:column value="{!rl.EndDateTime}"/>
            <apex:column value="{!rl.WhoId}"/>
            <apex:column value="{!rl.WhatId}"/>
            <apex:column value="{!rl.ShowAs}"/>
            <apex:column value="{!rl.StartDateTime}"/>
            <apex:column value="{!rl.Subject}"/>
            <apex:column value="{!rl.Type}"/>
            <apex:column value="{!rl.Attendance_Status__c}"/>
            <apex:column value="{!rl.Class_Role__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>

 

The idea behind my VF Page is to capture data (multiple records) then once all is captured, write the data (RecordList).  Trying to collect all the data without writting it in between each record.

 

What I'm attempting to do here is replicate data from the Contact, Account and Contract objects into a custom object called Student_Lookup__cThe application is for a franchise that has multiple schools and they have security on the accounts that prevent one franchise from seeing another frachises students however, a student can attend class at another franchises location when travelingThis requires the franchises to be able to see limited information about the student to know if they have an active contract.

 

I thought what I'd do is run a nightly job that updates the Student_Lookup__c with the relevant information from the Contact, Account, and Contract objectsBasically duplicating the dataI'm not convinced I'm doing this the easiest way so I'm open to ideasHowever this is what I have so far but I'm receiving the above error on my Map statement.

 

 

public with sharing class clsRefreshStudentLookup {
	public void Refresh() {
		// Create Variable to update all the updates
		List<Student_Lookup__c> SL = New List<Student_Lookup__c>();
		
		// Set Today's Date
		Date dExpDate = date.today();
		
		// Gather Student_Lookup__c ID's to add to the data set below
		Map<String, ID> SList = new Map<String, ID>([Select ContractId__c, ID from Student_Lookup__c where ContractId__c <> '']);		
		
		// Query for Student with active Contracts 
		for (Contract[] Stud : [Select c.AccountId, c.Id, c.OwnerId, c.Program__r.Name, c.Program__r.School__c, 
			c.StartDate, c.EndDate, c.Student__c, c.Student__r.Student_ID__c, c.Student__r.FirstName, c.Student__r.LastName, 
			c.Student__r.Birthdate, c.Student__r.EC_Name__c, c.Student__r.EC_Other_Phone__c, c.Student__r.EC_Phone__c, 
			c.Student__r.EC_Relationship__c from Contract c where c.EndDate >= :dExpDate]) {
		
			for (Contract c : Stud ) {
				ID SLid = SList.get(c.id);
				
				// Update Student_Lookup__c
				Student_Lookup__c SLUpdate = New Student_Lookup__c (
					ID = SLid,
					ContractId__c=c.Id, 
					OwnerId=c.OwnerId,
					Program_Name__c=c.Program__r.Name, 
					Contract_StartDate__c=c.StartDate,
					Contract_EndDate__c=c.EndDate,
					Student_ContactID__c=c.Student__c,
					Student_ID__c=c.Student__r.Student_ID__c, 
					First_Name__c=c.Student__r.FirstName, 
					Last_Name__c=c.Student__r.LastName,  
					Birthdate__c=c.Student__r.Birthdate, 
					EC_Name__c=c.Student__r.EC_Name__c,
					EC_Other_Phone__c=c.Student__r.EC_Other_Phone__c,
					EC_Phone__c=c.Student__r.EC_Phone__c, 
					EC_Relationship__c=c.Student__r.EC_Relationship__c,
					School_AccountID__c=c.AccountID);
				SL.add(SLUpdate);
			}
		}
		upsert SL;
	}
}

 

 

I'm getting the following error:

System.QueryException: No such column 'Location__c' on entity 'Special_Event__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. 
Stack Trace: Class.ORC.<init>: line 81, column 1 Class.ORTests.testORC: line 196, column 1
  • Special_Event__c.Location__c does exist and its a GeoLocation field type
  • It is visable to all profiles.  
  • Special_Event__c is Deployed.
  • I've updated the class to API 38 thinking perhaps it's prior API version didn't support GeoLocation but that didn't help
  • I tried rewriting the soql statement to a string with a database.execute() statement but again no luck.
I'm out of ideas.  Please help with any other idea
I have a client that has a public Force.com Site that walk visitors through a set of VF pages for scheduling appointments.  The first time a user goes through the pages, the performance is very slow (frequently timesout) however the second time they do the very same thing, it's very fast.

My question is more from a performance/indexing view.  Is there a reason the performance would take so much longer, long enough to timeout, on the first time then respond so quickly on following attempts?  There are 5 or 6 objects being queried so I would expect some delays for that, but we're also not talking about very large tables either.  Given the table sizes, I can't imagine it timing out even with un-indexed SOQL queries.  

Hoping for some guidance on what I can look for or how to troubleshoot this.
I'm getting an insufficient privileges error that I cannot understand why.  I have the following pieces of code:
- SalesReportExtension.cls v31
- SalesReport.page v31
- SalesReport.component v31
- Sales_Report.email v31

The user profiles have access to the above code.

Nothing in this code updates or creates Account record however, in-order to run the Sales Report the Profile needs to have Create and Edit rights.  Without both, they will get an insufficient privileges error.  The Account is the Controller but otherwise there are not updates of any object taking place in the code.  It simply is reading sales data associated to the account and summarizing it for the user and allowing them to create a PDF attached to a SF email.  The code works fine as an Admin and it works fine if I give the user Create/Edit rights to the Account.  Help
I'm working on a proof of concept that will allow us to run Reporting Services reports via a SF Action.  The SF1 users will be connected via Good and running within the firewall.  So connectivity will not be a problem.  

What I'm fighting is getting the links on my VF page to know if I'm running within SF1 or running from my Desktop browser.  When I run the code below, both the desktop and SF1 show the alert 'hello mobile'.  How do I get this to work from the Desktop?  The mobile link works perfectly.
<script> 
	function openTab(recid, recname) {
		var url = "http://crastrsrpt01.us.xxxxxx.com/ReportServer/Pages/ReportViewer.aspx?"
		url = url + "%2fProduction%2fTRSSales%2fProducer+Profile" 		
		url = url + "&contact=" + recid
		url = url + "&rs:Format=PDF"
		
		if((typeof sforce == 'undefined') || (sforce == null)) {
    		// Desktop navigation
    		alert('hello desktop - ' + sforce);
			window.location.href = url;
		} else {
    		// Salesforce1 navigation
    		alert('hello mobile - ' + sforce);
    		sforce.one.navigateToURL(url);
		}
	}
</script>


I feel like I'm very close to getting this to work.  What I'm trying to do it take the user to enter a Opportunity Contact Role page once they save the Opportunity.  To do so, I'm overriding the Opportunity View button.

 

I'm good with the redirct to the Opportunity Contact Role page but the standard Opportunity page is not coming up.  I get the following error:   

 

java.lang.IllegalArgumentException: Illegal view ID OpportunityRedirect?id=006M0000004ahc8. The ID must begin with /

 

Here's my code:

public with sharing class OpportunityRedirect {
	String oppId;

	public OpportunityRedirect(ApexPages.StandardController stdController) {
		//c = stdController;
		oppId = stdController.getId();
	}
        
	public PageReference redirect() {
		PageReference pageDetail = new PageReference ('/p/opp/ContactRoleEditUi/e?oppid=' + oppId + '&retURL=' + oppId);
		pageDetail.setRedirect(true);
		
		OpportunityContactRole[] ocr = [select ContactId, Role, isPrimary from OpportunityContactRole where OpportunityId = :oppId];
		system.debug('--------------------- ocr: ' + ocr);
		if (ocr.size() == 0) return pageDetail;
		
		//PageReference pageOpportunity = new PageReference('OpportunityRedirect/?id=' + oppId);
		PageReference pageOpportunity = new PageReference('OpportunityRedirect');
		pageOpportunity.getParameters().put('id',oppId);
		pageOpportunity.setRedirect(true);
		return pageOpportunity;
	}
}

 

<apex:page standardController="Opportunity" 
		extensions="OpportunityRedirect" action="{!redirect}">
	<apex:detail />
</apex:page>