• V100
  • NEWBIE
  • 55 Points
  • Member since 2010

  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 37
    Questions
  • 27
    Replies
I have seen some discussion on these problems and some solutions too, however i cannot find on the addresses my issue.
I am trying to do the following
<ol>
<li>Item 1</li>
<apex:outputPanel rendered="IF Statement">
     <li>Optional item a</li>
</apex:outputPanel>
<li>Item 2</li>
</ol>

This renders on the PDF as:
     Item 1
     Optional item a
     Item 2
Whereas in html:
     1. Item 1 
     2. Optional item a
     3. Item 2

I know there is incomplete support for the pdf rendering engine but does anyone know of a workaround for this?
I am setting the following variable to be reused in calculations
Below returns the error Error: Unknown property 'Cloud_Voice__cStandardController.monthly'
<apex:variable value="{!12}" var="term"/>
<apex:variable value="{!ROUND((Cloud_Voice__c.Total_Selected_Finance__c*(r.X12m__c/1000)/term),2)}" var="monthly"/>
<apex:variable value="{!monthly*term}" var="total"/>

Changing the term back to 12 works fine:
<apex:variable value="{!12}" var="term"/>
<apex:variable value="{!ROUND((Cloud_Voice__c.Total_Selected_Finance__c*(r.X12m__c/1000)/12),2)}" var="monthly"/>
<apex:variable value="{!monthly*term}" var="total"/>

Can't figure out why it does not work, any help?

I am looking to display child of a child records within a VF page using a standard controller.

<apex:repeat value="{!Parent__c.ChildofParent__r}" var="cl">  

This works fine to display the child records. What i then need to do is display the child records of that child.

I tried below within the above repeat.

<apex:repeat value="{!Parent__c.ChildofParent__r.ChildofChild__r}" var="c2">  

and then various version of this to try to display the records.

 

Is this possible without a custom controller and if so can anyone help with the syntax.

 

Have a visualforce page with a multi select picklist.

<apex:selectList value="{!selectedGroups}" size="10" multiselect="true">

 

I then need to loop over the comma delimited output selectedGroups in apex but i am not sure how to go about this.

Any suggestions?

Thanks

I am developing an app that has classes interacting with some stanrd objects; User ofr instance.

Typically when writing the test classes for this type i would create a user within the test to test against, as per SF design principals.

 

I am not sure how to tackle this from an managed app point of view as i could try to create a user, however the host org has a custom field that is required for that record.

Will that fail my test class and does that matter from the host org's point of view.

Will it be ignore in the managed app, or not matter somehow.

 

Thanks for any help.

 

Looking to use a VF page to display as a select list all profiles on the org and allow them to be selected into a custom object.

The display of profile all works fine, however when i try to add the value:

jProfile, it returns nothing.

selectedProfilesit returns Null.

 

Any suggestions as to where i am going wrong? Thanks

 

VF

    <apex:pageBlock id="block">
    <apex:pageMessages />          
        <apex:pageBlockSection title="Add Rule" id="section1">
<apex:pageBlockSectionItem id="selProfile"> <apex:outputLabel value="Profile"/> <apex:selectList value="{!selectedProfiles}" size="1" id="ProfilesSelect"> <apex:selectOptions value="{!Profiles}"/> </apex:selectList> </apex:pageBlockSectionItem>

        <apex:commandButton value="Create New Rule" action="{!addRule}" reRender="block" immediate="true">
        <apex:param name="jmProfile" value="{!selectedProfiles}" assignTo="{!jProfile}"/>
        </apex:commandButton>

 Controller

    private List<SelectOption> Profiles;
    
    public List<String> selectedProfiles {get; set;}
    public String jProfile {get;set;} 
    
    public List<SelectOption> getProfiles() {
      Profiles = new List<SelectOption>();
      Profiles.add(new SelectOption('None', 'None'));
      for (Profile rt : [Select Id, Name 
                            From Profile 
                            Order By Name ASC]) {                 
        Profiles.add(new SelectOption(rt.Name, rt.Name));
      }
      return Profiles;
    }

 

