• ab84
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 15
    Replies
Hi all,

I've done some basic classes but I've never written a batch class before.  

What I need is a class that I can schedule daily.  This will go through all accounts.  It will check the service contracts on the account.  If there is an active contract for Product A (a record type) then the "Product_A_Valid__c" box on the account object can be checked.  If there is no active product A contract then it should be unchecked.

Can anyone help me with this?
  • December 16, 2016
  • Like
  • 0
I'm replacing the ideas page with a custom VF page.  I have everything working apart from the vote up and down buttons.

Has anyone else done this and able to assist in getting the buttons working?  I have a look at this thread (https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AsPHIA0)with the same question but there was no resolution.
  • May 30, 2015
  • Like
  • 0
I have a visual force page that displays all ideas in a page block table.  I want to add a link to the side of the table that reads “Most discussed”.  When clicking on it, the ideas displayed will be sorted by the number of comments.  

Likewise, I want another link that says “popular” and when clicked it’ll sort by the number of votes.  

I’ve had a look at the below:

https://help.salesforce.com/apex/HTViewSolution?id=000171025&language=en_US

This kind of covers what I’m looking to do however I’m not sure how to implement the sort options.  My page uses a standard controller with an extension.

Can anyone suggest how I would code the sort options in the apex class and then implement in visual force?
  • May 27, 2015
  • Like
  • 0
I have a search box that fills the page with search results.  I need this to show the results in a different page.  How would I do this?

