• V100
  • NEWBIE
  • 55 Points
  • Member since 2010

  • Chatter
    Feed
  • 2
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 37
    Questions
  • 27
    Replies

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 page that will display a basket summary, this basket will be used on several pages showing different results based on a variable i am trying to send to the controller from the VF page.
VF Page
<apex:variable var="prodType" value="Cars"/>
 <c:sfoProductList />
Component - sfoProductList
<apex:component controller="sfoHCCTRL">
<apex:repeat value="{!BasketProducts}" var="p">
    {!p.Product_Name__c}</br>
</apex:repeat> 
</apex:component>/>
Controller
public String prodType{get; set;}    

public List<Order_Product__c> getBasketProducts() {
        List<Order_Product__c> prodList = [SELECT ID, Product_Name__c, Type__c FROM Order_Product__c WHERE Type__c = :prodType];
        return prodList;
    }
The value of prodType is set to Cars on the VF page, and is sent to the component ok. When the controller returns the list the value is blank.

I have seen many solutions showing parameters being passed but that only seems to work as part of a submit, not on a page render. Is it possible to do it in this way I am trying?
 
  • August 18, 2015
  • Like
  • 0
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?
  • February 24, 2014
  • Like
  • 0
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?
  • February 19, 2014
  • Like
  • 0
The screen allows the user to loop through adding a product from a dropdown list.
The list is populated via a dynamic choice that populates with 10 products.
Each time a product is added i wanted to remove that product from the dropdown. I did this by using an assighnment and populating a variable that was then used in the filter for the dynamic choice. This works fine the first iteration, however when the next product is selected the variable no longer works in the filter.
Have tried to format the variable using commas, stovepipe and Or as the sepearator but none seems to work.
Is there a way to filter on multiple variables (as per normal SOQL) in a single line of the filter. as below
 User-added image
  • January 06, 2014
  • Like
  • 1

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.

 

  • December 12, 2013
  • Like
  • 0

Looking for some help creating a call out to produce the following xml

<System_LogIn  xmlns="http://www.TargetURL.co.uk"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation="http://www.TargetURL.co.uk http://www.TargetURL.co.uk/WebServices/API/Schemas/invoices/System_LogIn.xsd">
    <Header>
        <MessageType>Request</MessageType>
        <TestMode>false</TestMode>
        <SubmissionNumber>00000001</SubmissionNumber>
        <Authentication>
            <AccNumber>123456</AccNumber>
            <MD5Value>7dd259dea3393880406d292e3f6f5830</MD5Value>
        </Authentication>
    </Header>
    <Body>
        <LandingPage>
          <Dashboard>true</Dashboard>
        </LandingPage>
      <ClientID>106476</ClientID>
    </Body>
</System_LogIn>

 have been trying to use with the above as the body

    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://www.TargetURL.co.uk/');
    req.setMethod('GET');
    req.setBody(body);

    Http http = new Http();
    HttpResponse res = http.send(req);

 

This is just returning the homepage rather than the API call. I have added www.TargetURL.co.uk to thr Remote Site also.

Any help much appreciated as this is not an area i know much about

 

  • January 29, 2013
  • Like
  • 0

I am trying to distinguish between Chatter Free and Chatter External in Apex.

The best i can get is CSN only from the usertype filed. Is there a way to differentiate them?

 

User case is writing apex to add chatter users into a group but the External users fail as they cannot see that group?

  • January 28, 2013
  • Like
  • 0

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

  • January 17, 2013
  • Like
  • 0

From reading the guides and these discussion it seems the way to create an extension is to install the base package in a DE then create the extension by referencing it.

 

The problem that i have when doing this is that i cannot then change any of the VF pages to add the new functionality into, is there a way around this. I have a VF page with a menu of item and i want to add the new feature into that menu.

  • January 14, 2013
  • Like
  • 0

i have created an uninstall script that looks for any scheduled jobs and then deletes them however it does not seem to be getting called as the uninstall fails as the classes have been scheduled.

 

I know the info says you cannot create scheduled jobs via the install/uninstall scripts but does not excluded removing them.

Anyone know if this is possible or not? If possible then is my code incorrect?

The custom_setting contains the scheduled job Ids and is populated correctly.

global class V100zUnInstall implements UnInstallHandler {
    global void onUnInstall(UnInstallContext context) {
    customer_setting__c b = customer_setting__c.getOrgDefaults();
    try{
        if (b.zSchJobMaster__c != '' && b.zSchJobMaster__c != null){
            system.abortJob(b.zSchJobMaster__c);
        }
    } catch (Exception e){
        // let it go b/c the job isn't scheduled
    }  
}  
}

 

 

 

  • January 12, 2013
  • Like
  • 0

