• DJP1S
  • NEWBIE
  • 140 Points
  • Member since 2012

  • Chatter
    Feed
  • 5
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 34
    Questions
  • 37
    Replies

I really want to make an application that would let the user switch between records containing login information and get back information from Google Analytics. I'd like to just process the data into visualforce charts. Is there any way to make callouts to google analytics? I can't seem to find a WSDL anywhere ad I'm not seeing any toolkits for Apex code.

  • June 11, 2013
  • Like
  • 0

I've got a big spreadsheet-style input. in a pageBlock. I''ve tried making an asynchronous call to my controller and rerendering the page based on the field value, but this is painfully slow. I'd like to use JavaScript to disable/enable an inputField on a row once a selectList is chosen. Here's what I've got, and I can see that it's not throwing any errors in Chrome and referencing the correct value. Still, it does nothing! Any help?

 

Specifically, I need help passing the selected value from the selectlist "myList" to the JavaScript in the inpuField "value" and getting it to actually disable based on that argument.

 

<apex:pageBlockSection id="Calls" columns="1" collapsible="true" title="Calls" rendered="{!totalCalls > 0}">           
            
    <apex:outputPanel styleClass="tableContainer" layout="block">
    <apex:pageBlockTable id="resultsIMC" value="{!calls}" var="n" cellPadding="4" border="1" styleclass="floatingHeaderTable">
              <apex:column value="{!n.Client_Call_Time__c}" headerValue="Call Time">
              </apex:column>
              <apex:column value="{!n.Nice_CallerID__c}" headerValue="Caller ID">
              </apex:column>
              <apex:column value="{!n.Duration__c}" headerValue="Duration">
              </apex:column>
              <apex:column headerValue="Disposition">
              <apex:selectList id="myList" value="{!n.Disposition__c}" multiselect="false" size="1" onChange="disableValue(this.value);">
                    <apex:selectOptions id="disposition" value="{!availablePick}" >
                    </apex:selectOptions>
              </apex:selectList>
              </apex:column>
              <apex:column headerValue="Category">
              <apex:selectList id="myCatCall" value="{!n.Category__c}" disabled="{!IF(n.Disposition__c != 'Accept',  true, false)}" multiselect="false" size="1" >
                    <apex:actionSupport event="onchange" action="{!updateCall}" rerender="parameters">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
                    <apex:selectOptions value="{!availableCat}"/>
              </apex:selectList>
              </apex:column>
              <apex:column headerValue="Value" style="width:20px">
              <apex:inputField id="value" value="{!n.Value__c}">
               <apex:actionSupport event="onchange"  action="{!updateCall}" rerender="parameters">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
                       <script>
                       function disableValue(e) { 
                            if ( e == "Reject" ) {
                               document.getElementById('{!$Component.value}').setAttribute("disabled","disabled");
                            } else {
                               document.getElementById('{!$Component.value}').removeAttribute("disabled");
                            }
                        }
                       </script>
              </apex:inputField>
              </apex:column>        
            </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:pageBlockSection>

 

  • May 02, 2013
  • Like
  • 0

This happening in Mozilla nad Chrome. Basically, I've got a visualforce page that renders a form. I've got the form in a section on the page layout. I've got the buttons up top fixed so the form scrolls behind the row of buttons. Once I implemented this functionality, whenever they go to modify a date, the datepicker renders hundreds of pixels below the field they clicked. What's up with that? 

 

The problem field is here :

<b>Due: &nbsp;</b> <apex:inputField value="{!n.ptask.Due__c}" style="width:80px"/>

 

<apex:page standardcontroller="Page1Project__c" extensions="ProjectNotes" doctype="html-5.0"
    action="{!allTaskNotes}" title="ProjectNotes">
    <style type="text/css">
        .lAlign
        {
            padding-left: 4px;
        }
        .panelStyle
        {
            font-family: arial;
            font-size: 9pt;
            color: #484848;
        }
        .bold
        {
            font-weight: bold;
        }
        .right
        {
            text-align: right;
        }
        .left
        {
            text-align: left;
        }
        .loadStyle
        {
            font-weight: bold;
            color: purple;
        }
        .updateStyle
        {
            color: blue;
        }
        .cke_skin_kama .cke_contents iframe
        {
            min-height: 800px;
        }   
        .floatingStyle 
        { 
            position:relative; 
        } 
        .tableContainer
        {
            height:680px; 
            width: 100%;
            overflow: auto;
        } 
    </style>

    <script>
        function setFocusOnLoad() {
        }
    </script>
    
    <!-- Add the javascript file to intialize the CkEditor -->
<apex:includescript value="{!URLFOR($Resource.CkEditor, 'ckeditor/ckeditor.js')}" />
<script type="text/javascript">
    CKEDITOR.config.height = '100px';
    CKEDITOR.config.scayt_autoStartup = true;
    CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
</script>

<apex:actionstatus id="save">
                    <apex:facet name="start">
                        <div class="waitingSearchDiv" id="el_loading" style="background-color:#fbfbfb; height:100%; opacity:0.65; width:100%;"> 
                            <div class="waitingHolder" style="top: 84px; width: 91px;">
                                <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                                <span class="waitingDescription">Saving...</span>
                            </div>
                        </div>
                    </apex:facet>
                </apex:actionstatus>