I have a package which creates a scheduled job using a post-install script, and saves the id in a custom settings entry. I am trying to create the equivalent uninstall script, but not having much success. The class and associated tests all perform normally when I run them in the IDE. When I run them from the Web UI however, the abortJob call doesn't delete the job and my tests fail. If I comment out the tests and do an actual install and uninstall of the package, the scheduled job is not deleted.

 

Any idea why this would happen? I know that the documentation indicates that uninstall scripts cannot schedule new jobs, call @future methods, etc, but it doesn't mention anything about deleting existing jobs. The same code, when part of a controller for a settings page, worked fine. Maybe I am misintepreting when the uninstall script actually runs, meaning the only option is for an admin to delete the scheduled job manually, before trying to uninstall the package?

 

Code snippet:

...

if(settings != null) {

  try {

    system.debug('Removing scheduled job with id: ' + settings.scheduled_job_id__c);

    System.abortJob(settings.scheduled_job_id__c);

  } catch (Exception e) {

    system.debug('Error removing scheduled job: ' + e.getMessage());

  }

  delete settings;

}

...

I have created a visualforce page on the lead object that is populated with the contacts for that account, this is to allow the user to simply select the contact they want

<apex:page standardController="Lead" extensions="LeadContactCtrl">

<apex:pageBlock >
<apex:form id="SelectConForm">
<apex:pageBlockTable value="{!Contacts}" var="c">
    <apex:column value="{!c.Name}"/>
    <apex:column value="{!c.Phone}"/>
    <apex:column value="{!c.Account_Manager_Contact_Flag__c}"/>
    <apex:column value="{!c.Key_Decision_Maker__c}"/>
    <apex:column value="{!c.Last_Updated_Date__c}"/> 
    <apex:column>  
        <apex:inputField id="Contact__c" value="{!c.Id}"/>  
    </apex:column>
    <apex:column>  
        <apex:commandButton value="Select" action="{!Save}"/>
    </apex:column>
</apex:pageBlockTable>
</apex:form>
</apex:pageBlock>
        

</apex:page>

 When the clickig save the controller tries to select that contact into the lead and save the lead:

public PageReference save()
{
    List<Lead> l = [SELECT Contact__c FROM Lead WHERE Id = :LeadId LIMIT 1];
    system.debug('JMM Lead: ');
    l[0].Contact__c= WHATSHOULDGOHERE;//'003P000000XjK71IAF';
    update l;
    
    return new PageReference('/apex/LeadContact?'+LeadId+'&refreshPage=true');
}

 I can get this work when i hard code a contact but cannot get to use the one selected in the save from the visualforce.

I have tried in the WHATSHOULDGOHERE i have tried eveything i can think off and but i'm sure i must be missing something simple.

Any help much appreciated.

 

 

We have a requirment to allow Dashboard elements to posted into Chatter feeds but only into a user or group feed, not into the dashboard itself.

I have written the code

    for (FeedItem f : trigger.new){          
        fParent = f.ParentID;
        if (fParent != null && fParent.startsWith('01Z')){
            f.addError('You can only comment on existing posts in this group.') ; 
        }
    }    

This prevents the post into the dashboard but instead of returning the friendly error message it shows a general error in a alert window:

"An error occurred while processing your request. The salesforce.com support team has been notified of the problem. If you have additional information that may helpful for reproducing or correcting the error, please contact Salesforce Support at support@salesforce.com. Please indicate the URL of the page you requested, any error ID shown below, and any related information. We apologize for the inconvenience. Thank you again for your patience and assistance. And thanks for using salesforce.com!"

Is there a way around this?

I am looking to execute some script (to add a user to a Chatter Group) when a user record is updated to any one of 10 profiles.

 

        if (u.Profile.Name.startsWith('BTLB') ){
            CollaborationGroupMember NewMember = new CollaborationGroupMember(MemberId = u.Id, CollaborationGroupId = '00ds0000001U9Ot');
            AddMembers.add(NewMember);
            }   

 This compile ok, however when i try to edit the user record I get:

Apex trigger NewUserEntries caused an unexpected exception, contact your administrator: NewUserEntries: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.NewUserEntries: line 57, column 13

