• dev_force
  • NEWBIE
  • 160 Points
  • Member since 2009

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 35
    Replies
Hi, I have created a simple multi line editor. My business requirement is that I have to add every edited row (item) as a new item in the database. On save event, I get the new items from the screen and in another similar object, I fetch older items from DB and then compare them using a loop. If any row (item) is different, found updated, I insert that into DB. I have wrote the following code (simplified) to achieve this functionality. Unfortunately it gives me the following exception. Would somebody please suggest me some solution to this problem. Thanks,

Shakespeare

 

Code:

<apex:form id="pixelReqForm"> <apex:pageBlock title="Pixel Request Form" id="pixelReqPageBlock"><br></br> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}" reRender="pixelReqTable"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!PixelReq}" var="aPixelReq" id="pixelReqTable"> <apex:column headerValue="Agency"> <apex:inputField value="{!aPixelReq.Agency__c}"/> </apex:column> <apex:column headerValue="Advertiser"> <apex:inputField value="{!aPixelReq.Advertiser__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

======================================================= public class PixelReqFormController { List<PixelReqForm__c> pixelReqList; public List<PixelReqForm__c> getPixelReq () { return pixelReqList; } public PageReference save() { string contractID = ApexPages.currentPage().getParameters().get('contractID'); //Call to comparer method. If some item is found to be updated, only that item(s) will be

// returned and will be inserted into db as new records. pixelReqList = comparePixReqObjs (pixelReqList); if (pixelReqList != null && pixelReqList.size() > 0) { insert pixelReqList; } else { ApexPages.Message myMsg = new ApexPages.message(ApexPages.Severity.INFO, 'There were no changes to save.'); ApexPages.addMessage(myMsg); } return null; } public List<PixelReqForm__c> comparePixReqObjs (List<PixelReqForm__c> newList) { List<PixelReqForm__c> updateableList = new List<PixelReqForm__c>(); List<PixelReqForm__c> oldList; PixelReqForm__c pixelReqObj; //getting older pixel list from DB oldList = [SELECT isDeleted__c, Agency__c, Advertiser__C, BCN__c, Value__C, Web_Page_Name__c, Web_Page_URL__c, OAS_System__c, Pixel_Usage__c, Tag_Security__c, Tag_Type__c, Special_Requests__c, ContracID__c FROM PixelReqForm__c where ContracID__c = :ApexPages.currentPage().getParameters().get('contractID') AND isDeleted__c = false order by agency__c desc]; //Comparing older and newer list for differences. If used has updated something, it will be

//saved as a new record. Otherwise no save operation will be done.

for (Integer i=0; i<oldList.size(); i++) { if (newList[i].Agency__c != oldList[i].Agency__c) { //initializing the object with new values, giving me the subject error. pixelReqObj = new PixelReqForm__c (Agency__c = newList[i].Agency__c,

Advertiser__c = newList[i].Advertiser__c); updateableList.add(pixelReqObj); } } return updateableList; } }

 

 
Is there an equivalent of  $Api.Enterprise_Server_URL_111 in an Apex Class? To get the session Id, I need UserInfo.getsessionid(), but is the only way to get the URL by setting it as a formula field somewhere and retrieve it? I can't see any other way...

Is it safe to use:

 

SELECT Id, Name FROM Account WHERE Name < 'a' ?

 

 

It seems to work... and returns accounts with names like:

$123abc

84888

20-20 Inc

 

I have several triggers on the opportunity object...before insert, before update and before insert, before update.  I need to add a new trigger that fires after the opportunity is updated:

 

