• Tyler McCarty
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 15
    Replies
So the requirement is to build a way for users to be able to schedule emails to go out at certain times. So what I have done is built a custom object called EmailScheduler__c and gave it fields such as Recipients__c, Time__c, Subject__c, Body__c, FileName__c, ClassName__c, etc. I have then made a trigger that will run after inserting a new record of EmailScheduler__c and it will grab the information for that new object. 

Where I'm stuck at is how do I setup the scheduler class from the trigger. I know I can setup a dynamic scheduler and a dynamic emailGenerator class but how do I set that up to run, and when the user deletes a record would it delete the schedule on the backend?
Hello, Im on the last part of this assignment and can't seem to find a way to get pagination to work with this table. I have a table that is filtered with a dropdown list. When i choose a dropdown selection the correct information will display and pagination will be accurate. But when I go to choose a different dropdown selection nothing happens.
I've posted the relevant code below. Everything else works fine. 

<apex:inputfield value="{!filterAccount.Type}" label="Account Type"> 

 <apex:actionSupport event="onchange" action="{!updateRecordList}" rerender="pwPanel"/>      
           
               </apex:inputfield>
   <br/><br/><br/>
            <!-----------Table---------->                  
<apex:outputPanel rendered="{!recordList.size > 0}" id="account_filter">

      <apex:pageBlockSection >

<apex:pageBlockTable value="{!Accounts}" var="rl" id="record_list">


    //pagination  
    public ApexPages.StandardSetController setcon 
    {
        get
        {
            if(setCon == null)
            {

                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                    [Select Name, Type, Website, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry  
                    from Account where type =:filterAccount.type Order by Name ASC Limit 10000]));
                setCon.setpageSize(pageSize);
                noOfRecords = setCon.getResultSize();

            }
            return setCon;
        }
        set;
        
    }

    // Initialize setCon and return a list of record    

    public List<Account> getAccounts() {  

       return setCon.getRecords();
    }
    
       //fields returning for table
  public void updateRecordList()
    {
       recordlist = setCon.getrecords();
    }
Hello, Im getting this error when trying to populate a dropdown box with the account types.

System.NullPointerException: Argument 1 cannot be null  Class.AccountTypeController.getAccounts: line 13, column 1

Apparently 'Type' is a reserved word in apex but is also the API name of the Account field, Type. It won't return the field because of this. Any way around this besides changing the API name?

Apex code:
public class AccountTypeController 
{
    public string Account{get; set;}
    public String sortOrder = 'Type';
    
    
    
    public List<SelectOption> getAccounts()
    {
        List<SelectOption> AccountList = new List<SelectOption>();
        for(Account act: [SELECT Name, Type, Website, BillingAddress
                                              FROM Account])
            AccountList.add(new SelectOption(act.Type, act.Type));

        return AccountList;
      
    }
    
   
    
    public void sortByType()
    {
        this.sortOrder = 'Type';
    }

}

vf code:
<apex:page controller="AccountTypeController">
  <apex:form >
    <apex:pageBlock title="Accounts">
        <apex:pageBlockSection >
        
            <apex:selectList value="{!Account}" size="1">
                 <apex:selectOption itemLabel="-Select Account Type-" itemValue="-Select-"/>                     
                  <apex:selectOptions value="{!Accounts}"/>
                  <apex:actionSupport event="onchange" reRender="pb" status="actStatusId"> </apex:actionSupport>
            </apex:selectList>
        </apex:pageBlockSection>
    </apex:pageBlock>  
  </apex:form>
</apex:page>
 
So the requirement is to build a way for users to be able to schedule emails to go out at certain times. So what I have done is built a custom object called EmailScheduler__c and gave it fields such as Recipients__c, Time__c, Subject__c, Body__c, FileName__c, ClassName__c, etc. I have then made a trigger that will run after inserting a new record of EmailScheduler__c and it will grab the information for that new object. 

