-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
11Questions
-
15Replies
Batch apex to update account based on contract status
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?
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?
- ab84
- December 16, 2016
- Like
- 0
- Continue reading or reply
Vote up and down on idea object
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.
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.
- ab84
- May 30, 2015
- Like
- 0
- Continue reading or reply
Sorting results in visualforce
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?
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?
- ab84
- May 27, 2015
- Like
- 0
- Continue reading or reply
Search box to open in new page
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:
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>
- ab84
- May 27, 2015
- Like
- 0
- Continue reading or reply
HTML held in a text field won't render in visualforce
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?
<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?
- ab84
- May 05, 2015
- Like
- 0
- Continue reading or reply
Displaying records in a matrix on a custom VF page
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?
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?
- ab84
- April 24, 2015
- Like
- 0
- Continue reading or reply
Document Object Search (with full content search)
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?
How would I reproduce this search in my VF page?
- ab84
- February 23, 2015
- Like
- 0
- Continue reading or reply
Basic SOQL Query for RecordType of Custom Object
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.
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.
- ab84
- April 22, 2014
- Like
- 0
- Continue reading or reply
Extension to add default text/images to rich text
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?
nws.NewsBody__c = 'Test default info';
How would I update this to include an image as the default?
- ab84
- March 23, 2014
- Like
- 0
- Continue reading or reply
Image upload on rich text fields
I have a custom rich text field. This has been added to a visualforce page. When I click the add image icon I see:
However if I use this on a standard page I see:
How do I update my field/visualforce page to allow an upload rather than a URL?
However if I use this on a standard page I see:
How do I update my field/visualforce page to allow an upload rather than a URL?
- ab84
- March 23, 2014
- Like
- 1
- Continue reading or reply
Default value on rich text field
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?
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?
- ab84
- March 20, 2014
- Like
- 0
- Continue reading or reply
Image upload on rich text fields
I have a custom rich text field. This has been added to a visualforce page. When I click the add image icon I see:
However if I use this on a standard page I see:
How do I update my field/visualforce page to allow an upload rather than a URL?
However if I use this on a standard page I see:
How do I update my field/visualforce page to allow an upload rather than a URL?
- ab84
- March 23, 2014
- Like
- 1
- Continue reading or reply
Vote up and down on idea object
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.
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.
- ab84
- May 30, 2015
- Like
- 0
- Continue reading or reply
Sorting results in visualforce
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?
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?
- ab84
- May 27, 2015
- Like
- 0
- Continue reading or reply
Subscribe & UnSubscribe buttons on Case records
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
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
- sfg1
- May 27, 2015
- Like
- 0
- Continue reading or reply
Displaying records in a matrix on a custom VF page
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?
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?
- ab84
- April 24, 2015
- Like
- 0
- Continue reading or reply
ChatterAnswersAuthProviderRegTest : unjustified Code Coverage Failure
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');
}
}
}
________________________________________________________________________________________________
"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');
}
}
}
________________________________________________________________________________________________
- Elsa Roussel
- March 02, 2015
- Like
- 0
- Continue reading or reply
How to create or recreate promote button on visualforce page
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!
Any help would be much appreciated!
Thanks!
- Btuitasi1
- November 07, 2014
- Like
- 0
- Continue reading or reply
Basic SOQL Query for RecordType of Custom Object
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.
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.
- ab84
- April 22, 2014
- Like
- 0
- Continue reading or reply
Extension to add default text/images to rich text
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?
nws.NewsBody__c = 'Test default info';
How would I update this to include an image as the default?
- ab84
- March 23, 2014
- Like
- 0
- Continue reading or reply
Default value on rich text field
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?
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?
- ab84
- March 20, 2014
- Like
- 0
- Continue reading or reply