-
ChatterFeed
-
1Best Answers
-
0Likes Received
-
0Likes Given
-
44Questions
-
42Replies
Error: Constructor not defined: [ApexPages.StandardController].<Constructor>()
I got this error when i save my test class:
Error: Compile Error: Constructor not defined: [ApexPages.StandardController].<Constructor>()
CLASS:
public class ContentVersionAlt { private List<ContentVersion> ContentVersions; public string host{get;set;} public ContentVersionAlt(ApexPages.StandardController controller) { host=URL.getSalesforceBaseUrl().toExternalForm(); } public List<ContentVersion> getContentVersions() { ContentVersions= [Select c.id ,c.Software_Download__c,c.title,c.description,c.FileType From ContentVersion c where c.Software_Download__c=:System.currentPagereference().getParameters().get('id')]; return ContentVersions; } }
TEST CLASS:
@istest private class ContentVersionAltTest { static testMethod void ContentVersionsTest(){ PageReference pageRef = Page.SoftwareDownloadFiles; Test.setCurrentPageReference(pageRef); ApexPages.StandardController sc = new ApexPages.standardController(); //create an instance of the controller ContentVersionAlt myPageCon = new ContentVersionAlt(sc); myPageCon.getContentVersions(); ContentVersion testContentInsert =new ContentVersion(); testContentInsert.ContentURL='http://www.google.com/'; testContentInsert.Title ='Google.com'; insert testContentInsert; ContentVersion testContent = [SELECT ContentDocumentId FROM ContentVersion where Id = :testContentInsert.Id]; ContentWorkspace testWorkspace = [SELECT Id FROM ContentWorkspace WHERE Name='Opportunity Documents ']; ContentWorkspaceDoc newWorkspaceDoc =new ContentWorkspaceDoc(); newWorkspaceDoc.ContentWorkspaceId = testWorkspace.Id; newWorkspaceDoc.ContentDocumentId = testContent.ContentDocumentId; insert newWorkspaceDoc; update testContent; } }
How can i solve this?
Thanks in advantage for any advice.
-
- Enry
- August 22, 2013
- Like
- 0
- Continue reading or reply
Number rows limit in report export
I would like to know which is the row number limit when you make an export of a report (usingExport details or Printable view).
I'm going to export a tabular report with 50.000 rows.
Thanks,BR.
-
- Enry
- August 18, 2013
- Like
- 0
- Continue reading or reply
Check if condition is satisfied for all related records
I'm writing a scheduled apex class and I would like to write a code to accomplish this:
check each account in the org and if an account has all opportunities with stage=”Cancelled” then set the checkbox named control =true on the account object.
For me it's difficult to check *if all* the opportunities have the stage ="Cancelled".
Please could you help me?
Thanks in advantage for any advice.
BR.
-
- Enry
- August 17, 2013
- Like
- 0
- Continue reading or reply
Field Email Validation
I have a simple VF form and i would like to validate the email address field when the user click on Submit.
<apex:page id="loginPage" showHeader="false" controller="SiteRegisterController" title="{!$Label.site.site_login}"> <apex:define name="body"> <center> <apex:panelGrid bgcolor="white" columns="1"> <br/> <br/> <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="1" styleClass="topPanelContainer"> <br/> <apex:outputPanel layout="block" styleClass="topPanel"> <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="2"> <apex:panelGroup > <h1>Don't have an account?</h1> <br/> <h2>Enter your email address to register</h2> <apex:form id="theForm" forceSSL="true"> <apex:panelGrid columns="2" style="margin-top:1em;"> <apex:outputLabel value="{!$Label.site.email}" for="email"/> <apex:inputText required="true" id="email" value="{!email}"/> <apex:outputText value=""/> <apex:commandButton action="{!registerUser}" value="{!$Label.site.submit}" id="submit"/> </apex:panelGrid> </apex:form> </apex:panelGroup> </apex:panelGrid> </apex:outputPanel> </apex:panelGrid> </apex:panelGrid> </center> <br/> </apex:define> </apex:page>
How can i achieve this?
Thanks in advantage for any advice.
BR.
-
- Enry
- August 11, 2013
- Like
- 0
- Continue reading or reply
Months between two dates
In my trigger i would like to calculate the number of months between two date.
For Example if the date format is (DAY/MONTH/YEAR):
START DATE : 07/10/2013
END DATE: 12/01/2014
Number Months=4
because (07/01/2014) plus 1 month for the 5 days
I've tried with many examples, but nothing.
Please can you help me?
Thanks in advantage for any advice.
BR
-
- Enry
- July 19, 2013
- Like
- 0
- Continue reading or reply
control trigger execution
I have 2 triggers:
The first:
trigger AutoProduct on Opportunity (before insert,after insert) { for(Opportunity newOppt : Trigger.new){ if ((trigger.isBefore)&&(Trigger.isInsert)){ // SET SOME FIELDS } opptsToInsert.add(newOppt); if ((Trigger.isAfter)&&(Trigger.isInsert)){ //GET OPPORTUNITY //CREATE OPPORTUNITY LINE ITEM FOR EACH NEW OPPORTUNITY //CREATE OPPORTUNITY LINE ITEM QUANTITY AND REVENUE SCHEDULE FOR EACH NEW OPPORTUNITY PRODUCT } }
The second
trigger AutoProductupdate on Opportunity ( before update,after update) { for(Opportunity newOppt : Trigger.new){ if (trigger.isAfter){ //DELETE OPPORTUNITY LINE ITEM SCHEDULES FOR ALL THE PRODUCTS // UPDATE OPPORTUNITY LINE ITEM // CREATE OPPORTUNITY LINE ITEM SCHEDULES FOR ALL THE PRODUCTS } } }
The problem is that when i insert an opportunity(execution first trigger) it's also executed the second trigger on update.
I want that on creation of an opportunity is only executed the first trigger.
How can avoid this?
Thank in advantage for any advice.
BR.
-
- Enry
- July 18, 2013
- Like
- 0
- Continue reading or reply
Recursive trigger
This is my trygger on Opportunity object.
trigger AutoProductupdate on Opportunity ( before update,after update) { static boolean already=false; if (already==false){ for(Opportunity newOppt : Trigger.new){ if (trigger.isAfter){ if (newOppt.Pricing_Tears__c.trim()=='Gigabyte'){ SYSTEM.DEBUG('update'); Automations.UpdateOpportunityLineItems(newOppt); //Action of the called function: //DELETE OPPORTUNITY LINE ITEM SCHEDULES FOR ALL THE PRODUCTS // UPDATE OPPORTUNITY LINE ITEM Automations.SheduleOpportunityLineItem(newOppt); //Action of the called function: // CREATE OPPORTUNITY LINE ITEM SCHEDULES FOR ALL THE PRODUCTS } } } already=true; } }
I am working with opportunity product and opportunity product schedules. In the debug log i see that the trigger is working recursively (It 's printed 15 times the string 'update' with the system.debug).
The error message:
execution of AfterUpdate caused by: System.DmlException: Delete failed. First exception on row 0 with id 00oL0000000acVqIAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AutoProductupdate: maximum trigger depth exceeded Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ]: []: Class.Automations.UpdateOpportunityLineItems: line 70, column 1
Which is the problem?
How can avoid this?
-
- Enry
- July 17, 2013
- Like
- 0
- Continue reading or reply
Report Accounts without open activities
I'm building a report to show all accounts without open activities. It's:
Accounts with or without related records from Activities
with filter activity status equals Completed.
I don't understand. In the report there are also accounts with activity with status not equals to completed.
Do you Know why?
Thanks in adavantage for any advice.
-
- Enry
- July 09, 2013
- Like
- 0
- Continue reading or reply
Export report with just one currency
I have a simple report that shows my opportunity with different currencies.
I'm exporting the report:
Currency Amount Amount
INR 100
USD 0.00
USD 0.00
USD 0.00
USD 0.00
I would like to export this with just one currency.
Is it possible?
Thanks in advantage for any advice.
BR.
-
- Enry
- July 09, 2013
- Like
- 0
- Continue reading or reply
Accounts with open activities
I want a list view with only the accounts that haven't open activities at this moment.
It isn't possible with a formula field or a roll-up.
Do you have any idea?
is it possible in a report instead?
Thanks in advantage for any advice
Br
-
- Enry
- July 08, 2013
- Like
- 0
- Continue reading or reply
System.FinalException: Record is read-only
Hi,I want just that when a new opportunity is created, a set of opportunitylineitems will be created.
This is my code:
trigger Automations on Opportunity (before insert,after insert) { List<Opportunity> opptsToInsert = new List<Opportunity>(); for(Opportunity newOppt : Trigger.new){ newOppt.NextStep='NextStep'; opptsToInsert.add(newOppt); } //CREATE 1 OPPORTUNITY LINE ITEM FOR EACH NEW OPPORTUNITY WITH THE CORRECT PRODUCT List<OpportunityLineItem> opptLineItemsToInsert = new List<OpportunityLineItem>(); if ((Trigger.isAfter)&&(Trigger.isInsert)){ for(Opportunity opptInserted : [Select Id, Description from Opportunity where Id in :opptsToInsert]) { for (Integer i=0;i<4; i++) { OpportunityLineItem newOpptLineItem = new OpportunityLineItem(); newOpptLineItem.OpportunityId=opptInserted.Id; newOpptLineItem.Quantity = 1; // SET PRODUCT newOpptLineItem.PricebookEntryId ='01ui0000002brJzAAI'; newOpptLineItem.TotalPrice=100; opptLineItemsToInsert.add(newOpptLineItem); } insert(opptLineItemsToInsert); } } }
i get the following error:
Automations: execution of AfterInsert caused by: System.FinalException: Record is read-only
it works if a remove newOppt.NextStep='NextStep';
The problem is that you cannot update fields on triggered records when you are in an after trigger but i have to update information for the new opportunity.
Please can you help me with this?
Thank you very much for any advice.
ps:I know that it very bad use hard coded ids,but this is just a test.
Br.
-
- Enry
- July 04, 2013
- Like
- 0
- Continue reading or reply
Set Product for new opportunity lineitem
in a trigger i'am going to create a new opportunitylineitem for an opportunity:
OpportunityLineItem newOpptLineItem = new OpportunityLineItem();
newOpptLineItem.OpportunityId = opptInserted.Id;
newOpptLineItem.=cs.OppProductCpvId__c; // FOR GIGABYTE
newOpptLineItem.Quantity = 1;
newOpptLineItem.PricebookEntryId = peWEBinteractive.Id;
opptLineItemsToInsert.add(newOpptLineItem); .
I want to set up a product for this new opportunitylineitem.
newOpptLineItem.ProductId isn't available.
Thanks in advantage for any advice.
-
- Enry
- July 04, 2013
- Like
- 0
- Continue reading or reply
Structure and fuction for picklist's values
I'm tring to optimize the code below.
I'm looking for a structure where i can put the picklist's values and after (with just a condition) i want check the condition for all the values in the structure.
if ((lead.Status.trim()=='Archived' || lead.Status.trim()=='False'||lead.Status.trim()=='Lead - Never'))
should be like this:
structure=['Archived','False','Lead - Never'];
if ((lead.Status.trim()==structure))
I can not find anything, do you know how i can do this?
Thanks in advantage for any advice.
Br
-
- Enry
- June 28, 2013
- Like
- 0
- Continue reading or reply
insert record and workflow-trigger
I'm creating a new record in a custom controller of a visualforce page.This getting the field values from a visual force page where the user insert only the values of 3 fields.
After pressing the button save i open the new record in edit mode and the user can insert the values of other 7 fields for the same records.
My question is about:
insert record;
this instruction in the custom controller runs the triggers and workflow rules of the object?
I have an insert when the user press the save button on the first page (3 fields), i think that i will have problems because on first save i haven't all the fields populated.
Thanks in advantage for any advice.
Br.
-
- Enry
- June 22, 2013
- Like
- 0
- Continue reading or reply
Open a standard record page in edit mode
Hi, It's very easy open the detail page of a new record created in a custom controller of a visual force page.
Example code:
public PageReference save() { ……. PageReference acctPage = new PageReference('/' + Influencer.id); acctPage.setRedirect(true); return acctPage; }
But i would like to be able to open the page of the new record in edit mode.
Please, can you help me?
Thanks in advantage for any advice.
-
- Enry
- June 21, 2013
- Like
- 0
- Continue reading or reply
Visual force page and record type
I'm creating a custom visual force page that allow users to create a new record for a custom object.
I want understand if in the custom VF page i have the standard functionality of the record type:
-see different field according to the visibility of the page layout
-have different picklist values
I have found this resource link:
I have tried creating a custom visual force page and two record types.
The record types are linked to different page layout.In one of the two page layouts i have removed some fields.
Pressing the New button i can choose which of the two record types i want.
They open the same VF page,but i can see on my custom vf Page the same fields.
I would like to be able to show different fields on my custom VF page according to different record types. Is not possible or is there something that i don't know?
Thanks in advantage for any advice.
BR.
-
- Enry
- June 21, 2013
- Like
- 0
- Continue reading or reply
Created by user in chatter api connect
Hi. I'm using the chatter connect to create a chatter post.
Ref: Connect
All works fine but i want to specify the user that creates the chatter post.
In the previous version of my code, i don't use the connect and i have the following instruction:
testpost.CreatedById=user.id;
Do you know how i can do this in the connect api chatter?
My class:
Global class HappyBirthdayRandomPilot implements Schedulable{ //FOR TEST METHOD public static String CRON_EXP = '0 0 0 3 9 ? 2022'; Global void execute(SchedulableContext sc) { // SEARCH BY STATIC RESOURCE NAME List<StaticResource> Pictures=[Select Name, ContentType, Body From StaticResource where Name like 'PicturehappyBirthday%']; // IS THE USER BIRTHDAY? List<user> lstu=[SELECT id,name,date_of_birth__c FROM user WHERE CALENDAR_MONTH(date_of_birth__c)=:date.today().month() AND DAY_IN_MONTH(date_of_birth__c)=:date.today().day()]; CollaborationGroup group=[Select id,name from CollaborationGroup where Name like 'name%' limit 1]; //String communityId = null; for(User u:lstu) { //GENERATE A RANDOM NUMBER [0-5] TO SELECT THE PICTURE Integer choice=math.mod(Integer.valueof(Math.random()*100),6); Blob Decodedbody=Pictures[choice].body; // CREATE A FEED_ITEM_TEXT ConnectApi.MessageBodyInput messageInput = new ConnectApi.MessageBodyInput(); messageInput.messageSegments = new List<ConnectApi.MessageSegmentInput>(); ConnectApi.TextSegmentInput textSegment = new ConnectApi.TextSegmentInput(); textSegment.text = 'Happy birthday to '; messageInput.messageSegments.add(textSegment); ConnectApi.MentionSegmentInput mentionSegment = new ConnectApi.MentionSegmentInput(); mentionSegment.id = u.id; messageInput.messageSegments.add(mentionSegment); textSegment = new ConnectApi.TextSegmentInput(); textSegment.text = '!'; messageInput.messageSegments.add(textSegment); ConnectApi.FeedItemInput input = new ConnectApi.FeedItemInput(); input.body = messageInput; // POST FILE_FEED_ITEM ConnectApi.NewFileAttachmentInput fileIn = new ConnectApi.NewFileAttachmentInput(); fileIn.title ='Wishes!'; fileIn.description = ''; Input.attachment = fileIn; string contentType='image/jpeg'; ConnectApi.BinaryInput feedBinary = new ConnectApi.BinaryInput(Decodedbody,contentType, 'Wishes!.jpg'); // PARAMETERS(communityId, feedType, subjectId, input,filebody); ConnectApi.ChatterFeeds.postFeedItem(null,ConnectApi.FeedType.Record,group.id,Input, feedBinary); } } }
Thanks in advantage for any advice.
BR.
-
- Enry
- June 19, 2013
- Like
- 0
- Continue reading or reply
Javascript Button to run apex class
Hi,I want create a custom button that runs an apex class.
This class create a record and open the detailed page of the record created.
Do you know if is it possible?
Do you have an example code for the button that exercutes the class? javascript?
Thanks in advantage for any advice.
BR.
-
- Enry
- June 18, 2013
- Like
- 0
- Continue reading or reply
Test class for ConnectApi chatter post
i have writtern a class that to post a happy birthday message and picture on chatter.
In this post i mention the user. I'm using the connect apex chatter.
All works fine, but i have some problems with the test class. I get the following error.
Method Name TestHappyBirthdayRandom Pass/Fail Skip Error Message Methods defined as TestMethod do not support Web service callouts, test skipped
Thanks in advantage for any advice.
BR.
-
- Enry
- June 15, 2013
- Like
- 0
- Continue reading or reply
Date time export data loader
I'm using the data loader to export accounts.
I put the following condition in the form of the dataloader:
Select NAME FROM Account WHERE LastModifiedDate = 2013-06-11T15:54:00Z
But i'm not able to get the account that have lastmodifiedDate equals to 2013-06-11 time 15:54 ( these value are showed by an account).
I don't know which of the following parameters is important to have success:
--My user has:
Time Zone (GMT+02:00) Central European Summer Time (Europe/Paris)
--Dataloader setting: timezone=Europe/Paris
--with a query in the developer console i see this format: 2013-05-31T12:26:35.000+0000
Please can you help me?
Which should be the right date format in the soql query?
Thank you in adavantage.
BR.
-
- Enry
- June 11, 2013
- Like
- 0
- Continue reading or reply
Error: Constructor not defined: [ApexPages.StandardController].<Constructor>()
I got this error when i save my test class:
Error: Compile Error: Constructor not defined: [ApexPages.StandardController].<Constructor>()
CLASS:
public class ContentVersionAlt { private List<ContentVersion> ContentVersions; public string host{get;set;} public ContentVersionAlt(ApexPages.StandardController controller) { host=URL.getSalesforceBaseUrl().toExternalForm(); } public List<ContentVersion> getContentVersions() { ContentVersions= [Select c.id ,c.Software_Download__c,c.title,c.description,c.FileType From ContentVersion c where c.Software_Download__c=:System.currentPagereference().getParameters().get('id')]; return ContentVersions; } }
TEST CLASS:
@istest private class ContentVersionAltTest { static testMethod void ContentVersionsTest(){ PageReference pageRef = Page.SoftwareDownloadFiles; Test.setCurrentPageReference(pageRef); ApexPages.StandardController sc = new ApexPages.standardController(); //create an instance of the controller ContentVersionAlt myPageCon = new ContentVersionAlt(sc); myPageCon.getContentVersions(); ContentVersion testContentInsert =new ContentVersion(); testContentInsert.ContentURL='http://www.google.com/'; testContentInsert.Title ='Google.com'; insert testContentInsert; ContentVersion testContent = [SELECT ContentDocumentId FROM ContentVersion where Id = :testContentInsert.Id]; ContentWorkspace testWorkspace = [SELECT Id FROM ContentWorkspace WHERE Name='Opportunity Documents ']; ContentWorkspaceDoc newWorkspaceDoc =new ContentWorkspaceDoc(); newWorkspaceDoc.ContentWorkspaceId = testWorkspace.Id; newWorkspaceDoc.ContentDocumentId = testContent.ContentDocumentId; insert newWorkspaceDoc; update testContent; } }
How can i solve this?
Thanks in advantage for any advice.
- Enry
- August 22, 2013
- Like
- 0
- Continue reading or reply
Field Email Validation
I have a simple VF form and i would like to validate the email address field when the user click on Submit.
<apex:page id="loginPage" showHeader="false" controller="SiteRegisterController" title="{!$Label.site.site_login}"> <apex:define name="body"> <center> <apex:panelGrid bgcolor="white" columns="1"> <br/> <br/> <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="1" styleClass="topPanelContainer"> <br/> <apex:outputPanel layout="block" styleClass="topPanel"> <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="2"> <apex:panelGroup > <h1>Don't have an account?</h1> <br/> <h2>Enter your email address to register</h2> <apex:form id="theForm" forceSSL="true"> <apex:panelGrid columns="2" style="margin-top:1em;"> <apex:outputLabel value="{!$Label.site.email}" for="email"/> <apex:inputText required="true" id="email" value="{!email}"/> <apex:outputText value=""/> <apex:commandButton action="{!registerUser}" value="{!$Label.site.submit}" id="submit"/> </apex:panelGrid> </apex:form> </apex:panelGroup> </apex:panelGrid> </apex:outputPanel> </apex:panelGrid> </apex:panelGrid> </center> <br/> </apex:define> </apex:page>
How can i achieve this?
Thanks in advantage for any advice.
BR.
- Enry
- August 11, 2013
- Like
- 0
- Continue reading or reply
Visual force error message in a new page
I'm creating a custom VF page for the registration of new users.
Page: simple form to get the user's email.
Controller:
public with sharing class SiteRegisterController { public SiteRegisterController () { } public String username {get; set;} public String email {get; set;} public String password {get; set;} public PageReference registerUser() { user u = [select id,username from User where username = :email]; if (u!=null) { //ADD HERE CODE FOR ERROR MESSAGE IN THE PAGE FORGOTPASSWORD PageReference page = System.Page.ForgotPassword; page.setRedirect(true); return page; } else { PageReference page = new PageReference('http://registration.com/'); page.setRedirect(true); return page; } return null; } }
If the user is already registered i would like also add a message "You are already registered, Did you forget your password?" on the new page System.Page.ForgotPassword;. I know how to add an eror message in the current page
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error Message.'); ApexPages.addMessage(myMsg);
but is it also possible add it in a new page(forgotpassword) from the controller of the current page? Of course in the page forgot password there is a tag
<apex:pageMessages id="error"/>
Thanks in advantage for any advice.
BR.
- enrydev
- August 10, 2013
- Like
- 0
- Continue reading or reply
Recursive trigger
This is my trygger on Opportunity object.
trigger AutoProductupdate on Opportunity ( before update,after update) { static boolean already=false; if (already==false){ for(Opportunity newOppt : Trigger.new){ if (trigger.isAfter){ if (newOppt.Pricing_Tears__c.trim()=='Gigabyte'){ SYSTEM.DEBUG('update'); Automations.UpdateOpportunityLineItems(newOppt); //Action of the called function: //DELETE OPPORTUNITY LINE ITEM SCHEDULES FOR ALL THE PRODUCTS // UPDATE OPPORTUNITY LINE ITEM Automations.SheduleOpportunityLineItem(newOppt); //Action of the called function: // CREATE OPPORTUNITY LINE ITEM SCHEDULES FOR ALL THE PRODUCTS } } } already=true; } }
I am working with opportunity product and opportunity product schedules. In the debug log i see that the trigger is working recursively (It 's printed 15 times the string 'update' with the system.debug).
The error message:
execution of AfterUpdate caused by: System.DmlException: Delete failed. First exception on row 0 with id 00oL0000000acVqIAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AutoProductupdate: maximum trigger depth exceeded Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ] Opportunity trigger event AfterUpdate for [006L0000003EUVZ]: []: Class.Automations.UpdateOpportunityLineItems: line 70, column 1
Which is the problem?
How can avoid this?
- Enry
- July 17, 2013
- Like
- 0
- Continue reading or reply
Export report with just one currency
I have a simple report that shows my opportunity with different currencies.
I'm exporting the report:
Currency Amount Amount
INR 100
USD 0.00
USD 0.00
USD 0.00
USD 0.00
I would like to export this with just one currency.
Is it possible?
Thanks in advantage for any advice.
BR.
- Enry
- July 09, 2013
- Like
- 0
- Continue reading or reply
System.FinalException: Record is read-only
Hi,I want just that when a new opportunity is created, a set of opportunitylineitems will be created.
This is my code:
trigger Automations on Opportunity (before insert,after insert) { List<Opportunity> opptsToInsert = new List<Opportunity>(); for(Opportunity newOppt : Trigger.new){ newOppt.NextStep='NextStep'; opptsToInsert.add(newOppt); } //CREATE 1 OPPORTUNITY LINE ITEM FOR EACH NEW OPPORTUNITY WITH THE CORRECT PRODUCT List<OpportunityLineItem> opptLineItemsToInsert = new List<OpportunityLineItem>(); if ((Trigger.isAfter)&&(Trigger.isInsert)){ for(Opportunity opptInserted : [Select Id, Description from Opportunity where Id in :opptsToInsert]) { for (Integer i=0;i<4; i++) { OpportunityLineItem newOpptLineItem = new OpportunityLineItem(); newOpptLineItem.OpportunityId=opptInserted.Id; newOpptLineItem.Quantity = 1; // SET PRODUCT newOpptLineItem.PricebookEntryId ='01ui0000002brJzAAI'; newOpptLineItem.TotalPrice=100; opptLineItemsToInsert.add(newOpptLineItem); } insert(opptLineItemsToInsert); } } }
i get the following error:
Automations: execution of AfterInsert caused by: System.FinalException: Record is read-only
it works if a remove newOppt.NextStep='NextStep';
The problem is that you cannot update fields on triggered records when you are in an after trigger but i have to update information for the new opportunity.
Please can you help me with this?
Thank you very much for any advice.
ps:I know that it very bad use hard coded ids,but this is just a test.
Br.
- Enry
- July 04, 2013
- Like
- 0
- Continue reading or reply
Set Product for new opportunity lineitem
in a trigger i'am going to create a new opportunitylineitem for an opportunity:
OpportunityLineItem newOpptLineItem = new OpportunityLineItem();
newOpptLineItem.OpportunityId = opptInserted.Id;
newOpptLineItem.=cs.OppProductCpvId__c; // FOR GIGABYTE
newOpptLineItem.Quantity = 1;
newOpptLineItem.PricebookEntryId = peWEBinteractive.Id;
opptLineItemsToInsert.add(newOpptLineItem); .
I want to set up a product for this new opportunitylineitem.
newOpptLineItem.ProductId isn't available.
Thanks in advantage for any advice.
- Enry
- July 04, 2013
- Like
- 0
- Continue reading or reply
Visual force page and record type
I'm creating a custom visual force page that allow users to create a new record for a custom object.
I want understand if in the custom VF page i have the standard functionality of the record type:
-see different field according to the visibility of the page layout
-have different picklist values
I have found this resource link:
I have tried creating a custom visual force page and two record types.
The record types are linked to different page layout.In one of the two page layouts i have removed some fields.
Pressing the New button i can choose which of the two record types i want.
They open the same VF page,but i can see on my custom vf Page the same fields.
I would like to be able to show different fields on my custom VF page according to different record types. Is not possible or is there something that i don't know?
Thanks in advantage for any advice.
BR.
- Enry
- June 21, 2013
- Like
- 0
- Continue reading or reply
Javascript Button to run apex class
Hi,I want create a custom button that runs an apex class.
This class create a record and open the detailed page of the record created.
Do you know if is it possible?
Do you have an example code for the button that exercutes the class? javascript?
Thanks in advantage for any advice.
BR.
- Enry
- June 18, 2013
- Like
- 0
- Continue reading or reply
Date time export data loader
I'm using the data loader to export accounts.
I put the following condition in the form of the dataloader:
Select NAME FROM Account WHERE LastModifiedDate = 2013-06-11T15:54:00Z
But i'm not able to get the account that have lastmodifiedDate equals to 2013-06-11 time 15:54 ( these value are showed by an account).
I don't know which of the following parameters is important to have success:
--My user has:
Time Zone (GMT+02:00) Central European Summer Time (Europe/Paris)
--Dataloader setting: timezone=Europe/Paris
--with a query in the developer console i see this format: 2013-05-31T12:26:35.000+0000
Please can you help me?
Which should be the right date format in the soql query?
Thank you in adavantage.
BR.
- Enry
- June 11, 2013
- Like
- 0
- Continue reading or reply
@Mention with apex code
I've written a class to post a happy birthday message and picture on chatter.
Now i want mention a user in the post.
I have found:http://developer.force.com/cookbook/recipe/posting-a-chatter-mention-via-apex
My code create the post but it doesn't mention the user.
i haven't experience with HttpRequest.
Please can you take a look to my code?
Thank you in advantage.
Global class HappyBirthdayRandom implements Schedulable{ //FOR TEST METHOD public static String CRON_EXP = '0 0 0 3 9 ? 2022'; @future(callout=true) public static void mention(string uid,string RecordId){ //INVOKE CHATTER REST API FOR MENTION String salesforceHost = System.Url.getSalesforceBaseURL().toExternalForm(); String url = salesforceHost + '/services/data/v26.0/chatter/feeds/record/' + RecordId + '/feed-items'; HttpRequest req = new HttpRequest(); req.setMethod('POST'); req.setEndpoint(url); string ChatterPostText='Happy Birthday'; req.setHeader('Content-type', 'application/json'); req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId()); req.setBody('{ "body" : { "messageSegments" : [ { "type": "mention", "id" : "' + uid + '" }, { "type": "text", "text" : "' + ' ' + ChatterPostText + '" } ] } }'); Http http = new Http(); HTTPResponse res = http.send(req); } Global void execute(SchedulableContext sc) { // SEARCH BY STATIC RESOURCE NAME List<StaticResource> Pictures=[Select Name, ContentType, Body From StaticResource where Name like 'PicturehappyBirthday%']; List<FeedItem> posts = new List<FeedItem>(); // IS THE USER BIRTHDAY? List<user> lstu=[SELECT id,name,date_of_birth__c FROM user WHERE CALENDAR_MONTH(date_of_birth__c)=:date.today().month() AND DAY_IN_MONTH(date_of_birth__c)=:date.today().day()]; CollaborationGroup fgroup=[Select id,name from CollaborationGroup where Name like 'Name%' limit 1]; for(User u:lstu) { //GENERATE A RANDOM NUMBER [0-5] TO SELECT THE PICTURE Integer choice=math.mod(Integer.valueof(Math.random()*100),6); Blob Decodedbody=Pictures[choice].body; // CREATE POST FeedItem post = new FeedItem(); // CREATE BY post.CreatedById=u.id; // CREATE ON post.ParentId =fgroup.id; post.Type = 'ContentPost'; mention(u.id,post.id); post.Body = 'Happy birthday to '+u.name+' !'; post.ContentData = Decodedbody; post.ContentFileName = 'Wishes!.jpg'; posts.add(post); } insert posts; } }
- Enry
- June 10, 2013
- Like
- 0
- Continue reading or reply
Get object Id
Hi,
I have a doubt.
When i have to use an id which is the best way to put it in a variable.
user u=[Select id,name from user where... limit 1 ]; post.CreatedById=u.id;
or
post.CreatedById='005E0000003XNVp';
are there other way?
Which is the best practise?
Thanks in advantage.
BR
- Enry
- June 07, 2013
- Like
- 0
- Continue reading or reply
TestMethod do not support Web service callouts, test skipped
Hi ,
I have written a test class for a trigger on the lead object.
When i run the test class i get the following error:
Methods defined as TestMethod do not support Web service callouts, test skipped
There is an other trigger on lead that has a call to a webservice so i get this error.
I have wrapped the call with:
if (!Test.isRunningTest()) { // do callout }
But i’m still getting the same error.
Any other way to run correctly the test class?
Thank you in advantage.
BR.
- Enry
- June 03, 2013
- Like
- 0
- Continue reading or reply
Standard Controller save
I have written a custom visual force page to edi a custom object "Influencer__c".
I have overridden the standard button edit for this object.
This is my custom page:
<apex:page Standardcontroller="Influencer__c" id="Page" tabstyle="Contact"> <script type="text/javascript"> function openLookup(baseURL, width, modified, searchParam){ var originalbaseURL = baseURL; var originalwidth = width; var originalmodified = modified; var originalsearchParam = searchParam; var lookupType = baseURL.substr(baseURL.length-3, 3); if (modified == '1') baseURL = baseURL + searchParam; var isCustomLookup = false; // Following "001" is the lookup type for Account object so change this as per your standard or custom object if(lookupType == "003"){ var urlArr = baseURL.split("&"); var txtId = ''; if(urlArr.length > 2) { urlArr = urlArr[1].split('='); txtId = urlArr[1]; } // Following is the url of Custom Lookup page. baseURL = "/apex/CustomInfluencerLookup?accplanid={!Influencer__c.Account_Plan__c}&txt=" + txtId; // Following is the id of apex:form control "myForm". baseURL = baseURL + "&frm=" + escapeUTF("{!$Component.myForm}"); if (modified == '1') { baseURL = baseURL + "&lksearch=" + searchParam; } // Following is the ID of inputField that is the lookup to be customized as custom lookup if(txtId.indexOf('mycontact') > -1 ){ isCustomLookup = true; } } if(isCustomLookup == true){ openPopup(baseURL, "lookup", 350, 480, "width="+width+",height=480,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true); } else { if (modified == '1') originalbaseURL = originalbaseURL + originalsearchParam; openPopup(originalbaseURL, "lookup", 350, 480, "width="+originalwidth+",height=480,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true); } } </script> <apex:sectionHeader title="{!$ObjectType.Influencer__c.label}" subtitle="{!Influencer__c.name}"/> <apex:pageBlock title="{!$ObjectType.Influencer__c.label} Detail" mode="edit"> <apex:pageBlockButtons> <apex:form> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton action="{!Cancel}" immediate="true" value="Cancel"/> </apex:form> </apex:pageBlockButtons> <apex:form> <apex:pageBlock> <apex:pageBlockSection title="Information" columns="2"> <apex:inputField value="{!Influencer__c.Name}"/> <apex:inputField value="{!Influencer__c.Account_Plan__c}" required="true"/> <apex:inputField id="mycontact" value="{!Influencer__c.Contact__c}" required="true"/> <apex:inputField value="{!Influencer__c.Type__c}" required="false"/> <apex:inputField value="{!Influencer__c.CCS_Role__c}" required="false"/> <apex:inputField value="{!Influencer__c.IMPACT__c}" required="false"/> <apex:inputField value="{!Influencer__c.Top_Goals__c}" required="false"/> <apex:inputField value="{!Influencer__c.Attitude_towards_QT__c}" required="false"/> <apex:inputField value="{!Influencer__c.Contact_Risk_Profile__c}" required="false"/> <apex:inputField value="{!Influencer__c.Time_Spent__c}" required="false"/> <apex:inputField value="{!Influencer__c.Has_Power__c}" required="false"/> <apex:inputField value="{!Influencer__c.Has_Budget__c}" required="false"/> <apex:inputField value="{!Influencer__c.QT_Exec__c}" required="false"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <apex:pageBlockSection showHeader="false" columns="2"> <apex:outputField value="{!Influencer__c.CreatedById}"/> <apex:outputField value="{!Influencer__c.LastModifiedById}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:page>
When i press the button SAVE the new informations are not saved.
Where am i wrong?
have i a problem in the code's page or is it because i have overridden the button?
Please help me.
Thank you very much.
BR
- Enry
- June 01, 2013
- Like
- 0
- Continue reading or reply
Trouble Setting RecordType in Trigger
I am setting the recordType of a newly created recorded in apex.
I have it inserting the new opportunity and am receiving an error on this line:
opportunity.recordtype = chosenRecType;
chosenRecType is a value passed to the controller via javascript.
The error is: Error: Compile Error: Illegal assignment from String to SOBJECT:RecordType
Is there a way to convert this string to be read properly?
Thanks.
- kshannon
- March 22, 2010
- Like
- 0
- Continue reading or reply