<apex:form >

 
           <div id="buttonsTop">
            
              <apex:commandButton id="switchc" value="Collapse All" action="{!getNotesSwitch}" rendered="{!IF(getNotes==true, true, false)}"/>
              <apex:commandButton id="switchu" value="Uncollapse All" action="{!getNotesSwitch}" rendered="{!IF(getNotes==false, true, false)}"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:commandButton id="saveButton" accesskey="x" value="Save" action="{!updateRecords}" status="save"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:commandButton id="createButtonSEO" value="Create SEO Recommendation" action="{!seoRecommendation}" status="Create" rendered="{!IF(projectType.Name=='SEO Recommendations', true, false)}"/>
            <apex:commandButton id="createButton" value="Create" action="{!CreateTask}" status="Create"  
            rendered="{!IF(projectType.Name!='SEO Recommendations' && projectType.Name!='Design Recommendations' && projectType.Name!='PPC Recommendations' && projectType.Name!='Social Media Recommendations' && projectType.Name!='Writing Recommendations' , true, false)}"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:actionstatus id="Create">
                    <apex:facet name="start">
                        <div class="waitingSearchDiv" id="el_loading" style="background-color:#fbfbfb; height:100%; opacity:0.65; width:100%;"> 
                            <div class="waitingHolder" style="top: 84px; width: 91px;">
                                <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                                <span class="waitingDescription">Creating a New Task and Note...</span>
                            </div>
                        </div>
                    </apex:facet>
                </apex:actionstatus>
            <apex:commandButton id="reseqButton" value="Resequence Tasks" action="{!reSeq}" status="seq" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:actionstatus id="seq">
                    <apex:facet name="start">
                        <div class="waitingSearchDiv" id="el_loading" style="background-color:#fbfbfb; height:100%; opacity:0.65; width:100%;"> 
                            <div class="waitingHolder" style="top: 84px; width: 91px;">
                                <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                                <span class="waitingDescription">Resequencing...</span>
                            </div>
                        </div>
                    </apex:facet>
                </apex:actionstatus>
             <apex:commandButton id="deleteButton" value="Delete Selected Tasks and Notes" action="{!deleteSelectedTasks}" status="delete"  />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:actionstatus id="delete">
                    <apex:facet name="start">
                        <div class="waitingSearchDiv" id="el_loading" style="background-color:#fbfbfb; height:100%; opacity:0.65; width:100%;"> 
                            <div class="waitingHolder" style="top: 84px; width: 91px;">
                                <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                                <span class="waitingDescription">Updating and Deleting...</span>
                            </div>
                        </div>
                    </apex:facet>
                </apex:actionstatus> 
              <apex:commandButton id="noteButton" value="New Task Note for Selected Tasks" action="{!noteForSelected}" status="note"  />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:actionstatus id="note">
                    <apex:facet name="start">
                        <div class="waitingSearchDiv" id="el_loading" style="background-color:#fbfbfb; height:100%; opacity:0.65; width:100%;"> 
                            <div class="waitingHolder" style="top: 84px; width: 91px;">
                                <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                                <span class="waitingDescription">Creating new Task Note...</span>
                            </div>
                        </div>
                    </apex:facet>
                </apex:actionstatus> 
                
                  <br/>
              </div>
              <apex:pageMessage rendered="{!errorFound}" summary="{!errorMessage}" severity="{!errorSeverity}" strength="2"/> 
     <apex:pageBlock >
        <apex:outputPanel styleClass="tableContainer" layout="block">
    <apex:dataTable id="resultsTask"  value="{!wrapout}" var="n">
              <apex:column style="border-bottom: solid #A3D1FF;" id="kadabra">
                   <apex:panelGrid id="taskPane" columns="10" styleClass="panelStyle" columnClasses="right bold, left"  cellPadding="0px" style="float:left;">
                    
                    <apex:outputpanel id="minus">
                    <apex:commandLink value="+" rendered="{!IF(n.collapsed==true, true, false)}" action="{!uncollapse}" styleClass="btn" style="text-decoration: none;"> 
                               <apex:param name="uncollapseParam" value="{!n.ptask.Id}" assignTo="{!tc}"/>
                          </apex:commandLink>
                      <apex:commandLink value="-" rendered="{!IF(n.collapsed==false, true, false)}" action="{!collapse}" styleClass="btn" style="text-decoration: none;">
                           <apex:param name="collapseParam" value="{!n.ptask.Id}" assignTo="{!tc}"/>
                        </apex:commandLink>
                    </apex:outputPanel>
                    <b>Seq: </b> <apex:inputText value="{!n.ptask.Seq__c}" style="width:30px" />
                    
                    <b>Description: </b> <apex:inputField value="{!n.ptask.Name}" style="width:500px"/>
                    
                    <b>Priority: </b> <apex:inputField value="{!n.ptask.Priority__c}" style="width:120px"/>
                    
                    <apex:outputLink value="https://page1solutions.my.salesforce.com/{!n.ptask.Id}" target="_blank">Task View</apex:outputLink> 
                    </apex:panelGrid>
                    <apex:panelGrid columns="12" styleClass="panelStyle" columnClasses="right bold, left"  cellPadding="0px" style="float:left;">
                    <b>Assigned To: </b> <apex:inputField value="{!n.ptask.Assigned_To__c}" style="width:120px"/>
                    
                    <b>Quant: &nbsp;</b> <apex:inputField value="{!n.ptask.Quantity__c}" style="width:30px"/>
                    
                    <b>Due: &nbsp;</b> <apex:inputField value="{!n.ptask.Due__c}" style="width:80px"/>
                     
                    <apex:outputLabel value="Status: " style="background-color:{!CASE(n.ptask.Status__c, '6) Completed', '#A7ED87', '4) On Hold', '#5C98FF', '5) Deferred', '#5C98FF', '2) Ready', '#FDFF5C', '3) Active', '#FDFF5C', '1) Not Started', '#EA5D61', 'none')}"/> <apex:inputField value="{!n.ptask.Status__c}" style="width:120px"/>
                    
                    <b>Task Select</b> <apex:inputCheckbox value="{!n.selected}">
                                        </apex:inputCheckbox>
                    <b>Complete?</b> <apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
                                        <apex:param value="{!n.ptask.Completed__c}" /> 
                                    </apex:outputText>
                    
                </apex:panelGrid>
                
    <apex:pageBlockTable id="inlinetablesec" value="{!n.ntes}" var="wo" >
           <apex:column >
                <apex:panelGrid columns="2" styleClass="panelStyle" columnClasses="right bold, left"  cellPadding="2px" style="float:left;">
                    <apex:outputLabel value="Note Type: "/>
                    <apex:outputField value="{!wo.Nte.Note_Type__c}"/>
                                                                        
                    <apex:outputLabel value="Quick Link: "/> 
                    <apex:outputLink value="https://page1solutions.my.salesforce.com/{!wo.Nte.Id}" target="_blank">{!wo.Nte.Name}</apex:outputLink>  
                                    
                </apex:panelGrid>
                <apex:panelGrid columns="2" styleClass="panelStyle" columnClasses="right bold, left" cellPadding="2px" style="float:left; max-width:50%; padding-left:14px;">    
                                                                                
                    <apex:outputLabel value="Importance: "/>
                    <apex:outputField value="{!wo.Nte.Important__c}"/> 
                    
                    <apex:outputLabel value="Created By: "/>
                    <apex:outputField value="{!wo.Nte.CreatedBy.Name}"/>
                        
                </apex:panelGrid>
                <apex:panelGrid columns="2" styleClass="panelStyle" columnClasses="right bold, left" cellPadding="2px" style="float:left; max-width:50%; padding-left:5px;">    
                    
                    <apex:outputLabel value="Archived?"/>                                    
                    <apex:outputField value="{!wo.NTE.Archived__c}"/>
                    
                    <apex:outputLabel value="Created On: "/>                                    
                    <apex:outputText value="{!wo.Nte.DOW_Created__c}, {!wo.Nte.CreatedDate}"/>
                    
                </apex:panelGrid>
                    <br/><br/>
                    <br/><br/>
                <apex:outputPanel rendered="{!IF(wo.Nte.Project__r.Project_Type__r.Name=='SEO Recommendations', true, false)}">
                <div class="lAlign" columns="2" styleClass="panelStyle" columnClasses="right bold, left" >
                    <b><apex:outputText value="Prompt: "/></b>           
                    <apex:outputText value="{!wo.Nte.Prompt__c}" style="height:12px"/>
                </div>
                </apex:outputPanel>
                <apex:outputPanel style="height:10px">
                    <apex:variable value="{!0}" var="rowNum"/>
                <div class="lAlign" >
                    <apex:inputtextarea value="{!wo.Nte.Note__c}" styleClass="ckeditor" richtext="false"/>
                </div>
                </apex:outputPanel>
                     
           </apex:column>  
           
           <apex:inlineEditSupport event="onClick"  />
        </apex:pageBlockTable>                       
           
               </apex:column> 
               
            </apex:dataTable>
            
        </apex:outputPanel>
    </apex:pageBlock> 
            </apex:form>