Line 57 is the if statement.

 

Is what i am trying to do possible?

I know i use profileId or a SOQL but don't really want to list the 10 possible ID and keep them updated whenever a new profiles is added.

Any help much appreciate.d

I amtrying to write a test class for Contacts code with ReportsTo completed

The code creates a single contact (ignore the test factory piece) and then creates a second contact reporting to the first.

The first and second contacts are created, but the ReportsTo is null on the second.

Contact con1 = Test_Factory.CreateContact();
con1.AccountId = tt.testADP.Customer__c;
con1.Contact_Post_Code__c = 'WR5 3RL';
insert con1;
Contact con2 = Test_Factory.CreateContact();
con2.AccountId = tt.testADP.Customer__c;
con2.Contact_Post_Code__c = 'WR5 3RL';
con2.ReportsTo = con1;

 I have tried the variationbut that no longer works

con2.ReportsToId = con1.Id;

There was a similar issue raised:

http://boards.developerforce.com/t5/Apex-Code-Development/Trigger-not-updating-Contact-RelatedTo-field-with-no-reason-why/m-p/209732/highlight/true#M37146

That shows a work around, however this is for a test class so cannot really work around.

Are there problems writing to this field via Apex or have a i got something wrong.

Any help much appreciated.

Hi folks.  My HR department would like me to disable the edit icon (the yellow pencil) on each users' Chatter profile page  (specifically on the "Contact" information, not necessarily for the "About Me" section).  Only system administrators (or users with a particular profile) would be able to see the pencil, and edit the information in that area.

 

Has anyone done this before?  Any ideas on how to do it?  JavaScript that's read when the page loads, perhaps?

 

Thanks!

I have a test case as below

 

@isTest

private class Test_FeedbackController{
    static testMethod void runPositiveTestCases() {
        // test general feebdack      
        Feedback__c fbk = new Feedback__c (Feedback_Title__c = 'Test Feedback', Requested_Priority__c = 'low', Type__c = 'Issue',Description__c = 'Testing' ); 
        Database.Saveresult fbkResult = Database.insert(fbk);    
        //additional validation on CR
        Feedback__c fbk1 = new Feedback__c (Feedback_Title__c = 'Test Feedback', Requested_Priority__c = 'low', Type__c = 'Change Request',Description__c = 'Testing',Reason__c = 'Teast Reason' ); 
        Database.Saveresult fbkResult1 = Database.insert(fbk1);   
        // test attachment
        Note note= new Note (OwnerId = UserInfo.getUserId(), ParentId = fbk.ID, isPrivate = false, body = 'Blob', title = 'test' ); 
        Database.Saveresult noteResult = Database.insert(note);           
    }    
}

When i run the test indiviually it returns 100% code coverage. However when i run all test it says 0% code coverage for the FeedbackController.

Why would it test individually at 100% and then zero on run all tests?

 

The code for the controller is:

 