Where I'm stuck at is how do I setup the scheduler class from the trigger. I know I can setup a dynamic scheduler and a dynamic emailGenerator class but how do I set that up to run, and when the user deletes a record would it delete the schedule on the backend?
I am having trouble with a query on contentdocumentlink.
I upload a document to an account. Then I query the contentdocumentlink to get the linkentityid and I get a different id.
Any idea why this is happening. 
Here is the test class and the query.

query from trigger:

list<account> a= new list<account>();
 list<ContentDocumentlink> doc= [select id, LinkedEntityId from contentdocumentlink where contentdocumentid=: newdoc.ContentDocumentId];
      System.debug(doc);
  if(!doc.isempty())
            A= [select name, id from account where id=: doc[0].LinkedEntityId];
      system.debug(a);

This is the test code
@isTest
public class TestNewFileAlert 
{

    public static testmethod void MyUnitTest()
    {
           Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
        User futureUser = new User(firstname = 'Future', lastname = 'User',
                                   alias = 'future', defaultgroupnotificationfrequency = 'N',
                                   digestfrequency = 'N', email = 'test@test.org',
                                   emailencodingkey = 'UTF-8', languagelocalekey='en_US', 
                                   localesidkey='en_US', profileid = p.Id, 
                                   timezonesidkey = 'America/Los_Angeles',
                                   username = 'futureasdasdasuser@test.org',
                                   userpermissionsmarketinguser = false,
                                   userpermissionsofflineuser = false, userroleid= null);
        insert(futureUser);
        System.runAs(futureUser)
        {
            
            Account acct = new Account(Name='TEST_ACCT');
            insert acct;
            system.debug(acct);
            
            ContentVersion contentVersion = new ContentVersion
            (
                Title = 'Penguins',
                PathOnClient = 'Penguins.jpg',
                VersionData = Blob.valueOf('Test Content'),
                IsMajorVersion = true
            );
            insert contentVersion; 
            Test.setCreatedDate(contentVersion.Id, DateTime.now());
            
            List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];
            
            //create ContentDocumentLink  record 
            ContentDocumentLink cdl = New ContentDocumentLink();
            cdl.LinkedEntityId = acct.id;
            cdl.ContentDocumentId = documents[0].Id;
            cdl.shareType = 'V';
            insert cdl;
            Test.setCreatedDate(cdl.Id, DateTime.now());
        }

    }
}
I'm working on my first "real" lightning component, trying to extend what I've learned through a couple Trailhead trails and other Lightning component examples to my own real world component, but I can't figure why my inner component extends beyond the border of my outer component.

My scenario is this, I have a custom object with one or many contacts related to it.  I'm creating a record page component to show Activities related to the contacts who are related to my custom object record. I have an Apex class returning the activity records and my lightning component is showing those records.

The problem occurs with long Subject descriptions, despite my attemp to use slds-truncate.  How do I keep my inner component from extending beyond the border of my outer component?

Here's what I see:
User-added image

Here's my outer component (tasksRelatedToFundList):
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="getActivitiesRelatedToFund" >
    <!-- Handle component initialization in a client-side controller -->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <!-- Dynamically load the list of tasks -->
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="tasks" type="Task[]" />
    <aura:attribute name="taskList" type="Task[]" />
    <aura:attribute name="totalTasks" type="Integer" />
    
    <!-- Page header with a counter that displays total number of tasks -->
    <div class="slds-page-header slds-page-header--object-home">
        <lightning:layout >
            <lightning:layoutItem >
                <lightning:icon iconName="standard:task" />
            </lightning:layoutItem>
            <lightning:layoutItem class="slds-m-left--small">
                <p class="slds-text-title--caps slds-line-height--reset">Activities</p>
                <h1 class="slds-page-header__title slds-p-right--x-small">Related Activities</h1>
            </lightning:layoutItem>
        </lightning:layout>
        
        <lightning:layout >
            <lightning:layoutItem >
                <p class="slds-text-body--small">{!v.totalTasks} Activities</p>
            </lightning:layoutItem>
        </lightning:layout>
        
        <!-- BOXED AREA -->
        <fieldset class="slds-box slds-theme--default slds-container--small">
            <!-- Body with list of tasks -->
            <lightning:layout >
                <lightning:layoutItem padding="horizontal-small" >
                    <!-- Iterate over the list of tasks and display them -->
                    <aura:iteration var="task" items="{!v.tasks}">
                        <c:tasksRelatedToFund task="{!task}"/>
                    </aura:iteration>
                </lightning:layoutItem>
            </lightning:layout>    
        </fieldset>
    </div>