</apex:page>

 

  • April 16, 2013
  • Like
  • 0

I've got a method in my class that updates records. Some of my more savvy users would like a CTRL+S function to activate this while they're just sitting there.

 

Is there anyway to implement this? I don't see anything in the documentation.

  • February 16, 2013
  • Like
  • 0

I've got myself a map like the following.

Map<Page1Task__c, List<Note__c>> this.taskNotes = new Map <Page1Task__c, List<Note__c>>();

 I'd like to represent one Page1Task and a few fields, followed by all of its notes and repeat for each PageTask sObject on a visualforce page. 

 

I found something similar to this, but I this won't work since I need to just iterate through each one and display it. Here's where I'm at now...

 

 

<apex:pageBlockTable id="results" value="{!taskNotes}" var="t" cellPadding="4" border="1">
        <apex:repeat value="{!taskNotes[t]}" var="n">
              <apex:column >
...
              </apex:column> 
        </apex:repeat> 
</apex:pageBlockTable>

 

  • January 11, 2013
  • Like
  • 0

I keep getting a "no viable alternative at character ' '" error whenever I try to compare a datetime value of an sObject to CreatedDate.

 

Basically, I keep getting this written out in my query:

AND CreatedDate > 2010-01-08 00:00:00

Rather than this:

AND CreatedDate > 2010-01-08T00:00:00Z

This is driving me crazy. Any ideas on how to fix?

 

Here's my visualforce component

<b>Notes Back To:&nbsp;&nbsp;</b>
<apex:inputField value="{!dateFilter.Start_Time__c}"required="false"/>&nbsp;&nbsp;

 Which plugs into this part of my controller

this.query = 'SELECT Name, ClientCode__c, ClientCode__r.Name, DOW_Created__c, Project__c, ID, Account__c, Prompt__c,Note__c, Seq__c, CreatedBy.Name, CreatedDate, Important__c, Note_Type__c, Department__c, Note_Group__r.Name, Page1Task__c, Status__c, Date__c FROM Note__c WHERE CreatedBy.Name != null';
        system.debug('%%% query: ' + this.query); 
        if(this.dateFilter.Start_Time__c != null){
            this.query = this.query + ' AND CreatedDate > ' + dateFilter.Start_Time__c;
            system.debug('%%% query: ' + this.query); 
        }

 

 

 

 

  • January 09, 2013
  • Like
  • 0

I've got some code I've written that writes out all the service fields in my custom Task object for a it's parent Project object. When I insert a lot of records or delete a lot, this class gets called.

 

public class ProjectTaskGoals {
    