I have a visualforce page that is populated with data froma record.

I want to enable the user to view the field, update it and save.

This is the VF:

        <apex:repeat value="{!Config}" var="uD">
            Users will be automatically deactivated <strong><apex:outputText value="{!uD.Deactivate_After__c}"/></strong> days after the last login.<br/>
            Set a new value in days&nbsp; <apex:inputText id="origDays" value="{!uD.Deactivate_After__c}" style="width:27px;"/>&nbsp;&nbsp;
            <apex:commandButton value="Set" action="{!adduserDays}">
                <apex:param id="chgDays" name="newParam" value="{!uD.Deactivate_After__c}" assignTo="{!newDays}"/>
            </apex:commandButton>
        </apex:repeat>   

 The controller:

    public Decimal newDays {get;set;}    
    
    public PageReference addUserDays() {
        
        List<V100_Control__c> userRec = [SELECT Id, Frequency__c, Deactivate_After__c, Time__c FROM V100_Control__c WHERE Id = 'a01d00000077Ayi' LIMIT 1];     
        system.debug('JMM newDays: ' + newDays);
        //userRec[0].Deactivate_After__c = newDays;
        try {
          update userRec;
        } catch (DMLException e) {
          ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Days could not be changed.'));
          return null;
        }
        //ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Rule Created'));
         return null;    
    }

The newdays field is always null.

Can anyone help with how i can allow the user to upadte this field and pass it to the controller. I cannot use a custom controller.

  • January 07, 2013
  • Like
  • 0

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.

 

  • January 03, 2013
  • Like
  • 0

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;
    }

 

  • December 22, 2012
  • Like
  • 0

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.

 

 

  • January 20, 2012
  • Like
  • 0

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?

  • January 18, 2012
  • Like
  • 0

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

  • December 15, 2011
  • Like
  • 0

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.

  • November 21, 2011
  • Like
  • 0

Starting to use related content on our opportunities and trying to find out which fields are searched.

We have created the content with relevant tags to help link it to our opportunities, however we are unsure as to what the "Find Related Content" button uses from the opportunity to find the content.

It seems to be Opp Title but not 100% sure. We would like to understand which field(s) it is and if we can change this, ie to look at the products added to the opp.

Cant find it documented anywhere so any help much appreciated.

  • October 25, 2011
  • Like
  • 0

I am using the code with a customer controller to manage notes and attachments.

 

    <apex:dataTable value="{!PostNoteList}" var="FbkAtt" width="100%" >
        <apex:column >
             <apex:outputLink target="_top" value="{!URLFOR($Action.Note.Edit,FbkAtt.id)}" style="font-weight: bold;">Edit</apex:outputLink> |&nbsp; 
        </apex:column>
   </apex:dataTable>  

 and i get the error: Field $Action.Note.Edit does not exist. Check spelling.

 

Curiously it works for attachment downloads

 

{!URLFOR($Action.Attachment.Download,FbkAtt.id)}

but not Edit or Delete

 

Any help much appreciated.

 

 

  • January 07, 2011
  • Like
  • 0

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;
}
 
}

 

 

  • November 26, 2010
  • Like
  • 0
The screen allows the user to loop through adding a product from a dropdown list.
The list is populated via a dynamic choice that populates with 10 products.
Each time a product is added i wanted to remove that product from the dropdown. I did this by using an assighnment and populating a variable that was then used in the filter for the dynamic choice. This works fine the first iteration, however when the next product is selected the variable no longer works in the filter.
Have tried to format the variable using commas, stovepipe and Or as the sepearator but none seems to work.
Is there a way to filter on multiple variables (as per normal SOQL) in a single line of the filter. as below
 User-added image
  • January 06, 2014
  • Like
  • 1
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?
  • February 24, 2014
  • Like
  • 0
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?
  • February 19, 2014
  • Like
  • 0

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.

 

  • December 12, 2013
  • Like
  • 0

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

  • January 17, 2013
  • Like
  • 0

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.

 

  • January 03, 2013
  • Like
  • 0

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;
    }

 

  • December 22, 2012
  • Like
  • 0

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.

 

 

  • January 20, 2012
  • Like
  • 0

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?

  • January 18, 2012
  • Like
  • 0

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

  • December 15, 2011
  • Like
  • 0

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.

  • November 21, 2011
  • Like
  • 0

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;
}
 
}

 

 

  • November 26, 2010
  • Like
  • 0

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.

 

  • November 18, 2010
  • Like
  • 0