</aura:component>

Here's my inner component (tasksRelatedToFund):
<aura:component implements="flexipage:availableForRecordHome">
    <aura:attribute name="task" type="Task" />
    
    <span class="slds-assistive-text">Email</span>
    <div class="slds-media">
        <div class="slds-media__body">
            <div class="slds-media slds-media--timeline slds-timeline__media--call">
                <div class="slds-media__figure slds-timeline__icon">
                    <div class="slds-icon_container">
                        <lightning:icon iconName="standard:email" size="x-small" alternativeText="email"/>  
                    </div>
                </div>
                <div class="slds-media__body">
                    <p class="slds-truncate" title="{!v.task.Subject}"><a onclick="{!c.goToRecord}">{!v.task.Subject}</a></p>
                    <p class="slds-p-horizontal--none"> <ui:outputDate value="{!v.task.ActivityDate}"/> </p>
                    <p class="slds-truncate">{!v.task.Status}</p>
                    <ul class="slds-list--horizontal slds-wrap">
                        <li class="slds-m-right_large">             
                            <ui:inputTextArea aura:id="comments" value="{!v.task.Description}" rows="5" cols="65" disabled="true" />
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</aura:component>
suppose we choose 10 from picklist the the table should dispaly 10 records and if we choose 20 then the table updates to display 20 records.
Hi all,
I am testing receiving the authentication token for my connected app so i can continue to build a simple consoleapp for salesforce.As a new developer of salesforce, I am having issues with testing Oauth through postman. 
User-added image
I followed this guide here https://blog.mkorman.uk/using-postman-to-explore-salesforce-restful-web-services/ , but to no avail. 
When i click "request token", the salesforce login appears, however when i input my UN and PW i am given an error message reading
"Could not complete OAuth2.0 login"

I've also tried this way, and recieve an invalid_grant error, and have tried every body configuration.
User-added image

Could someone point me in the right direction? I'd appreciate any help/tips. Thanks in advance!
I'm new to Lightning components and am experimenting with my first app displaying a list of records from a custom object (Aircraft_Relationship__c); each record will include fields from two other related objects (master-detail to Aircraft__c and lookup to Account (field is  Account is Aircraft_User__c). The listing of the primary object (Aircraft_Relationship__c) works fine.

For the life of me I cannot figure out why when I launch the app the related fields do not appear; I've reviewed the documentation and from what I understand the dot notation is supposed to work in traversing these relationships (as I'm familiar with in VF).

Any help would be appreciated (am I missing something obvious?)

Hre's Apex controller pulling the related fields:
public with sharing class auraAClisting {

    @AuraEnabled
    public static List<Aircraft_Relationship__c> findAll() {
        return [SELECT id, name,status__c,ownership__c,Aircraft__r.name,aircraft__r.id,New_Used__c,Model__c,Aircraft_User__c,Aircraft_User__r.name,Owner__c,Owner__r.name FROM Aircraft_Relationship__c where status__c = 'Delivered' LIMIT 50];
    }
}
Here's the client-side controller:
({
    doInit : function(component, event) {
        var action = component.get("c.findAll");
        action.setCallback(this, function(a) {
            component.set("v.acr", a.getReturnValue());
        });
        $A.enqueueAction(action);
    }
})
And the component:
<aura:component controller="auraAClisting">
    <aura:attribute name="acr" type="Aircraft_Relationship__c[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <ul class="list-group">
        <aura:iteration items="{!v.acr}" var="ac">
            <li class="list-group-item">
                <a href="{! '/' + ac.Id }">
                    <p>{!ac.Name}</p>             <-- DISPLAYS VALUE in APP
                    <p>{!ac.Aircraft__c}</p>      <-- DISPLAYS VALUE in APP
                    <p>{!ac.Aircraft__r.id}</p>   <-- NOTHING APPEARS in APP
                </a>
            </li>
        </aura:iteration>
    </ul>