    public ProjectTaskGoals (List<Page1Task__c> triggerNew){
        
        	Page1Project__c[] projectsToUpdate = new Page1Project__c[]{};
        
         	Set<Id> projectIds = new Set<Id>();
            Page1Project__c[] relatedProjects = new Page1Project__c[]{};
            Integer num = 200;
           
            
            if(triggerNew != null){
            for(Page1Task__c cpc : triggerNew){
                
                projectIds.add(cpc.Project__c);
            }
                
            Page1Project__c[] projects = [SELECT Id, Task_Report_Codes__c FROM Page1Project__c
                                          WHERE Id =: projectIds];
                
            for(Page1Project__c pro : projects){
                
                relatedProjects.add(pro);
            }  
                
          	Page1Task__c[] writeCodes =   [SELECT Id, Seq__c, Project__c, Status__c, Service__r.Name FROM Page1Task__c
				                			WHERE Project__c =: relatedProjects
				                            AND Service__r.Name != null
				                            ORDER BY Seq__c
				                            LIMIT :num];
                
                for(Page1Project__c cci : projects){
                	Integer w = 0;
                	Integer x;
            	 	String taskReportCodes = '';
            		String taskMonthlyGoals = '';                           
                	for(Page1Task__c p1t: writeCodes){              
                    	if(p1t.Project__c == cci.Id)
		                    { 
		                        taskReportCodes += '' + p1t.Seq__c + ') ' + p1t.Service__r.Name + ', ';
		                        w += 1;
	                        }
		                        taskReportCodes += ''; 
                    }
		                 cci.Task_Report_Code_Count__c = w;
		                 integer l = taskReportCodes.length();
                   		 integer L2 = l - 2;
                    	 taskReportCodes = taskReportCodes.left(L2);
                    	 if (taskReportCodes.length() >= 255){
                             taskReportCodes = taskReportCodes.left(255);
                         }
		                 cci.Task_Report_Codes__c = taskReportCodes;
		                                
		                 projectsToUpdate.add(cci);
		                 //system.debug('%%%projectsToUpdate: ' + projectsToUpdate);
                  	                                       
            	}
         	}
        if(projectsToUpdate.size() > 0){
            	update projectsToUpdate;   
            }
	}
}

 This part is what's causing me grief is this little snippet here:

 

 for(Page1Project__c cci : projects){
                	//Some variables                         
     for(Page1Task__c p1t: writeCodes){              
         if(p1t.Project__c == cci.Id)
	    { 
              So some work
            }

 In the debug logs, I'm seeing a lot of this...

 

12:24:54.932 (20932493000)|SYSTEM_METHOD_EXIT|[42]|Id.compareTo(Id, Boolean)
12:24:54.932 (20932515000)|SYSTEM_METHOD_ENTRY|[41]|system.ListIterator.hasNext()
12:24:54.932 (20932531000)|SYSTEM_METHOD_EXIT|[41]|system.ListIterator.hasNext()
12:24:54.932 (20932572000)|SYSTEM_METHOD_ENTRY|[42]|Id.compareTo(Id, Boolean)
12:24:54.932 (20932588000)|SYSTEM_METHOD_EXIT|[42]|Id.compareTo(Id, Boolean)
12:24:54.932 (20932608000)|SYSTEM_METHOD_ENTRY|[41]|system.ListIterator.hasNext()
12:24:54.932 (20932623000)|SYSTEM_METHOD_EXIT|[41]|system.ListIterator.hasNext()
12:24:54.932 (20932664000)|SYSTEM_METHOD_ENTRY|[42]|Id.compareTo(Id, Boolean)
12:24:54.932 (20932679000)|SYSTEM_METHOD_EXIT|[42]|Id.compareTo(Id, Boolean)
12:24:54.932 (20932704000)|SYSTEM_METHOD_ENTRY|[41]|system.ListIterator.hasNext()
12:24:54.932 (20932718000)|SYSTEM_METHOD_EXIT|[41]|system.ListIterator.hasNext()
12:24:54.932 (20932761000)|SYSTEM_METHOD_ENTRY|[42]|Id.compareTo(Id, Boolean)
12:24:54.932 (20932777000)|SYSTEM_METHOD_EXIT|[42]|Id.compareTo(Id, Boolean)
12:24:54.932 (20932798000)|SYSTEM_METHOD_ENTRY|[41]|system.ListIterator.hasNext()
  • January 06, 2013
  • Like
  • 0

I've got a field that is long text that I would like to copy over to rich text in a trigger. The text gets brought over just fine, but it loses any carriage returns. If I make the Rich Text Field a Long Text Field, I easily keep the formatting by assigning

 

ObjectA.FieldA = ObjectB.FieldB;

 

 

Here's what I get now...

 

Long text field:

Blah Blah Blah

Neat Neat Neat

Oh So Cool

 

Rich Text Field:

Blah Blah BlahNeat Neat NeatOh So Cool

 

How can I keep my carriage returns? I would rather not have to change the field types, that is a last-ditch effort.

  • December 26, 2012
  • Like
  • 0

Okay, I've got a piece of code that makes a new SObject record from data in a field. It looks like this:

for(Page1Task__c p1t : trigger.new){
        		if(p1t.Task_Notes__c != null && p1t.Task_Notes__c != ''){
                    Note__c note = new Note__c();
                    note.Note__c = p1t.Task_Notes__c;
                    note.Note_Type__c = 'Page1Task Instructions';
                    note.Important__c = '4) Normal';
                    note.Prompt__c = p1t.Name;
                    note.Department__c = '<N/A>';
                    note.Reference_Id__c = p1t.Id;
                    note.Page1Task__c = p1t.Id;
                    taskNote.add(note);    
        		}                                    
        	}
        	if(taskNote.size() > 0){
     	 		insert taskNote;
        	}
        	

 

When I insert a bunch of Page1Task__c records, I get the Too Many SOQL Query error. When I remove the IF statement, I don't and I get all of my Note__c records that I want (and then a bunch for blank fields). 

It looks like it's inserting a bunch of notes one-by-one even though it's outside the FOR loop. Here's what my code looks like that works (kinda) the way I want it:

 

for(Page1Task__c p1t : trigger.new){
                    Note__c note = new Note__c();
                    note.Note__c = p1t.Task_Notes__c;
                    note.Note_Type__c = 'Page1Task Instructions';
                    note.Important__c = '4) Normal';
                    note.Prompt__c = p1t.Name;
                    note.Department__c = '<N/A>';
                    note.Reference_Id__c = p1t.Id;
                    note.Page1Task__c = p1t.Id;
                    taskNote.add(note);            
        	}
        	if(taskNote.size() > 0){
     	 		insert taskNote;
        	}

 All I did was remove the IF statement. Now my records are getting processed in bulk. 

 

Here's another way I've tried it - still gives me an error.

 

}else if(trigger.isAfter){

            for(integer i=0; i<trigger.new.size(); i++){
            	if(trigger.new[i].Task_Notes__c != null){
            		Note__c note = new Note__c();
                    note.Note__c = trigger.new[i].Task_Notes__c;
                    note.Note_Type__c = 'Page1Task Instructions';
                    note.Important__c = '4) Normal';
                    note.Prompt__c = trigger.new[i].Name;
                    note.Department__c = '<N/A>';
                    note.Reference_Id__c = trigger.new[i].Id;
                    note.Page1Task__c = trigger.new[i].Id;
                    taskNote.add(note); 
            	}
            }
        		insert taskNote;

 

 

 

  • December 26, 2012
  • Like
  • 0

Hi, I was wondering if any of you have some kind of code sample that writes out data from a query like this:

 

My_Object.Field_A

My_Object.Field_B

My_Object.Field_C

My_Object.Field_A

My_Object.Field_B

My_Object.Field_C

 

And then I can just add dividers between each record that is written out this way. I basically want to simulate a basic report or word-style document, rather than using the usual pageBlockTable element.

  • December 19, 2012
  • Like
  • 0

I've got a visualforce page that works with a custom controller. This inputField works as intended for me (an admin). It looks like this:

 

 

To my users, it looks like this:

 

  • November 26, 2012
  • Like
  • 0

I'm trying to implement a query built from other variables, I'm getting it from the part highlighted in red. I figured this by trial-and-error. Why is this not working? I can get the query to run with all other conditions when that field (dateFilter.Date__c) is excluded. It works in a standard SOQL query, but I need a dynamic one because of the namestring.

 

There is definitely a date variable being assigned at this point in the query.

 

if(this.selectedCode.Name != null){
            this.clientCCs = Database.query('SELECT ClientCode__c,Sent_Date_Time__c,Lead_Status__c, No_Count_Reason__c, Body__c,Subject__c,From__c,Page_Source__c,HTTP_Referer__c,Client_Selection_Method__c,P1C_CCID__c,ClientCode__r.Account_Manager__c,AM__c,Syndication__c FROM Client_CC__c WHERE Lead_Status__c = ' + this.leadStatus + ' AND Sent_Date__c > ' + this.dateFilter.Date__c + ' AND ClientCode__r.Name LIKE ' + '\'%' + this.nameString + '%\'' + ' LIMIT ' + this.queryLimit);
}

 

 

  • November 13, 2012
  • Like
  • 0

I've got a select list with values in it, once something other than null or "--None--" is selected, I want a button to cease being disabled. How might this be accomplished, generally? Here's the chunk of code I'm working with:

 

                <b>&nbsp;IMC:&nbsp;</b>
                <apex:selectList value="{!selectedIMC}" multiselect="false" size="1" rerender="Search for CC Emails" >
                    <apex:selectOptions value="{!availableIMCs}"/>
                </apex:selectList>&nbsp;&nbsp;
    
                <b>Record Limit&nbsp;</b>
                <apex:inputText value="{!queryLimit}" required="false" style="width:30px;"/>&nbsp;&nbsp;
                
                <apex:commandButton value="Search for CC Emails" action="{!searchForClientCCs}" rerender="clientCCBlock, buttonBlock" status="ccSearchStatus" disabled="true"/>&nbsp;
                <apex:actionstatus id="ccSearchStatus">
                    <apex:facet name="start">
                        <div class="waitingSearchDiv" id="el_loading" style="background-color:#fbfbfb; height:100%; opacity:0.65; width:100%;"> 
                            <div class="waitingHolder" style="top: 84px; width: 91px;">
                                <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                                <span class="waitingDescription">Searching...</span>
                            </div>
                        </div>
                    </apex:facet>
                </apex:actionstatus>

 

I want Seach for CC Emails to enable when I click a value in IMC. Even a blog post overviewing the topic would be helpful. Thanks.

  • November 12, 2012
  • Like
  • 0

I've got this little bit of coe: 

if(ac.Start_Time__c != null && ac.End_Time__c != null){
            	decimal Hours = decimal.valueOf((ac.End_Time__c.getTime() -  ac.Start_Time__c.getTime())/(1000*60*60));
                system.debug('$$$ Hours:' + Hours);
               	ac.Hours__c = Hours;
            }

 

And it returns a decimal just fine if I have the Start_Time__c and End_Time__c as a whole hour (e.g., 6:00 pm), but if I have I have a partial hour (Start Time at 2 pm and End Time at 6:30pm), I get 4.00 returned instead of 4.5. Why is this?

  • October 31, 2012
  • Like
  • 0

I'm trying to get a detail page button that can handle prepulating fields upon entering a new account time entry from certain custom objects.

 

For instance my url from my Page1Project object looks like this: .

/a20/e?&CF00N40000002ajJy={!Page1Project__c.ClientCode__c}&CF00N40000002ajK3={!User.Name}&CF00N40000002cgfq={!Page1Project__c.ClientCode__r.Account__c}

 


I'm getting an error on that bolded part, is it possible to populate based on a lookup value in this case?

 

 

  • October 30, 2012
  • Like
  • 0

I have no clue why this won't work. I've tried it a couple ways. Basically, I'm just trying to change the record type of the account record to a specific record type whnever certain conditions are met. Is this even possible?

 

The first: 

trigger AccountRecordType on Account (after update) {
    
    List<RecordType> getRecordType = new List<RecordType>([SELECT Id, Name FROM RecordType WHERE Id = '01240000000DciMAAS']);
    List<Account> updateAccounts = new List<Account>();
    
    for(Account acc : trigger.new){
    	if (acc.Type == 'Client - Active'){
            for(Account aco : trigger.old){
            	if (aco.Account_RecordType__c == 'Prospect - Page 1 SEO'){
                    aco.RecordType = getRecordType[0];
                    updateAccounts.add(aco);
                }
            }
        }     	   
    }
    update updateAccounts;

}

 And this way:

 

trigger AccountRecordType on Account (after update) {
    
    List<Account> updateAccounts = new List<Account>();
    
    for(Account acc : trigger.new){
    	if (acc.Type == 'Client - Active'){
            for(Account aco : trigger.old){
            	if (aco.Account_RecordType__c == 'Prospect - Page 1 SEO'){
                    aco.RecordTypeId = '01240000000DciMAAS';
                    updateAccounts.add(aco);
                }
            }
        }     	   
    }
    update updateAccounts;

}

 

  • September 28, 2012
  • Like
  • 0

I've got this piece of code in my sandbox which is working just fine 

      Page1Project__c[] updates = new Page1Project__c[]{};
      Project_Template__c[] templates = new  Project_Template__c[]{};
       	
      for (Page1Project__c pu : projects){
      			updates.add(pu);
      }
    ; 
      	    for (Project_Template__c pt : [SELECT Name, Id, Times_Used__c, Last_Used__c FROM Project_Template__c]){
           	 	for(Page1Project__c u : updates){
                	if(pt.Id == u.Project_Template__c){
                 		decimal i = pt.Times_Used__c;
                 		pt.Times_Used__c = i + 1;
                        integer m = u.CreatedDate.date().month();
                        string ms = string.valueOf(m);
                        integer d = u.CreatedDate.date().day();
                        string ds = string.valueOf(d);
                    	pt.Last_Used__c = '' + u.CreatedDate.date().year() + '-' + ms.leftPad(2, '0') + '-' + ds.leftPad(2, '0') + ' - ' + UserInfo.getFirstName() + UserInfo.getLastName().SubString(0,1);
                        //string d = u.createdDate.date().year();();
                        templates.add(pt);
                	}
                }
            }
    if (templates.size() >0){
    	update templates;
    }

 But whenever I try to deploy I get a save error that the "Method does not exist or incorrect signature: [String].leftPad(Integer, String)"

 

It's throwing it at this line:

 

pt.Last_Used__c = '' + u.CreatedDate.date().year() + '-' + ms.leftPad(2, '0') + '-' + ds.leftPad(2, '0') + ' - ' + UserInfo.getFirstName() + UserInfo.getLastName().SubString(0,1);

 I'm trying to get the string writted like this: 2012-09-26 - FirstnameL

 

  • September 27, 2012
  • Like
  • 0

Hi, I have a picklist with values like "Boo Foo (2)[0]"

 

I want to grab the 2 and use it later in a DML statement. However, when I write my code like this:

 

String s = t.Prospect_Phase_Change__c;
                    system.debug('%%% s: ' + s);
                    s.split('(', 1);
                    system.debug('$$$ s: ' + s);

 I get the error "Invalid regex: Unclosed group near index 1 ( ^"

 

I was planning to split it to the right of the '(' and the left of the ')' and then write that value elsewhere.

  • September 24, 2012
  • Like
  • 0

If I write a string like this: 

 

priorityList += '- ' + writePriority[i].CreatedBy.Name + ' - ' + writePriority[i].LastModifiedDate + ': ' + writePriority[i].Priority_Notes__c;

 What would be the best way to get the modified date to only display 2012-09-14, without the time following?

  • September 14, 2012
  • Like
  • 0

I have a class that has some limited functionality. I'd like for it to be able to handle more related priorities without having to hard-code each scnario, e.g.:

 

List<Client_Priority__c> writePriority = new Client_Priority__c[6];
                   writePriority = [SELECT ClientCode__c, Priority_Notes__c, Status__c FROM Client_Priority__c
                                      WHERE Status__c = 'Active' AND Client_Priority__c.ClientCode__c =: cci.Id
                                      LIMIT 5];
                                       
                            //for(Client_Priority__c wp : writePriority){
                if(writePriority.size() == 1){
                                priorityList += 'Client Priorities: \r\n- ' + writePriority[0].Priority_Notes__c;
                                priorityList += '\r\n';
                }
                if(writePriority.size() == 2){
                                priorityList += 'Client Priorities: \r\n- ' + writePriority[0].Priority_Notes__c;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[1].Priority_Notes__c ;
                                priorityList += '\r\n';
                }
                if(writePriority.size() == 3){
                                priorityList += 'Client Priorities: \r\n- ' + writePriority[0].Priority_Notes__c;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[1].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[2].Priority_Notes__c ;
                }
                if(writePriority.size() >= 4){
                                priorityList += 'Client Priorities: \r\n- ' + writePriority[0].Priority_Notes__c;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[1].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[2].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[3].Priority_Notes__c ;
                }
                if(writePriority.size() >= 5){
                                priorityList += 'Client Priorities: \r\n- ' + writePriority[0].Priority_Notes__c;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[1].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[2].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[3].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[4].Priority_Notes__c ;
                }
                if(writePriority.size() >= 6){
                                priorityList += 'Client Priorities: \r\n- ' + writePriority[0].Priority_Notes__c;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[1].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[2].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[3].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[4].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[5].Priority_Notes__c ;
                }

 

It prints text out too the client priorities field like this:

 

Client Priorities:

- A Priority

- Another Priority

- Foo Foo Foo

 

How could I get this to work in a loop to handle more than 6 (what I have coded for now) client priorities?

  • September 12, 2012
  • Like
  • 0

Hey everyone, I've got this Apex class that I swear should work:

 

Global class Page1TaskReadyTriggerDate implements Schedulable {
  global void execute (Schedulablecontext SC){
    
    Page1Task__c[] tasksToUpdate = new Page1Task__c[]{};
    
  date myDate = system.today();
  
  Page1Task__c[] readyTasks = ([SELECT ID, Status__c FROM Page1Task__c 
                WHERE Ready_Trigger_Date__c != NULL
                AND Ready_Trigger_Date__c <= :myDate
                AND Status__c = '1) Not Started']);
          
  for (Page1Task__c rt : readyTasks){
    if (rt.Status__c != null){
    rt.Status__c = '2) Ready';
    tasksToUpdate.add(rt);      
    }
  }
  
  
  update tasksToUpdate;
  
  }
}

 

When I use the baked-in apex scheduler in Salesforce, it will run on the day I set it - but fails on subsequent days. For instance, I set it to run each day at 6am. It will run that day at 6am and set all of my fields accordingly. It fails on subsequent days. Is there something I'm missing or should this be rewritten?

 

Edit: It actually only runs the day the class was generated. It's not getting the system date on subsequent days, Creating a second scheduled apex job results in nothing, but rebuilding the class and scheduling works fine.

  • August 06, 2012
  • Like
  • 1

I really want to make an application that would let the user switch between records containing login information and get back information from Google Analytics. I'd like to just process the data into visualforce charts. Is there any way to make callouts to google analytics? I can't seem to find a WSDL anywhere ad I'm not seeing any toolkits for Apex code.

  • June 11, 2013
  • Like
  • 0

I've got a big spreadsheet-style input. in a pageBlock. I''ve tried making an asynchronous call to my controller and rerendering the page based on the field value, but this is painfully slow. I'd like to use JavaScript to disable/enable an inputField on a row once a selectList is chosen. Here's what I've got, and I can see that it's not throwing any errors in Chrome and referencing the correct value. Still, it does nothing! Any help?

 

Specifically, I need help passing the selected value from the selectlist "myList" to the JavaScript in the inpuField "value" and getting it to actually disable based on that argument.

 

<apex:pageBlockSection id="Calls" columns="1" collapsible="true" title="Calls" rendered="{!totalCalls > 0}">           
            
    <apex:outputPanel styleClass="tableContainer" layout="block">
    <apex:pageBlockTable id="resultsIMC" value="{!calls}" var="n" cellPadding="4" border="1" styleclass="floatingHeaderTable">
              <apex:column value="{!n.Client_Call_Time__c}" headerValue="Call Time">
              </apex:column>
              <apex:column value="{!n.Nice_CallerID__c}" headerValue="Caller ID">
              </apex:column>
              <apex:column value="{!n.Duration__c}" headerValue="Duration">
              </apex:column>
              <apex:column headerValue="Disposition">
              <apex:selectList id="myList" value="{!n.Disposition__c}" multiselect="false" size="1" onChange="disableValue(this.value);">
                    <apex:selectOptions id="disposition" value="{!availablePick}" >
                    </apex:selectOptions>
              </apex:selectList>
              </apex:column>
              <apex:column headerValue="Category">
              <apex:selectList id="myCatCall" value="{!n.Category__c}" disabled="{!IF(n.Disposition__c != 'Accept',  true, false)}" multiselect="false" size="1" >
                    <apex:actionSupport event="onchange" action="{!updateCall}" rerender="parameters">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
                    <apex:selectOptions value="{!availableCat}"/>
              </apex:selectList>
              </apex:column>
              <apex:column headerValue="Value" style="width:20px">
              <apex:inputField id="value" value="{!n.Value__c}">
               <apex:actionSupport event="onchange"  action="{!updateCall}" rerender="parameters">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
                       <script>
                       function disableValue(e) { 
                            if ( e == "Reject" ) {
                               document.getElementById('{!$Component.value}').setAttribute("disabled","disabled");
                            } else {
                               document.getElementById('{!$Component.value}').removeAttribute("disabled");
                            }
                        }
                       </script>
              </apex:inputField>
              </apex:column>        
            </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:pageBlockSection>

 

  • May 02, 2013
  • Like
  • 0

I've got a method in my class that updates records. Some of my more savvy users would like a CTRL+S function to activate this while they're just sitting there.

 

Is there anyway to implement this? I don't see anything in the documentation.

  • February 16, 2013
  • Like
  • 0

I've got myself a map like the following.

Map<Page1Task__c, List<Note__c>> this.taskNotes = new Map <Page1Task__c, List<Note__c>>();

 I'd like to represent one Page1Task and a few fields, followed by all of its notes and repeat for each PageTask sObject on a visualforce page. 

 

I found something similar to this, but I this won't work since I need to just iterate through each one and display it. Here's where I'm at now...

 

 

<apex:pageBlockTable id="results" value="{!taskNotes}" var="t" cellPadding="4" border="1">
        <apex:repeat value="{!taskNotes[t]}" var="n">
              <apex:column >
...
              </apex:column> 
        </apex:repeat> 
</apex:pageBlockTable>

 

  • January 11, 2013
  • Like
  • 0

I keep getting a "no viable alternative at character ' '" error whenever I try to compare a datetime value of an sObject to CreatedDate.

 

Basically, I keep getting this written out in my query:

AND CreatedDate > 2010-01-08 00:00:00

Rather than this:

AND CreatedDate > 2010-01-08T00:00:00Z

This is driving me crazy. Any ideas on how to fix?

 

Here's my visualforce component

<b>Notes Back To:&nbsp;&nbsp;</b>
<apex:inputField value="{!dateFilter.Start_Time__c}"required="false"/>&nbsp;&nbsp;

 Which plugs into this part of my controller

this.query = 'SELECT Name, ClientCode__c, ClientCode__r.Name, DOW_Created__c, Project__c, ID, Account__c, Prompt__c,Note__c, Seq__c, CreatedBy.Name, CreatedDate, Important__c, Note_Type__c, Department__c, Note_Group__r.Name, Page1Task__c, Status__c, Date__c FROM Note__c WHERE CreatedBy.Name != null';
        system.debug('%%% query: ' + this.query); 
        if(this.dateFilter.Start_Time__c != null){
            this.query = this.query + ' AND CreatedDate > ' + dateFilter.Start_Time__c;
            system.debug('%%% query: ' + this.query); 
        }

 

 

 

 

  • January 09, 2013
  • Like
  • 0

I've got a field that is long text that I would like to copy over to rich text in a trigger. The text gets brought over just fine, but it loses any carriage returns. If I make the Rich Text Field a Long Text Field, I easily keep the formatting by assigning

 

ObjectA.FieldA = ObjectB.FieldB;

 

 

Here's what I get now...

 

Long text field:

Blah Blah Blah

Neat Neat Neat

Oh So Cool

 

Rich Text Field:

Blah Blah BlahNeat Neat NeatOh So Cool

 

How can I keep my carriage returns? I would rather not have to change the field types, that is a last-ditch effort.

  • December 26, 2012
  • Like
  • 0

Okay, I've got a piece of code that makes a new SObject record from data in a field. It looks like this:

for(Page1Task__c p1t : trigger.new){
        		if(p1t.Task_Notes__c != null && p1t.Task_Notes__c != ''){
                    Note__c note = new Note__c();
                    note.Note__c = p1t.Task_Notes__c;
                    note.Note_Type__c = 'Page1Task Instructions';
                    note.Important__c = '4) Normal';
                    note.Prompt__c = p1t.Name;
                    note.Department__c = '<N/A>';
                    note.Reference_Id__c = p1t.Id;
                    note.Page1Task__c = p1t.Id;
                    taskNote.add(note);    
        		}                                    
        	}
        	if(taskNote.size() > 0){
     	 		insert taskNote;
        	}
        	

 

When I insert a bunch of Page1Task__c records, I get the Too Many SOQL Query error. When I remove the IF statement, I don't and I get all of my Note__c records that I want (and then a bunch for blank fields). 

It looks like it's inserting a bunch of notes one-by-one even though it's outside the FOR loop. Here's what my code looks like that works (kinda) the way I want it:

 

for(Page1Task__c p1t : trigger.new){
                    Note__c note = new Note__c();
                    note.Note__c = p1t.Task_Notes__c;
                    note.Note_Type__c = 'Page1Task Instructions';
                    note.Important__c = '4) Normal';
                    note.Prompt__c = p1t.Name;
                    note.Department__c = '<N/A>';
                    note.Reference_Id__c = p1t.Id;
                    note.Page1Task__c = p1t.Id;
                    taskNote.add(note);            
        	}
        	if(taskNote.size() > 0){
     	 		insert taskNote;
        	}

 All I did was remove the IF statement. Now my records are getting processed in bulk. 

 

Here's another way I've tried it - still gives me an error.

 

}else if(trigger.isAfter){

            for(integer i=0; i<trigger.new.size(); i++){
            	if(trigger.new[i].Task_Notes__c != null){
            		Note__c note = new Note__c();
                    note.Note__c = trigger.new[i].Task_Notes__c;
                    note.Note_Type__c = 'Page1Task Instructions';
                    note.Important__c = '4) Normal';
                    note.Prompt__c = trigger.new[i].Name;
                    note.Department__c = '<N/A>';
                    note.Reference_Id__c = trigger.new[i].Id;
                    note.Page1Task__c = trigger.new[i].Id;
                    taskNote.add(note); 
            	}
            }
        		insert taskNote;

 

 

 

  • December 26, 2012
  • Like
  • 0

I've got a visualforce page that works with a custom controller. This inputField works as intended for me (an admin). It looks like this:

 

 

To my users, it looks like this:

 

  • November 26, 2012
  • Like
  • 0

Hi everyone,

 

I would like to show the values of each bar on the bar chart I created at the top of the bar chart like a report. However I am having trouble figuring out how to do that. I would appreciate the help. 

 

Thank,

I've got a select list with values in it, once something other than null or "--None--" is selected, I want a button to cease being disabled. How might this be accomplished, generally? Here's the chunk of code I'm working with:

 

                <b>&nbsp;IMC:&nbsp;</b>
                <apex:selectList value="{!selectedIMC}" multiselect="false" size="1" rerender="Search for CC Emails" >
                    <apex:selectOptions value="{!availableIMCs}"/>
                </apex:selectList>&nbsp;&nbsp;
    
                <b>Record Limit&nbsp;</b>
                <apex:inputText value="{!queryLimit}" required="false" style="width:30px;"/>&nbsp;&nbsp;
                
                <apex:commandButton value="Search for CC Emails" action="{!searchForClientCCs}" rerender="clientCCBlock, buttonBlock" status="ccSearchStatus" disabled="true"/>&nbsp;
                <apex:actionstatus id="ccSearchStatus">
                    <apex:facet name="start">
                        <div class="waitingSearchDiv" id="el_loading" style="background-color:#fbfbfb; height:100%; opacity:0.65; width:100%;"> 
                            <div class="waitingHolder" style="top: 84px; width: 91px;">
                                <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                                <span class="waitingDescription">Searching...</span>
                            </div>
                        </div>
                    </apex:facet>
                </apex:actionstatus>

 

I want Seach for CC Emails to enable when I click a value in IMC. Even a blog post overviewing the topic would be helpful. Thanks.

  • November 12, 2012
  • Like
  • 0

I've got this little bit of coe: 

if(ac.Start_Time__c != null && ac.End_Time__c != null){
            	decimal Hours = decimal.valueOf((ac.End_Time__c.getTime() -  ac.Start_Time__c.getTime())/(1000*60*60));
                system.debug('$$$ Hours:' + Hours);
               	ac.Hours__c = Hours;
            }

 

And it returns a decimal just fine if I have the Start_Time__c and End_Time__c as a whole hour (e.g., 6:00 pm), but if I have I have a partial hour (Start Time at 2 pm and End Time at 6:30pm), I get 4.00 returned instead of 4.5. Why is this?

  • October 31, 2012
  • Like
  • 0

I'm trying to get a detail page button that can handle prepulating fields upon entering a new account time entry from certain custom objects.

 

For instance my url from my Page1Project object looks like this: .

/a20/e?&CF00N40000002ajJy={!Page1Project__c.ClientCode__c}&CF00N40000002ajK3={!User.Name}&CF00N40000002cgfq={!Page1Project__c.ClientCode__r.Account__c}

 


I'm getting an error on that bolded part, is it possible to populate based on a lookup value in this case?

 

 

  • October 30, 2012
  • Like
  • 0

I've got this piece of code in my sandbox which is working just fine 

      Page1Project__c[] updates = new Page1Project__c[]{};
      Project_Template__c[] templates = new  Project_Template__c[]{};
       	
      for (Page1Project__c pu : projects){
      			updates.add(pu);
      }
    ; 
      	    for (Project_Template__c pt : [SELECT Name, Id, Times_Used__c, Last_Used__c FROM Project_Template__c]){
           	 	for(Page1Project__c u : updates){
                	if(pt.Id == u.Project_Template__c){
                 		decimal i = pt.Times_Used__c;
                 		pt.Times_Used__c = i + 1;
                        integer m = u.CreatedDate.date().month();
                        string ms = string.valueOf(m);
                        integer d = u.CreatedDate.date().day();
                        string ds = string.valueOf(d);
                    	pt.Last_Used__c = '' + u.CreatedDate.date().year() + '-' + ms.leftPad(2, '0') + '-' + ds.leftPad(2, '0') + ' - ' + UserInfo.getFirstName() + UserInfo.getLastName().SubString(0,1);
                        //string d = u.createdDate.date().year();();
                        templates.add(pt);
                	}
                }
            }
    if (templates.size() >0){
    	update templates;
    }

 But whenever I try to deploy I get a save error that the "Method does not exist or incorrect signature: [String].leftPad(Integer, String)"

 

It's throwing it at this line:

 

pt.Last_Used__c = '' + u.CreatedDate.date().year() + '-' + ms.leftPad(2, '0') + '-' + ds.leftPad(2, '0') + ' - ' + UserInfo.getFirstName() + UserInfo.getLastName().SubString(0,1);

 I'm trying to get the string writted like this: 2012-09-26 - FirstnameL

 

  • September 27, 2012
  • Like
  • 0

Hi, I have a picklist with values like "Boo Foo (2)[0]"

 

I want to grab the 2 and use it later in a DML statement. However, when I write my code like this:

 

String s = t.Prospect_Phase_Change__c;
                    system.debug('%%% s: ' + s);
                    s.split('(', 1);
                    system.debug('$$$ s: ' + s);

 I get the error "Invalid regex: Unclosed group near index 1 ( ^"

 

I was planning to split it to the right of the '(' and the left of the ')' and then write that value elsewhere.

  • September 24, 2012
  • Like
  • 0

If I write a string like this: 

 

priorityList += '- ' + writePriority[i].CreatedBy.Name + ' - ' + writePriority[i].LastModifiedDate + ': ' + writePriority[i].Priority_Notes__c;

 What would be the best way to get the modified date to only display 2012-09-14, without the time following?

  • September 14, 2012
  • Like
  • 0

I have a class that has some limited functionality. I'd like for it to be able to handle more related priorities without having to hard-code each scnario, e.g.:

 

List<Client_Priority__c> writePriority = new Client_Priority__c[6];
                   writePriority = [SELECT ClientCode__c, Priority_Notes__c, Status__c FROM Client_Priority__c
                                      WHERE Status__c = 'Active' AND Client_Priority__c.ClientCode__c =: cci.Id
                                      LIMIT 5];
                                       
                            //for(Client_Priority__c wp : writePriority){
                if(writePriority.size() == 1){
                                priorityList += 'Client Priorities: \r\n- ' + writePriority[0].Priority_Notes__c;
                                priorityList += '\r\n';
                }
                if(writePriority.size() == 2){
                                priorityList += 'Client Priorities: \r\n- ' + writePriority[0].Priority_Notes__c;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[1].Priority_Notes__c ;
                                priorityList += '\r\n';
                }
                if(writePriority.size() == 3){
                                priorityList += 'Client Priorities: \r\n- ' + writePriority[0].Priority_Notes__c;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[1].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[2].Priority_Notes__c ;
                }
                if(writePriority.size() >= 4){
                                priorityList += 'Client Priorities: \r\n- ' + writePriority[0].Priority_Notes__c;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[1].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[2].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[3].Priority_Notes__c ;
                }
                if(writePriority.size() >= 5){
                                priorityList += 'Client Priorities: \r\n- ' + writePriority[0].Priority_Notes__c;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[1].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[2].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[3].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[4].Priority_Notes__c ;
                }
                if(writePriority.size() >= 6){
                                priorityList += 'Client Priorities: \r\n- ' + writePriority[0].Priority_Notes__c;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[1].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[2].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[3].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[4].Priority_Notes__c ;
                                priorityList += '\r\n';
                                priorityList += '- ' + writePriority[5].Priority_Notes__c ;
                }

 

It prints text out too the client priorities field like this:

 

Client Priorities:

- A Priority

- Another Priority

- Foo Foo Foo

 

How could I get this to work in a loop to handle more than 6 (what I have coded for now) client priorities?

  • September 12, 2012
  • Like
  • 0

Hey everyone, I've got this Apex class that I swear should work:

 

Global class Page1TaskReadyTriggerDate implements Schedulable {
  global void execute (Schedulablecontext SC){
    
    Page1Task__c[] tasksToUpdate = new Page1Task__c[]{};
    
  date myDate = system.today();
  
  Page1Task__c[] readyTasks = ([SELECT ID, Status__c FROM Page1Task__c 
                WHERE Ready_Trigger_Date__c != NULL
                AND Ready_Trigger_Date__c <= :myDate
                AND Status__c = '1) Not Started']);
          
  for (Page1Task__c rt : readyTasks){
    if (rt.Status__c != null){
    rt.Status__c = '2) Ready';
    tasksToUpdate.add(rt);      
    }
  }
  
  
  update tasksToUpdate;
  
  }
}

 

When I use the baked-in apex scheduler in Salesforce, it will run on the day I set it - but fails on subsequent days. For instance, I set it to run each day at 6am. It will run that day at 6am and set all of my fields accordingly. It fails on subsequent days. Is there something I'm missing or should this be rewritten?

 

Edit: It actually only runs the day the class was generated. It's not getting the system date on subsequent days, Creating a second scheduled apex job results in nothing, but rebuilding the class and scheduling works fine.

  • August 06, 2012
  • Like
  • 1