public with sharing class FeedbackController {
public List<Feedback__c> searchResults {get;set;}
public string CheckStatus = null;
    public FeedbackController(ApexPages.StandardController controller) {

    }

public string FeedbackID = System.currentPageReference().getParameters().get('id');
 
      
public Attachment attachment {
  get {
      if (attachment == null)
      attachment = new Attachment();
      return attachment;
    }
  set;
  }
  
public Note note {
  get {
      if (note == null)
        note = new Note();
      return note ;
    }
  set;
  }

public List<Attachment> getAtt() {    
      return [SELECT ID, Name, Description, Body, BodyLength, CreatedByID, CreatedBy.Name, CreatedDate FROM Attachment WHERE ParentID = :FeedbackID  ORDER BY CreatedDate DESC ];
  }

public List<Note> getNoteList() {
      return [SELECT ID, Title, Body, CreatedByID, CreatedBy.Name, CreatedDate, IsPrivate FROM Note WHERE ParentID = :FeedbackID ORDER BY CreatedDate DESC];
  }
 
public PageReference CATyes() {
// CAT Sign off using a note
    note.OwnerId = UserInfo.getUserId();
    note.ParentId = FeedbackID ; // the record the file is attached to
    //note.IsPrivate = false;
    note.Title= 'CAT Sign Off';
    note.Body= 'CAT Passed. ' + note.body;
           
    try {
      insert Note;
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      note= new Note(); 
    }

    try {
        Feedback__c fbkStatus = [SELECT ID, Status__c FROM Feedback__c WHERE ID = :FeedbackID LIMIT 1];
        fbkStatus.Status__c = 'Passed CAT';

        update fbkStatus;
    } Catch (DMLException e) {
      ApexPages.addMessages(e);
      return null;
    }

    return new PageReference('/'+FeedbackID );

}


public PageReference CATno() {
    note.OwnerId = UserInfo.getUserId();
    note.ParentId = FeedbackID ; // the record the file is attached to
    //note.IsPrivate = false;
    note.Title= 'CAT Failed';
    if (note.Body == '') {
        note.adderror('Comments must be added for Rejecting CAT'); 
        return null;
    }
    else {
    note.Body= 'CAT FAILED. Rejection Comments: ' + note.body;
    }
    
    try {
      insert Note;
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      note= new Note(); 
    }

    try {
        Feedback__c fbkStatus = [SELECT ID, Status__c FROM Feedback__c WHERE ID = :FeedbackID LIMIT 1];
        fbkStatus.Status__c = 'Failed CAT';

        update fbkStatus;
    } Catch (DMLException e) {
      ApexPages.addMessages(e);
      return null;
    }
    
     
    return new PageReference('/'+FeedbackID );
}

public PageReference CATcancel() {
    return new PageReference('/'+FeedbackID );
}

public PageReference upload() {
    attachment.OwnerId = UserInfo.getUserId();
    attachment.ParentId = FeedbackID ; // the record the file is attached to
    attachment.IsPrivate = false;
    if (attachment.Description == '') {
        attachment.adderror('Please enter a Title for the attachment'); 
        return null;
    }
    else {
    note.Body= 'CAT FAILED. Rejection Comments: ' + note.body;
    } 
    try {
      insert attachment;
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      attachment = new Attachment(); 
      attachment.body  = null;
    }
 
    //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
    
  }
  
public PageReference addNote() {
    note.OwnerId = UserInfo.getUserId();
    note.ParentId = FeedbackID ; // the record the file is attached to
    //note.IsPrivate = false;
    note.Title= 'Feedback Note';
 
    try {
      insert Note;
    } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
      return null;
    } finally {
      note= new Note(); 
    }
 
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
    return null;
}
 
}

 

 

I have created the following BulkApex to count the number of accounts owned by users.

 

This works, however it does not work for our larger account owners where it hits governor limits. To combat this i have put in a LIMIT 5000, however we have many owners with more than 5k accounts and i would like to get an accurate count.

 

        List<User> users = new List<User>();
        Set<ID> UserIDs = new Set<ID>();
        for (Sobject c : scope) {
                UserIDs.add(c.Id);
        }       
        Map<ID, User> usersWithAccounts = new Map<ID, User>([select Id, Accounts_Owned__c  FROM User WHERE  Id in :UserIDs]);
        Map<ID, Account> acctsCount = new Map<ID, Account>([select Id, OwnerID FROM Account WHERE OwnerId in :UserIDs LIMIT 5000]);
        
        for (User acct : usersWithAccounts.values()) {
            Set<ID> conIds = new Set<ID>();
            for (Account con : acctsCount.values()) {
                if (con.OwnerID == acct.Id)
                    conIds.add(con.Id);
            }
            acct.Accounts_Owned__c = conIds.size();        
        }
        update usersWithAccounts.values();

    }
 global void finish(Database.BatchableContext BC){
    }
}

I have tried to do variation on 

Map<ID, Account> acctsCount = new Map<ID, Account>([select Id, OwnerID FROM Account WHERE OwnerId in :UserIDs LIMIT 5000]);

 

To use COUNT(), COUNT(ID) instead of the size so it will run for all users.

 

I have taken this script from another similar process for counting contacts on the account, so that is the basis for the way it has been contstructed, I am very new to Apex.

Any hlep much appreciated.