My controller extension is below:
public with sharing class ideaExtension {  

   public list <idea> i1 {get;set;}  
   public string searchstring {get;set;}  
   public ApexPages.StandardSetController stdCntrlr {get; set;}
   
  
   public ideaExtension(ApexPages.StandardSetController controller) {  stdCntrlr = controller; }  
  
   public void search(){  
     string searchquery='select title,id from idea where title like \'%'+searchstring+'%\' Limit 20';  
     i1= Database.query(searchquery);  
   }  
   public void clear(){  
   i1.clear();  
   }
My visualforce is:
<apex:form >  
 <apex:inputText value="{!searchstring}" label="Input"/>   
  <apex:commandButton value="Search records" action="{!executeSearch}"/>  
   <apex:pageBlock title="Search Result">  
    <apex:pageblockTable value="{!i1}" var="i">  
     <apex:column >  
      <apex:outputlink value="/{!i.id}">{!i.Title}</apex:outputlink>  
     </apex:column>  
     <apex:column value="{!i.id}"/>  
    </apex:pageBlockTable>     
   </apex:pageBlock>   
  </apex:form>
  • May 27, 2015
  • Like
  • 0
I have a text field in salesforce that holds a piece of HTML code.  The code is very basic:

<i class="icon-ok">

How can I update my visualforce page to run the html and display the ok icon rather than display the code?
 
  • May 05, 2015
  • Like
  • 0
I have a custom object.  It has fields for region, status and created date and there are 5 records created every day.  I want a VF page that displays this as a matrix.  

Along the top I want days, and on the side region.  The cell should display the status field.

Example:

                     apr 24   apr 25     apr 26    apr 27    apr 28
UK                Yes       No          Yes       No         Yes
US                Yes       No          Yes       No         Yes
Europe          Yes       No          Yes       No         Yes

Is there an easy way to create this kind of a matrix in VF? 
  • April 24, 2015
  • Like
  • 0
I've written a custom VF page for the Document object.  I can do a basic search field that searches the main fields, however the search field in the standard document object page will also search the content of the attachments.  

How would I reproduce this search in my VF page?
  • February 23, 2015
  • Like
  • 0
Hi,

I've created a custom object and a page to display the data.

I have now updated the object by adding record types.  What I want to do is update either the class or the page so that the page only displays the data for one particular record type.

My SOQL query is currently:

String strSql = 'SELECT Id, Name, Preview_Text__c, NewsBody__c, CreatedDate, Sort_Date__c, Published__c, RecordType.ID FROM News__c WHERE Published__c = TRUE ORDER BY Sort_Date__c DESC';
return database.query(StrSql);


I have tried changing this to;

String strSql = 'SELECT Id, Name, Preview_Text__c, NewsBody__c, CreatedDate, Sort_Date__c, Published__c, RecordType.ID FROM News__c WHERE Published__c = TRUE AND RecordType.ID="WHATEVER THE ID IS" ORDER BY Sort_Date__c DESC';
return database.query(StrSql);

This displays an error.  Can anyone advise on the correct way to handle this requirement?  I will want to do another page later that includes the data for the other type.
  • April 22, 2014
  • Like
  • 0
I have a controller extension that adds default value to a rich text field.  The line that adds the default value is:

nws.NewsBody__c = 'Test default info';

How would I update this to include an image as the default?
  • March 23, 2014
  • Like
  • 0
I have a custom rich text field.  This has been added to a visualforce page.  When I click the add image icon I see:

User-added image

However if I use this on a standard page I see:

User-added image

How do I update my field/visualforce page to allow an upload rather than a URL?
  • March 23, 2014
  • Like
  • 1
I have an visualforce page that uses a class extension to pre-populate some fields.

nws.NewsBody__c = 'Test default info'; works fine for text.

The NewsBody__c field is a rich text field.  How would I update my extension so that it includes images as the default value?


  • March 20, 2014
  • Like
  • 0
I have a custom rich text field.  This has been added to a visualforce page.  When I click the add image icon I see:

User-added image

However if I use this on a standard page I see:

User-added image

How do I update my field/visualforce page to allow an upload rather than a URL?
  • March 23, 2014
  • Like
  • 1
I'm replacing the ideas page with a custom VF page.  I have everything working apart from the vote up and down buttons.

Has anyone else done this and able to assist in getting the buttons working?  I have a look at this thread (https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AsPHIA0)with the same question but there was no resolution.
  • May 30, 2015
  • Like
  • 0
I have a visual force page that displays all ideas in a page block table.  I want to add a link to the side of the table that reads “Most discussed”.  When clicking on it, the ideas displayed will be sorted by the number of comments.  

Likewise, I want another link that says “popular” and when clicked it’ll sort by the number of votes.  

I’ve had a look at the below:

https://help.salesforce.com/apex/HTViewSolution?id=000171025&language=en_US

This kind of covers what I’m looking to do however I’m not sure how to implement the sort options.  My page uses a standard controller with an extension.

Can anyone suggest how I would code the sort options in the apex class and then implement in visual force?
  • May 27, 2015
  • Like
  • 0
Hi,
On a standard Case pagelayout i need  Subscribe & Unsubscribe buttons. On clicking Subscribe button, need to receive updates & onclicking Unsubscribe, need to stop updates. Need help on these.Thanks
  • May 27, 2015
  • Like
  • 0
I have a custom object.  It has fields for region, status and created date and there are 5 records created every day.  I want a VF page that displays this as a matrix.  

Along the top I want days, and on the side region.  The cell should display the status field.

Example:

                     apr 24   apr 25     apr 26    apr 27    apr 28
UK                Yes       No          Yes       No         Yes
US                Yes       No          Yes       No         Yes
Europe          Yes       No          Yes       No         Yes

Is there an easy way to create this kind of a matrix in VF? 
  • April 24, 2015
  • Like
  • 0
When I try to deploy some component (without any link to chatter) i have the error : 

"ChatterAnswersAuthProviderRegTest.validateCreateUpdateUser(), Details: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [ProfileId]: [ProfileId] Class.ChatterAnswersAuthProviderRegTest.validateCreateUpdateUser: line 31, column 1"

the test class ask for a ProfileId, while i can't modify it.

Name                            Version       Nom d'espace       Type
API salesforce.com        33.0             API                     salesforce.com
____________________________________________________________________________________________________
@isTest
private class ChatterAnswersAuthProviderRegTest {
  static testMethod void validateCreateUpdateUser() {
    User thisUser = [ select Id from User where Id = :UserInfo.getUserId() ];
    System.runAs ( thisUser ) {
      Auth.UserData userData = new Auth.UserData('testId', 'testFirst', 'testLast',
      'testFirst testLast', 'no-reply@salesforce.com', null, 'testuserlong', 'en_US', 'facebook',
      null, new Map<String, String>{'language' => 'en_US'});
      ChatterAnswersAuthProviderRegistration reg = new ChatterAnswersAuthProviderRegistration();
      Profile[] p = [SELECT Id FROM Profile WHERE Name = 'System Administrator'];
      User[] adminUser = [SELECT Id, Firstname, Lastname FROM User WHERE IsActive = true and ProfileId =: p[0].Id LIMIT 1];
      reg.setSiteAdminUserId(adminUser[0].Id);
      User newUser = reg.createUser(null, userData);
      System.assert(newUser != null, 'A new user should have been created');
      System.assertEquals(newUser.Firstname, 'testFirst', 'First name should have been same');
      System.assertEquals(newUser.Lastname, 'testLast', 'Last name should have been same');
      System.assertEquals(newUser.Email, 'no-reply@salesforce.com', 'Email should have been same');
      
      Contact c = new Contact();
      c.AccountId = (newUser.Username.split('@'))[0];
      c.LastName = 'contactLast';
      insert(c);
      
      newUser.Alias = 'firstusr';
      newUser.TimeZoneSidKey = 'America/Los_Angeles';
      newUser.LocaleSidKey = 'en_US';
      newUser.EmailEncodingKey = 'UTF-8';
      newUser.LanguageLocaleKey = 'en_US';
      newUser.ContactId = c.Id;
      // newUser.ProfileId = [SELECT Id FROM Profile WHERE Name = 'Standard User' LIMIT 1].Id;  [try to add this but i can't save]

      insert(newUser); // <= this is where the error is located :
      
      Auth.UserData updateUserData = new Auth.UserData('testId', 'updatedFirst', 'updatedLast',
      'updatedFirst updatedLast', 'no-reply@new.salesforce.com', null, 'testuserlong', 'en_US', 'facebook',
      null, new Map<String, String>{'language' => 'en_US'});
      reg.updateUser(newUser.Id, null, updateUserData);
      
      User dbUser =  [SELECT Id, Firstname, Lastname, Email FROM User WHERE Id = :newUser.Id];
      System.assertEquals(dbUser.Firstname, 'updatedFirst', 'First name should have been updated');
      System.assertEquals(dbUser.Lastname, 'updatedLast', 'Last name should have been updated');
      System.assertEquals(dbUser.Email, 'no-reply@new.salesforce.com', 'Email should have been updated');
    }
  }
}
________________________________________________________________________________________________
I have a html customized visualforce page that displays idea records. I have successfully implemented everything, except for the promote/demote buttons. How would I put that in my page under each record displayed? I've searched the documentation, but haven't had any success. 

Any help would be much appreciated!

Thanks!

 
Hi,

I've created a custom object and a page to display the data.

I have now updated the object by adding record types.  What I want to do is update either the class or the page so that the page only displays the data for one particular record type.

My SOQL query is currently:

String strSql = 'SELECT Id, Name, Preview_Text__c, NewsBody__c, CreatedDate, Sort_Date__c, Published__c, RecordType.ID FROM News__c WHERE Published__c = TRUE ORDER BY Sort_Date__c DESC';
return database.query(StrSql);


I have tried changing this to;

String strSql = 'SELECT Id, Name, Preview_Text__c, NewsBody__c, CreatedDate, Sort_Date__c, Published__c, RecordType.ID FROM News__c WHERE Published__c = TRUE AND RecordType.ID="WHATEVER THE ID IS" ORDER BY Sort_Date__c DESC';
return database.query(StrSql);

This displays an error.  Can anyone advise on the correct way to handle this requirement?  I will want to do another page later that includes the data for the other type.
  • April 22, 2014
  • Like
  • 0
I have a controller extension that adds default value to a rich text field.  The line that adds the default value is:

nws.NewsBody__c = 'Test default info';

How would I update this to include an image as the default?
  • March 23, 2014
  • Like
  • 0
I have an visualforce page that uses a class extension to pre-populate some fields.

nws.NewsBody__c = 'Test default info'; works fine for text.

The NewsBody__c field is a rich text field.  How would I update my extension so that it includes images as the default value?


  • March 20, 2014
  • Like
  • 0