trigger OpportuntityAfterUpdate on Opportunity (after update) { List<Opportunity> opps = [Select Id, Transaction_ID__c, Name, StageName, Product_Line_ProDev_Category__c, Opportunity.Account.BillingStreet, Opportunity.Account.BillingCity, Opportunity.Account.BillingState, Opportunity.Account.BillingPostalCode From Opportunity WHERE Id in :Trigger.new]; Set<Id> oppyIds = new Set<Id>(); for (Opportunity o : opps) { oppyIds.add(o.Id); } OpportunityLineItem oli = [Select Site__c From OpportunityLineItem WHERE OpportunityId in : oppyIds LIMIT 1]; if (oli.Site__c <> null) { Account acct = [Select a.Name, a.Id From Account a WHERE a.Id = : oli.Site__c]; for (Opportunity oppy: opps) { if (oppy.StageName == 'Closed Won' && oppy.Product_Line_ProDev_Category__c > 0) { // Create a new single email message object // that will send out a single email to the addresses in the To, CC & BCC list. Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); // Strings to hold the email addresses to which you are sending the email. String[] toAddresses = new String[] {'test@test.com'}; String[] ccAddresses = new String[] {'test@test.com.com',}; // Assign the addresses for the To and CC lists to the mail object. mail.setToAddresses(toAddresses); mail.setCcAddresses(ccAddresses); // Specify the address used when the recipients reply to the email. mail.setReplyTo('test@test.com'); // Specify the name used as the display name. mail.setSenderDisplayName('Salesforce Support'); // Specify the subject line for your email address. mail.setSubject('A new Professional Development order has been placed!'); // Set to True if you want to BCC yourself on the email. mail.setBccSender(false); // Optionally append the salesforce.com email signature to the email. // The email address of the user executing the Apex Code will be used. mail.setUseSignature(false); // Specify the text content of the email. mail.setPlainTextBody('Opportunity Name: ' + oppy.Name + '/n' + 'Transaction ID: ' + oppy.Transaction_ID__c + '/n' + 'Account Name: ' + acct.Name + '/n' + 'Billing Address: ' + oppy.Account.BillingStreet + '/n' + 'Billing City: ' + oppy.Account.BillingCity + '/n' + 'Billing State: ' + oppy.Account.BillingState + '/n' + 'Billing Zip: ' + oppy.Account.BillingPostalCode + '/n'); mail.setHtmlBody('<p>Opportunity Name: ' + oppy.Name + '</p>' + '<p>Transaction ID: ' + oppy.Transaction_ID__c + '</p>' + '<p>Account Name: <a href=https://cs2.salesforce.com/' + acct.Id + '>' + acct.Name + '</a></p>' + '<p><hr /></p>' + '<p>Billing Address: ' + oppy.Account.BillingStreet + '</p>' + '<p>Billing State: ' + oppy.Account.BillingState + '</p>' + '<p>Billing Zip: ' + oppy.Account.BillingPostalCode + '</p>'); // Send the email you have created. Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } } } }

 

The above trigger works by itself, but it is conflicting with the other triggers on the opportunity object.  It is causing the error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY error when a new opportunity is created. 

 

Here are the three existing triggers on the opportunity that are conflicting with the after update trigger:

 

trigger OpportunityBeforeInsert on Opportunity (before insert) { // calculate the "active *" fields on this opportunity's accounts for (Opportunity oppy : Trigger.new) { AccountActivityCalculator.updateAccount(oppy.AccountId); } } trigger OpportunityBeforeInsertBeforeUpdate on Opportunity (before insert, before update) { // grab owner's ID and push it into Commission_Salesperson__c (since Owner fields are not available in formula lookups) for (Opportunity opp : Trigger.new) { if(opp.Commission_Salesperson__c == null) { opp.Commission_Salesperson__c = opp.OwnerId; } } } trigger OpportunityAfterInsert on Opportunity (after insert) { List<Opportunity> opps = [select Id, Invoice_Preference__c, Account.Invoice_Preference_Value__c, Account.Sales_Area__c, Account.FOB_Destination__c, Account.District_Active_Sites__c, Account.District_Active_Subscriptions__c from Opportunity where Id in :Trigger.new]; for (Opportunity oppy: opps) { // copy over fields from account that should be historically accurate (i.e. can't be done via formulas) oppy.Invoice_Preference__c = oppy.Account.Invoice_Preference_Value__c; if (oppy.Payment_Terms__c == '') { // user is a salesperson, did not enter it; copy from Account oppy.Payment_Terms__c = oppy.Account.Payment_Terms__c; } oppy.FOB_Destination__c = oppy.Account.FOB_Destination__c; oppy.Sales_Area__c = oppy.Account.Sales_Area__c; oppy.Active_Sites__c = oppy.Account.District_Active_Sites__c; oppy.Active_Subscriptions__c = oppy.Account.District_Active_Subscriptions__c; } update opps; }

 

How can I get around this conflict and fire the after update trigger successfully?
Message Edited by Dman100 on 04-21-2009 09:51 AM
I have a Cronkit job scheduled to run every night, and it has been doing fine for weeks, but last night 4 of the scheduled jobs did not run, and gives a message :

FutureRequests Request Limit exceeded.

 

What does this mean?

I am trying to design a visualforce page tha creates Account, Contact, and Opportunity records. I also am needing to send values to a custom object. The problem is that I cannot find the correct syntax to pull the field from the custom object.

 

for example

Standard is {!Opportunity.Name}

Custom is ???

 

I have read about the term "MyCustomObject__c" but cannot get it to work.

 

Can anyone help?

 

 

I have a created a VF Page that supposed to replace the activity history section in the contact page layout related list. Although I can see it in the page layout, it won't let me add it to the related list section.

 

public class ActivityController {
    private final Contact cont;

    public ActivityController (ApexPages.StandardController stdController) {
        this.cont = (Contact)stdController.getRecord();
}

    public PageReference newTaskforCall()
    {
        PageReference NewTaskPage = new PageReference('/00T/e?title=Call&who.id=' + System.currentPageReference().getParameters().get('id') + '&followup=1&tsk5=Call&retURL=%2F003R000000ArDZn');
        NewTaskPage.setRedirect(true);
        return NewTaskPage;
    }


    public String hasNext { get; set; }

    public PageReference next()
    {
        return null;
    }


    public String getHasPrevious()
    {
        return null;
    }


    public PageReference previous()
    {
        return null;
    }

        Public Task[] getActivities()
        {
                return [Select id, subject, what.name,activitydate, owner.name, lastmodifieddate from Task where whoid = :System.currentPageReference().getParameters().get('id') and calldurationinseconds > 0];
        }

        public Contact getContact()
        {
                return [Select id, name
                        from Contact where id = :System.currentPageReference().getParameters().get('id')];


        }
}

 

 

 

 

 

 

 

   

<apex:page standardController="Contact" extensions="ActivityController" tabstyle="Contact" sidebar="false">

  <apex:form id="myform">

    <apex:pageBlock title="Cal History" >

    <apex:pageblockButtons >

    <apex:commandButton value="Log Call" action="{!newTaskforCall}">

    </apex:commandButton>

    </apex:pageblockButtons>

    <apex:pageBlockSection title="" columns="5" collapsible="true">

    <apex:panelGrid columns="2" id="navigation">

    </apex:panelGrid>

    <apex:dataTable value="{!Activities}" var="each" border="0" styleClass="list">

        <apex:column headerValue="Subject"><a href="/{!each.id}">{!each.subject}</a></apex:column>

        <apex:column headerValue="Related To"><a href="/{!each.what.Name}">{!each.what.Name}</a></apex:column>

         <apex:column headerValue="CSD"><a href="/{!each.owner.id}">{!each.owner.Name}</a></apex:column>

        <apex:column headerValue="Due Date">{!each.ActivityDate}</apex:column>

        <apex:column headerValue="Last Modified Date/Time">{!each.lastmodifieddate}</apex:column>

    </apex:dataTable>

    </apex:pageBlockSection>

    </apex:pageBlock>

  </apex:form>

</apex:page>

I am having a problem with the following code. My problem is that some of the fields are able to be edited and saved and some are not. My goal here is just  have a VFpage where the uses can edit these records and save them using the My Save button. 

 

But if I change the fields and try to save, some of them save and some of them don't. Am I doing something wrong?

 

Controller code:

 

public class RasmussenEnrollmentClass_Ver3 { // Declare standardController controller private ApexPages.StandardController controller; private EA__c enrollment; // Will help us determine whether to do Insert or Update upon Save private Boolean bUpdate; public RasmussenEnrollmentClass_Ver3(ApexPages.StandardController stdController) { this.controller = stdController; this.enrollment= (EA__c)stdController.getRecord(); //if the pos.id is null that means this is an insert of a new obj, not and edit bUpdate = enrollment.id == null ? false : true; } public PageReference myEA() { if ([select Id FROM EA__c WHERE Student_Name__c=:userinfo.getuserid()].size() > 0) { EA__c eaID= [select Id FROM EA__c WHERE Student_Name__c=:userinfo.getuserid()]; PageReference pg= new PageReference('/apex/RasEA_1?id='+eaId.Id); pg.setRedirect(true); return pg; } else { //If size is 0 it means there is no Enrollment Agreement record. The admin assistant did not make one yet. //In this case, redirect the user to a page which says to please wait while their EA is processed PageReference pg1= new PageReference('/apex/NoEnrollment'); pg1.setRedirect(true); return pg1; //This was just a test for trying to let the student do a blank form if the EA was not created by the Admin yet //The following should not be used // PageReference pg= new PageReference('/apex/RasmussenEnrollmentPage_Fix?id='+eaId.Id); /// PageReference pg= new PageReference('/apex/RasEA_1'); // pg.setRedirect(true); // return pg; } } public PageReference mySave(){ // This is contrived unless there is something to do special in the update or insert you're trying to do // if you're not doing anything special in the save then just use the standardController.save() // if (bUpdate){ try { update enrollment; } catch(System.DMLException e) { ApexPages.addMessages(e); System.debug(e); return null; } return null; } }

 

 VF Page

 

<apex:page sidebar="false" showHeader="false" standardController="EA__c" extensions="RasmussenEnrollmentClass_Ver3"> <apex:form id="theForm"> <apex:pageBlock > <apex:pageBlockButtons > <apex:commandButton value="My Save" action="{!mySave}"/> <apex:commandButton value="Cancel" action="{!cancel}" immediate="true"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="2"> <apex:inputField id="FirstName" value="{!EA__c.First_Legal_Name__c}" required="FALSE"/> <apex:inputField id="LastName" value="{!EA__c.Last_Legal_Name__c}" required="FALSE"/> <apex:inputField id="SSN" value="{!EA__c.Social_Security_Number__c}" required="FALSE"/> <apex:inputField id="DOB" value="{!EA__c.Date_of_Birth__c}" required="FALSE"/> <apex:inputField id="Phone" value="{! EA__c.Phone_Number__c}" required="FALSE"/> <apex:inputField id="Phone2" value="{! EA__c.Secondary_Phone__c}" required="FALSE"/> <apex:inputField id="Address1" value="{! EA__c.Address_1__c}" required="FALSE"/> <apex:inputField id="Address2" value="{! EA__c.Address_2__c}" required="FALSE"/> <apex:inputField id="City" value="{! EA__c.City__c}" required="FALSE"/> <apex:inputField id="Country" value="{! EA__c.Country__c}" required="FALSE"/> <apex:inputField id="Email" value="{! EA__c.Email__c}" required="FALSE"/> <apex:inputField id="Maiden" value="{! EA__c.Maiden_Name__c}" required="FALSE"/> <apex:inputField id="Phone3" value="{! EA__c.Phone__c}" required="FALSE"/> <apex:inputField id="State" value="{! EA__c.State__c}" required="FALSE"/> <apex:inputField id="Zip" value="{!EA__c.Zipcode__c}" required="FALSE"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

 

 

 

Hi all,

 

I have a problem with @future annotations. I need to do to different call outs when a new Lead is created, the first call out is to a webservice(webservice1) that returns a parameter needed for the callout to the webservice. I know that Future method cannot be called from a future method... what is the best solution to handle this?

 

Thanks

Hi,

 

Would like to ask how to set a field to readonly immediately when a checkbox is checked on standard object Edit page.

 

Can this be done by using VisualForce?

 

Thanks.

I would like to query the possible values for a picklist to put up a mutli-select field on my page.  Is there a way to query for the possible values for a simple picklist?

 

Also, I'd like to do the same for a multi-select picklist.  I know this was asked before and it wasn't possible in the past.  Is there any way to do it now?

 

I have a pipeline field that is calculated.  I would like it so when I save an opportunity, it automatically updates the amount field w/ the pipeline field.

 

Is this possible w/o having to create another button?

 

I only have SalesForce Pro.

 

Thanks.

I'm sending an email to a contact which I expect to fail (the contact has NO email address specified):

 

 

 

List<Messaging.SingleEmailMessage> emailList = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage sem = new Messaging.SingleEmailMessage();
sem.setSubject('test subject');
sem.setHtmlBody('testbody');
sem.setSaveAsActivity(false);
sem.setTargetObjectId('003R00000090cra');

emailList.add(sem);


List<Messaging.SendEmailResult> sendEmailResult = Messaging.sendEmail(emailList, false);
System.Debug('@@@@ '+sendEmailResult);

 

 Here is the result that comes back:

 

13:08:57 INFO  - 20090325170853.851:AnonymousBlock: line 13, column 1: @@@@ (Messaging.SendEmailResult[getErrors=(Messaging.SendEmailError[getTargetObjectId=null;]);isSuccess=false;])

 

Why is the SendEmailError object not being fully populated?

 

I would expect the following to be populated:

- getMessage

- getStatusCode

- getTargetObjectId

 

 

Message Edited by dev_force on 03-25-2009 10:13 AM
Message Edited by dev_force on 03-25-2009 10:42 AM
Message Edited by dev_force on 03-25-2009 12:58 PM

When I login,the mail give me the message:  

 

Apex script unhandled exception by user/organization: 00580000001orUz/00D80000000artE

Visualforce 页面: /apex/Start_Here

System.ListException: List index out of bounds: 0

Class.startHereController.getBannerURL: line 59, column 69
External entry point

Debug Log:

***正在开始 /apex/Start_Here 的页面日志

 

How can I cope with it?

Hi,

 

Can anyone tell what is the organization wide SOQL limit per day?

 

Regards,

Hi,

We all know inline Editable fields from the native VF interface. by this I mean a field that looks like "apex: outputfield" but when double clicked, becomes an "apex:inputfield".

I would like to know if there is any way that I could to this myself
(I have a VF page that works on multiple rows of data, using a datatable full of "apex:inputfield" components.

Is there a VF component for that? if not, is there an Idea to create one?

Thanks