</aura:component>
Hi all,
I have one input field of type picklisk in visualforce page,now if i select any picklist value then i want records to display releated to that picklist value with pagenation, if result having more than 10 records.

Note:I dont want button to click for getting the result,It should be onchange using <apex:actionsupport> tag or any other tag.

Thanks.
Hello, 

I am working on displaying a list of opportunities in a table on one of my vf pages, and would like the table rows to alternate in color to make it easier to read. 

I was using a pageBlockTable before, and was able to accomplish this easily by defining a style: 
 
<style>
             .odd {
              background-color: #A4A4A4;
                }
             .even {
             background-color: #E6E6E6;
                }
            </style>

and then referencing thaty style like so: 
 
<apex:pageblocktable value="{!listOfLive}" var="lv" rowclasses="even,odd">

Unfortunatley, I have had to move away from using a pageBlockTable to using apex:repeat - and I can not get this trick to work. 

Here is my new table: 
 
<table cellpadding="5" style="border-collapse: collapse" width="100%">
                <tr>
                              <td style="background-color: #C6D4D4; color: #040404">
                        <b>Opportunity Name</b>
                    </td>
                    <td style="background-color: #C6D4D4; color: #040404">
                        <b>Company Name</b>
                    </td>
                    <td style="background-color: #C6D4D4; color: #040404">
                        <b>Vertical</b>
                    <td style="background-color: #C6D4D4; color: #040404">
                        <b>Weeks Live</b>
                    </td>
                    
                    
                    </td>
                     <td style="background-color: #C6D4D4; color: #040404">
                        <b>Days Idle</b>
                    </td>
                                 
                    <td style="background-color: #C6D4D4; color: #040404">
                        <b>Contract Sent</b>
                    </td>
        <td style="background-color: #C6D4D4; color: #040404">
                        <b>Next Step</b>
                    </td>
                    <td style="background-color: #C6D4D4; color: #040404">
                        <b>Lead Source</b>
                    </td>
                    <td style="background-color: #C6D4D4; color: #040404">
                        <b>Probability %</b>
                    </td>
                    <td style="background-color: #C6D4D4; color: #040404">
                        <b>Owner</b>
                    </td>
                    <td style="background-color: #C6D4D4; color: #040404">
                        <b>Revenue Last Week</b>
                    </td>
                    <td style="background-color: #C6D4D4; color: #040404">
                        <b>Revenue Last 30 Days</b>
                    </td>
                </tr>
                <apex:repeat value="{!listOfLive}" var="lv">
                                                                         <tr>
                                  
                            <td>
                                {!lv.name}
                            </td>  
                              <td>
                                {!lv.Company_Name__c}
                            </td> 
                                <td>
                                {!lv.Vertical__c}
                            </td>
                            <td>
                                {!lv.Weeks_Live__c}
                            </td>
                           
                            <td>
                                {!lv.Days_Since_Last_Modified__c}
                            </td>
                            <td>
                                {!lv.Contract_SENT__c}
                            </td>
                            
                            <td>
                                {!lv.NextStep} 
                            </td>
                
                             <td>
                                {!lv.LeadSource}
                            </td>
                             <td>
                                {!lv.Probability}
                            </td>
                            <td>
                                {!lv.Owner_Name__c}
                            </td>
                            <td>
                                {!lv.Spend_Last_Week__c}
                            </td>
                            <td>
                                {!lv.Spend_Last_30_Days__c}
                            </td>
                        </tr>
                                                          </apex:repeat>
            </table>

What is the best way to accomplish alternating row colors using this method?

Thanks in advance!

John
Hello All,
            I have written code in apex and visualforce  to saving the Geo location in my detail page. While doing this an error is coming on this particular line.It throw an error on my particular this code:
 
newSupply.GeoLocation__Latitude__s=decimal.valueOf(latitude);
newSupply.GeoLocation__Longitude__s=decimal.valueOf(longitude);
"Visualforce Error System.Type Exception: Invalid decimal".
 
  • March 30, 2015
  • Like
  • 0

Hi All,

 

I need to send an email with a PDF attachment.  I have developed a normal visualforce page (didn't render as PDF). And then using apex code, am getting the body of it, and sending it as PDF attachment.

 

I am receving the email with the PDF attachment, but when I try to open the PDF, it isn't opening.  It gives the following decode error - "Adobe reader cannot open the PDF because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)"

 

Below is the Apex class that is taking the body of vf page and making it a PDF attachment.  Please let me know if I am missing anything.  Thanks.

 

global class CustomersPDF_SendEmail implements Schedulable {

    global void execute(SchedulableContext sc) {    
        
        PageReference pdf = Page.CustomersPDF;
        pdf.getParameters().put('id','001O000000ECvg4');
     
        Blob body;
     
        try {
          body = pdf.getContent();
        } 
        catch (VisualforceException e) {
          body = Blob.valueOf('Some Text');
        }
     
        Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
        attach.setContentType('application/pdf');
        attach.setFileName('KeyCustomers.pdf');
        attach.setInline(false);
        attach.Body = body;
     
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setUseSignature(false);
        mail.setToAddresses(new String[] {'abc@gmail.com'});
        mail.setSubject('Customers PDF - Demo');
        mail.setHtmlBody('Check the attachment!');
        mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach }); 
     
        // Send the email
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });               
    
    }
}

 

 

Hi All

 

I am getting this error when i write the ontabenter function on the tab.

<apex:tab label="Billing" name="billName" id="tabBilling" ontabenter="callCon('Billing');" style="background-color:white;"  rendered="{!IF(strSearchlevel='1',false,true)}">

<apex:outputText value="{!IF(lstDisputeInfo.size>0,'Yes','No')}" label="Account In Dispute" />

 <apex:actionFunction name="callCon" oncomplete="callCon1();">
                        <apex:param name="firstParam" value="" assignTo="{!Tabselected}"/>
                        </apex:actionFunction>

 

Below is the error. when i remove the ontabenter action it is not throwing the error, but i need to write the ontabenter action in order to capture the clicks on the tab. Please let me know your taughts on this.Appreciate your time and help.

 

The value 'null' is not valid for operator '>'

Error is in expression '{!IF(lstDisputeInfo.size>0,'Yes','No')}' in component <apex:outputText> in page summarypage

 

Hi guys,

 

today I received a strange error message after trying to change the controller in the visualforce editor

 

Error: java.sql.SQLException: ORA-00001: unique constraint (CORE.AKAPEX_CLASS) violated ORA-06512: at "HAPPY.CAPEX", line 505 ORA-06512: at line 1 : {call cApex.update_class(?,?,?,?,?,?,?,?,?,?,?,?)})} 

 

 

and remebered about a Blog article on Wes's Blog about strange error messages where I found this

 

  

Error: java.sql.SQLException: ORA-00001: unique constraint (CORE.AKAPEX_CLASS) violated ORA-06512: at “SNEEZY.CAPEX”, line 505 ORA-06512: at line 1 : {call cApex.update_class(?,?,?,?,?,?,?,?,?,?,?,?)})} 

.

 

 

Looks like some SF guys are huge fans 'Snow White and the Seven Dwarfs' .

 

 

So the big question is, where are the others and of course where's Snow White?

 

 

 

I recently learned that classes in apex inherit a toString method which outputs the instantiated object to a string (much like serialization does in some languages). I cannot seem to find any documentation on this inherited method can someone point me in the right direction? 

 

Also once its in a string how can then convert that string to an object again?

 

Thanks 

Message Edited by jadent on 09-02-2009 11:52 AM
  • September 02, 2009
  • Like
  • 0