• BrianWK
  • NEWBIE
  • 380 Points
  • Member since 2008

  • Chatter
    Feed
  • 15
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 92
    Questions
  • 183
    Replies

Do you know? Can you help?

 

Is it possible to add logic to the Standard Clone button to update a field "Cloned?" to "Yes" on the oppty record when an oppty is cloned?

 

Any feedback or suggestions would be truly appreciated.

 

Hi,

 

I deployed an app into prod before couple of months and all the test classes were fine with no errors with 75% coverage. Today i tried to run a test in my sandbox and a lot of errors were thrown with test % coming down to 48. So, i deployed test classes from prod to the sandbox and tried again, the result is same. Why is this happening though when i run the same test class in prod it has no errors with 75% where as in sandbox a lot of errors are thrown with 48% . Does any body know what is causing the problem or why such problem persists. FYI, my sandbox is not yet been upgraded to summer release and prod too not yet upgraded to summer release. 

 

Thanks.

  • May 31, 2010
  • Like
  • 0

I'm looking to have a trigger that when a lead is created, from a specific web-to-lead form that it will automatically create an activity.  But I'm not sure how to get started and can't seem to find any documentation on how I would do that.

 

I know how to create the trigger on the Leads, and have this for the stub.

 

trigger CreateActivity on Lead (after insert) {

}

Hi community,

 

 I am trying to code a trigger that sets the lead's status after it was converted according to either if or if not a Oppti has been created.

 

It basically would look like this:

 

 

trigger LeadConvertStatusOnLeadUpdate on Lead (before update) {

for (Lead l : trigger.new) {

if (l.ConvertedContactId != null && l.ConvertedOpportunityId == null) {
l.Status = 'Closed - Converted to Contact';
update l;
}

if (l.ConvertedContactId != null && l.ConvertedOpportunityId != null) {
l.Status = 'Closed - Converted to Opportunity';
update l;
}
}

}

 

 But this didn't worked out. It just did not set that value.

I tried to make it a trigger "after update" but that also did not worked. It threw me an error that the lead is read-only.

 

Any ideas?

 

Thanks,

Hannes

 

Message Edited by Sennah on 10-26-2009 09:28 AM
  • October 13, 2009
  • Like
  • 0

I am trying to create a trigger that will take information from a sObject we have created and use it to create a new public event. I found some code for a recurring event and I figured I could tweak it to create the events I am aiming for. The problem is that even though the code compiles fine, when I create a new record in our sObject I can not find the event that was supposed to be created. What am I missing?

 

 

trigger aClassTrigger on LGA__c (after insert) {
Map<String, LGA__c> clasMap = new Map<String, LGA__c>();
// after LGA are inserted
   List<Event> lgaEvents = new List<Event>();// build list in memory
   for (LGA__c clas : System.Trigger.new) {
    date t = clas.LGA_Date__c;
          datetime xStartDate = DateTime.newInstance(t.year(),t.month(),t.day());
   Event event = new Event(
    ActivityDate = clas.LGA_Date__c ,
    RecurrenceEndDateOnly = clas.End_Date__c ,
    RecurrenceStartDateTime = xStartDate,
    RecurrenceType = 'RecursEveryWeekday',
    RecurrenceDayofWeekMask = 1,
    IsRecurrence = TRUE,
    Description = 'Class Event.',
    Event_Type__c = 'Customer Training',
    Call_Objective__c = 'training',
    Location = 'here',
    IsAllDayEvent = TRUE,
    Event_Status__c = 'Not Started',
    Subject = 'Class trigger Event');
    lgaEvents.add(event);  // add to list
   }

}

Hi All,

 

I tried to send an email using the Messaging.singleemail..... but i get the Unauthorized page whenever this line of code executes...

 

I do not find any permissions in the SiteProfile to enable this..

 

Is it like i cannot call this method from a site... Pls suggest...

 

Thanks,

Edwin

Hello,

I see a strange behavior with a Visualforce in my managed package:
1. There is a button on Opportunity that links to a VF page
2. When button is pressed the URL changes to:
https://myprefix.na6.visual.force.com/apex/mypage?scontrolCaching=1&id=0068000000O7yGb
3. VF page has a 'Save' button that has the following code:
PageReference myPage = new PageReference('/' + opportunityId);
myPage.setRedirect(true);                               
return myPage;

basically all it does is redirects a user to an Opportunity screen with the opportunityId.

BUT, when user is redirected to the Opportunity page the URL remains the same (and never changes no matter where you go):
https://myprefix.na6.visual.force.com/apex/mypage?scontrolCaching=1&id=0068000000O7yGb


Thanks,
Shamil

Hi,

 

I'm hoping there's a simple solution to the problem I'm running into. To write my tests so that they are  independent of any organization, I would like to create new test users in my test methods and then use RunAs to verify expected behavior as the different types of users. The problem I'm running into is that if an organization has maxed out their licenses I can't create the users for my tests. Is there anyway to get around this?

 

Thanks in advance for any help!

 

Scott

  • May 13, 2009
  • Like
  • 0
I'm building an edit page for Opportunity Line items.  If a users enters 2 in the QTY field and $10 in the Sell price field I'd like to total field (read only formula field) to update to $20.  Is there any method I could call to get the total to update without saving?  I want to allow the user to be able to cancel and not save their changes hence the reason for not wanting to save after the field values have been changed.

Is there anyway to disable the sidebar and header on default pages (i.e. default edit page).

 

This is what I have:

I have my home page with the header and sidebars.

In the main area, I display a list of things to do (tasks ...)

When I click on one of the items, instead of going to a new page, it just pops up the view or edit page in a section (iframe) below the list.

 

The problem is that the iframe also has the header and sidebar in it.

 

Suggestions?

Thanks.

  • February 18, 2009
  • Like
  • 0

The pkb_contactus_buttons_article component has a CommandButton id="contactUsYesButton" which displays "showFeedbackDialog" modal window.

 

This window asks for the first name, last name, Email and Request type.

 

I'll like to modify this window, but I haven't been able to find where the js is populating the modal.

 

 

I'm assuming it is setup similar to the pkb_feedbackyesno component where the actual content of the modal is defined via visualforce script.

 

Can anyone point me to the right area?

With Spring '12 there's you can now create a case from outlook using the Salesforce for Outlook plugin.

 

This is great, but it can also be a bit frustrating. If you want each indiviual user to have a case "owned" by them after hitting that button, you need to create separate destinations for each user. This means separate configuration for each user. Bleh!

 

So I'm working on a work around. What I've come up with is a Trigger on the EmailMessage. It looks at the FromAddress, grabs the ParentID (case id) and changes the owner to the active Salesforce user with either the Username or Email of the FromAddress. If that fails, it assigns it to the case creator.

 

The gotcha's I've thought of are:

  1. It requires the User to have the Username/Email of the From Address
  2. The assumption is you have only 1 user with that FromAddress as their email or Username
  3. That you want to have it assigned to the Creator if a user isn't found

Here's what I got so far (no test class yet). I appreciate any feedback you have.

 

trigger EmailMessage_CaseCreation on EmailMessage (after insert) {
//Review incoming new cases. If OwnerId = CaseQueue.id then change Owner to CreatedById
    //Name of the queue created
    string QueueName = 'CaseQueue';
    Group CaseQueue = [Select g.Type, g.RelatedId, g.OwnerId, g.Name,g.Id, g.Email  From Group g where g.type = 'Queue' and g.name = :QueueName limit 1];
    set<id> sCaseIDs = new set<id>();
    set<string> sFromAddresses = new set<string>();
    map<id,EmailMessage> mCase2Email = new map<id,EmailMessage>();
    for(integer i=0; i<trigger.new.size(); i++){
        sCaseIds.add(Trigger.new[i].ParentId);
        mCase2Email.put(Trigger.new[i].ParentID, Trigger.new[i]);
        sFromAddresses.add(Trigger.new[i].FromAddress);
    }
    list<Case> lCases = [select id, subject, OwnerId,Createdbyid from Case where id in :sCaseIds];
    if(CaseQueue != null){
        
        if(mCase2Email.size()>0){
            map<string, user> mEmail2User = new map<string, user>();
            For(User u :[Select id, Username, Email From User where IsActive = True and (Username in:sFromAddresses or Email in: sFromAddresses)]){
                system.debug('User added to map: ' + u.email);
                mEmail2User.put(u.email.toLowerCase(), u);
                mEmail2User.put(u.Username.toLowerCase(), u);
            }
            for(integer i=0; i<lCases.size(); i++){
                if(lCases[i].OwnerID == CaseQueue.id){                
                    system.debug('Email From Address is: ' + mCase2Email.get(lCases[i].id).FromAddress);
                    User u = new user(); 
                    u = mEmail2User.get(mCase2Email.get(lCases[i].id).FromAddress.toLowerCase());
                    system.debug('User: ' + u);
                    if(mEmail2User.get(mCase2Email.get(lCases[i].id).FromAddress.toLowerCase()) != null){
                        system.debug('Found User!: ' + mEmail2User.get(mCase2Email.get(lCases[i].id).FromAddress.toLowerCase()).id);  
                        lCases[i].OwnerID = mEmail2User.get(mCase2Email.get(lCases[i].id).FromAddress.toLowerCase()).id;
                    }else{
                        system.debug('Created by: ' + lCases[i].CreatedbyId);
                        lCases[i].OwnerID = lCases[i].CreatedbyId;
                    }
                    system.debug('Owner Changed! ' + lCases[i].OwnerID);
                }
            }
            update lCases;
        }else{system.debug('NO EMAILS FOUND');}
    }
}

 

 

 

Hopefully that subject makes sense.

 

I'm having a puzzling issue. This issue cannot be reproduced on purpose and my debug logs haven't shown anything to hint what's going on. Here's the scenario:

 

I have a visualforce page that is intended to build up a series of Sobjects and then insert those Sobjects with a single DML. The user enters each item in called "NewProduct" which is then added to the list<sobjects>. The new Product is then "reset" for the user to enter a new one -- based on the previous values.


The goal is to give the user the capability to enter a new record, have the system perform a series of client side (javascript) calculations, add the records to a "product cart" and then save the whole cart to the server.

 

This works... most of the time. Every now and then the list of sobjects - or my "product cart" - has one of the items in the list over-written by the incoming "NewProduct." It doesn't happen all the time. I can't reproduce it, and I'm not sure what I'm doing wrong in my code that could cause this problem.

 

So with no further ado - here's the method in the controller that is "adding" the product to the cart:

    public void AddProduct()
    {       
        //values of current New Product
        system.debug('Starting Values of NewProduct!');
        
        system.debug('UQ: ' + NewProduct.Unit_Quantity__c);		
        system.debug('UP: ' + NewProduct.Unit_Price__c );
        system.debug('TAP: ' + NewProduct.Total_Amount_Paid__c );
        system.debug('SD: ' + NewProduct.Start_Date__c);         
        system.debug('ED: ' + NewProduct.End_Date__c );
        system.debug('ARRT: ' + NewProduct.Annualized_Rec_Rev_Term__c);
        system.debug('MRP: ' + NewProduct.Monthly_Recurring_Price__c );
        system.debug('ARP: ' + NewProduct.Annual_Recurring_Price__c );        
        system.debug('OTP: ' + NewProduct.One_Time_Price__c);
        
        ID UIProd = NewProduct.Contract_Product__c;
        date StartDate = NewProduct.Start_Date__c;
        date EndDate =   NewProduct.End_Date__c;
		integer UQ = integer.valueof(NewProduct.Unit_Quantity__c);		
        decimal UP = NewProduct.Unit_Price__c ;
        decimal TAP = NewProduct.Total_Amount_Paid__c;
        decimal CA = NewProduct.Capped_Amount__c;
         
        UpdatedField = 'All';

        system.debug('Size after variable: ' + prods.size());
        system.debug('NewProduct to Add: ' + NewProduct);
 
        if(Schedule =='Month')
        {
            //NewProduct.Annual_Price__c = (getPriceBookOpp().Amount / NewProduct.Quantity__c);
        }
        prods.add(NewProduct);      
		/* Add NewProduct into ProductCart */
		ProductCart.add(new cProd(NewProduct));
        for(cProd cp :ProductCart)
        {
            if(cp.vname == 'changeme')
            {
                cp.vname = string.valueof(counter)+ string.valueof(NewProduct.Contract_Product__c);
            }
        }
        counter = counter+1;
        ID AccountID = NewProduct.Account__c;
        ID ProductID = NewProduct.Contract_Product__c;

        boolean NewClient = NewProduct.New_Client__c;
		/* Next 3 lines Clone Product to "Reset" new product with same values */
        Contract_Product__c TempProduct = NewProduct.clone(false,true,false, false);
        NewProduct = new Contract_Product__c(); 
        NewProduct = TempProduct.clone(false,true,false, false);          

    }   

/*Wrapper Class and Product Cart Methods */
    
    public class cProd
    {
        public Contract_Product__c Prod {get; set;}
        public Boolean cSelected {get; set;}
        public string vName {get; set;}
        
        public cProd(Contract_Product__c p)
        {
            Prod = p; //Contract Product object
            cSelected = false; //Selected Checkbox
            vname='changeme';                        
        }
    }   
    private list<cProd> ProductCart {get;set;}  
    
    public list<cProd> getProductCart()
    {           
        system.debug('This is the getProductCart: ' +ProductCart);
        return ProductCart;
    }

 

Anyone see what I'm doing wrong here to cause my problem? Anyone have suggestions on how to make this better?

Hey folks, I'm having some real difficulty here.

 

Here's what I'm trying to do. My goal is to have very quick client-side "warnings and errors" messages display on a VF page. Going to controller and back everytime users are entering data simply takes way too long.

 

I'm already using Javascript on that page to handle some client-side calculation. So I'm planning on also using Javascript to Identify when a data error has occured and then display text within a output panel. I want this text red, bold and centered on the page.

 

I've been able to get the text to display in an output panel, be bold and red - but I can never get it to be centered.

 

Here's a slimmed down version of what I got.

 

<apex:page standardcontroller="Contract_Product__c" extensions="Contract_Product_Add_Extension_jquery" id="page">
	<apex:form rendered="{!Master.AccountID != null && Master.Lock_Status__c != 'Locked' || $Profile.Name == 'System Administrator'}" id="ProductForm">
		<apex:outputpanel id="SelectContractProducts" layout="none">
			<apex:pageblock id="ContractProductsBlock" title="Select Contract Products"  rendered="{!Display}">
				<apex:outputpanel id="Warnings" >
					<table width="100%" id="WarningsTable">
						<tr id="WarningsRow">
							<td id="WarningsCells">
							</td>
						</tr>
					</table>
				</apex:outputpanel>
			</apex:pageblock>
		</apex:ouputpanel>
	</apex:form>
</apex:page>

 

If I remove the WarningsTable (and all chidlren) I can update the OutputPanel "Warnings" succesfully with

document.getElementById('{!$Component.page.ProductForm.ContractProductsBlock.Warnings}').innerHTML

 However trying to update the table I've been unsuccessful in getting the Table, Row, or Cell IDs. The only reason I'm using a table is to get the text to be centered.

 

Anyone provide some guidance? I either need to get the text centered in the output panel so it's centered within the pageblock or I need to get to the TD value so I can add and delete warnings.

I have a batch class that accepts a query string.

 

I"m testing the function and want to pass over a query to the batch for very specific records that I can test. I would like to pass over either a single id or a set.

 

Can I format a query string to include the single quotes necessary when formatting a filter for a single ID? I know I could modify the class to include another variable but I would rather not. I'm only doing this as a test and wouldn't actually use that variable ever again after the test.

 

For example:

 

I want: 
Select MyFied__c from Contract where id = '8003000000021gz';

but as a string literal:

string q = 'select MyField__c from Contract where id =' .... 

 

I must be doing something very simply stupid.

 

I have two JS Functions, one takes a single variable and a second JS function that takes two variables.

 

All of these variables are in my Apex Controller and updated based on user input. I can't just call the variable directly in the function because it only get's set on the page load and not when a user makes an update.

 

For my first JS function with only 1 varilable I call using an ActionFunction that calls the PageReference to update the variable in the Controller and then calls my JS Function oncomplete and passes the variable to the JS Function.

 

Like this:

  <apex:actionFunction name="DurationCalculate" action="{!CalDuration}" rerender="Rec_Rev_Term,PanelTesting" oncomplete="setARRT({!duration})" >
  </apex:actionFunction>

<script type="text/javascript">
	function setARRT(duration)
	{		
		var months = duration;
		
		//set ARRT data
		document.getElementById('{!$Component.page.ProductForm.ContractProductsBlock.pbs.pbsiARRT.OutputARRT_m}').innerHTML = months;
	}
</script>

 This works perfectly!

 

So I tried doing this with my function that takes two variables. The actionfunction gets called but the actual JS function isn't.

 

  <apex:actionFunction name="CalPriceType"  rerender="PanelTesting" oncomplete="setPrices({!duration},{!Price_Type})" >  																				 
  </apex:actionFunction>	

<script type="text/javascript">
	function setPrices(duration,PriceType)
	{
		if(PriceType == 'Recurring')
		{
			.... do this
		}
		return false;
	}
</script>

 What am I doing wrong? Both {! duration } and {! Price_Type} can change base on the user input. The values are set correctly in the controller.

Okay,

 

I'm feeling incredibly stupid here. I've been using a Apex Class to handle a lot of the calculations for a page. This works and it also incredibly slow. There are multiple inputs with each one requiring a series of calculations and partial page re-renders. This causes a lot of slow down with all the client -> server communication.

 

So, I'm switching to Javascript. I've had some success with all the references and websites out there. I've successfully updated all the calculations that are done on InputText and InputField components. My issue is that this doesn't seem to work on OutputText and Outputfields.

 

Here's a quick example. It's more complex than this but really simply I'm having a javascript function populate InputFields, OutputFields and OutputText after the function is called.

 

<apex:page id="thepage">
<script type="text/javascript">
	function jsUpdateFields(){
		var vnum = 10;
		var vdollar = 5;
		var vtext = 'hello';
		
		document.getElementByID('{!Component.thepage.theform.thepageblock.InputField}').value = vnum;
		document.getElementByID('{!Component.thepage.theform.thepageblock.OutputField}').value = vdollar;
		document.getElementByID('{!Component.thepage.theform.thepageblock.OutputText}').value = vtext;
		return false;
	}
</script>
	<apex:form id="theform">
		<apex:pageblock id="thepageblock"
			<apex:inputfield value="{!Myobject.MyNumber__c}" id="InputField" />
			<apex:outputfield value="{!MyObject.MyCurrency__c}" id="OutputField" />
			<apex:outputtext value="{!MyObject.CustomText__c}" id="OutputText" />
		<a href="#" onclick="jsUpdateFields()">Run Javascript</a>
		</apex:pageblock>		
	</apex:form>
</apex:page>

 What happens: The inputfields update perfectly. The outputField and OutputText have no updates. If I change those components to inputs they work fine.

Here's the thing I don't want to have those to be inputs.

 

I've also tried using an apex function that calls the javascript function and then rerenders an outputpanel where my output fields are located. This also doesn't seem to work.

help! and thank you

So I'm creating my first functions in Javascript for visualforce.

 

I started by created the script directly on the page. This works and it takes a large amount of space.

 

So instead I planned on creating a bunch of functions and uploading those as a static resource. Then have a single script on the page that calls the functions and sets the element id.

 

When everything is on the page directly it works fine. The moment I remove my functions and upload to a static resource I get a syntax error.

 

Here's a sample of a really simple function. It accepts to variables, multiples them, and returns the result.

 

<script type="text/javascript">
	function TAPCalculate(UQ, UP){		
		var P = UQ * UP;		
		return P;
	}
</script>

 

I created this .js file and then uploaded as a static resource called 'Contract_Calcs"

 

My visualforce page then has an include script:

<apex:includeScript value="{!$Resource.Contract_Calcs}"/>

 

And then I call this function from the script on my page. I don't even get to the point of calling the function and instantly get a syntax error in firebug. Firebug states my first line of the function is wrong. That's the var P = UQ * UP;

 

It works on the page -- why doesn't it work when I upload it as a static resource?

 

 

Ok,

 

So I've been using a controller to do a bunch of math functions on Inputfields on my page. The response of the page has degraded quite a bit so I decided to move my math functions to jquery.

 

So I'm starting with my simpliest formula where I have an inputfield for Unit Quantity, Unit Price, and Total Amount Paid.  So I created this function:

 

<script type="text/javascript">
	$j = jQuery.noConflict();
	function jsCalculate(){
		var UQ = document.getElementById('{!$Component.page.theform.ContractProductsBlock.pbs.pbsiUQ.InputUQ}').value;
		var UP = document.getElementById('{!$Component.page.theform.ContractProductsBlock.pbs.pbsiUP.InputUP}').value;
		var P = UQ * UP;
		document.getElementById('{!$Component.page.theform.ContractProductsBlock.pbs.pbsiTAP.InputTAP}').value = P;
}
</script>

 

So Here's what I'm having issues with. If I set the InputTAP value to UQ or to UP i get the correct number when the function is called. However when I try to assign it to P or do the math directly in the value set (InputTtap.value = UQ * UP)

I get an "NaN" error message instead of the product.

What am I doing wrong here? The function is being called and I'm getting the right values from my input fields but the math portion seems to fail.

 

 

Okay, so here's my scenario.

 

I have a custom object called "Contract Product." I've estentially built a "shopping cart" page where users can select a Product via a drop down, enter some Dollar and dates and "Add to Cart." This way they can add multiple products into the cart and they all get "saved" to the server in bulk (vs one at a time). 

 

Part of the aspect of this cart is a number of fields. As specific fields get modified the page updates other fields with new values based on some calculations. Right now all my calculations are in a separate Class called by my custom controller. This is nice in case I have to update the math I can modify the methods. Plus I can use this class for other pages doing the same calculation.

 

Here's the simple example. We have three fields:

  • Unit Quantity
  • Unit Price
  • Total Amount Paid

When Unit Quantity is changed, the page re-renders the Total Amount Paid with the new value (Unit Quantity * Unit Price).

When Unit Price is changed, the page re-renders the Total Amount Paid with the new value (Unit Quantity * Unit Price).

When Total Amount Paid is changed, the page re-renders the Unit Price (Total Amount Paid / Unit Price)

 

 

So far what I've done is have each field in an Outputpanel. Each Inputfield also has an ActionSupport component that "onblur" calls a Custom Controll method (Calculate) and re-renders the other fields. I also have a Status on the Action Support so a "waiting" message displays when the Support method is working.

 

This system "works." I've noticed a few challenges and frustrations:

 

  1.  "On Blur" requires the user to leave the field. Sometimes the actionsupport is called sometimes it isn't
  2. This is slow: Each time the Action Support is used it causes a "slow down" in the end-user process. Sometimes the response is really fast -- sometimes it takes 5-10 seconds for the rerender to occur.
  3. Not every re-render gets re-rendered consistently. There are more fields than just the 3 in this sample being used. Sometimes what will happen is that two fields will get updated and re-rendered and 2 other fields won't -- until the next change happens. I know the value is being updated in the controller - what's shown on the page to the end user appears to be either the "wrong" value (it's from a prior edit) or blank.

 

So what's the best way to handle this type of scenario? I've seen people use javascript, jquery, mixture of either with apex. Is there a best practice? What would provide the fastest user experience and the most accuracy?

 

I'm pretty new to using Word Mergefields with Salesforce.

 

I have an if formula that I want to look at the value of a MergeField and either return a blank or the mergefield.

 

This is what I have. The field Name is a Picklist in Salesforce with values of either "Service Fee" or "Subscription Fee"

 

{IF{MERGEFIELD Proposal_line_item_chargetype \* MERGEFORMAT}="Service Fee" "" {MERGEFIELD Proposal_line_item_chargetype \* MERGEFORMAT}}

 

My issue is that the formula ALWAYS returns the "False" value. I've tried simplifing it so it just gives me "ISTRUE" and "ISFALSE" instead of the blank and mergefield and I get the same results.

 

I know the values are exact - I've even copied and paste them. I tried using TRIM to remove any extra spaces. I even tried to use LEFT and TRIM to search for "Service" with no luck. The only time I get this to result to a true value is when I say mergefield = mergefield.

 

So there must be something returning in the mergefield other than "Service Fee" -- but I can't figure out what it is.

 

Anyone have any insight on this? I've tried using other fields  from the same object - Text Formulas, Checkboxes, etc and I can't get any of them to work.

 

HELP! -- and thanks!

We make a lot of customizations to our Salesforce instance. We have tons of custom objects, fields, and Apex code.

 

I'm looking to submit a report to our executive team that shows the usefulness of salesforce and in particular the amount of customization we do for the company.

 

One method I'll like to use is to show the number custom objects and fields we created (by created date) and the last modified date. Being able to filter packaged components would be a bonus. Ideally, I could report on the frequency of edits made to a field or object although that would be icing on top.

 

Is any of this feasible right now? I haven't seen anything in the report types that suggests that it is. I'm currently been trying to track this by hand which hasn't been very easy to keep up to date. I know Salesforce already stories the created and modified dates of the objects and fields so I was hoping a report was possible.

 

Anyone have recommendations on how I can do this? My next stop is going to be the idea exchange otherwise.

 

Thanks!

We recently added a validation rule that requries a Rich Text Field to be filled in when the object is completed. This object is "Implementation" and the field is "Transition_Notes__c"

 

In my test classes where I have completed Implementation objects I've attempted to add Transition_Notes__c so the Validation rule doesn't impact my test class.

 

When I do this, I get "

Error: Compile Error: Invalid field Transition_Notes__c for SObject Implementation__c at line 56 column 9 

"

 

Normally I see this error when I make a typo. I've tried copy and pasting the API name. I've done this using the Apex Class GUI editor in Salesforce. I also tried the IDE in Eclipse using the auto-complete feature. And I still get this error.

 

Here's a snippet:

 

Implementation__c CompletedI1 = new Implementation__c();

        CompletedI1.Stage__c = 'Live (completed)'; 
        CompletedI1.Status__c = 'Completed';
        CompletedI1.Actual_live_Date__c = date.Today();
        CompletedI1.Completed_Date__c = date.Today();
        CompletedI1.Imp_Survey_Recipient__c = c1.id;
        CompletedI1.Transition_Notes__c = 'Filled in';
        update CompletedI1;

 I know the API name is right. I know it's attached to the right variable of the SObject. I can see the field in the Schema. What's going on?

Hey everyone! I hope I can get some thoughts on the best practice of using Outputpanels when rerendering forms and fields. I'm currently creating a form with multiple fields. As each field in the form is updated I refresh a "Warnings" area. The Warnings area is a separate form and intended to prompt the user to make corrections. It acts as an early "soft" validation rule.

 

The desired functionality is when user enters or deletes data on the field, the Warnings area is re-rendered and displays the appropriate warning messages based on the current form data. For an example: I delete the Start Date - the Warning form displays "Start Date is missing." -- I delete Total Price Paid -- The warnings displays "total price paid missing"

 

At one point I thought I had the refreshing working out great. I'm not sure what I did, but the refreshing has stopped working for most instances. I've tried a few different examples to get the refresh to work the way I intended. What frustrates me is the fields within the form being updated rerender just fine, but my Warnings form only seems to rerender when the WHOLE form should disappear. The individual fields no longer rerender.

 

 

Here's a code example using BOTH examples. This is for the warning form.

<apex:form id="WarningsForm" id="Warnings">	
	<apex:pageblock title="Warnings" id="WarningBlock" rendered="{!NewProductValidation}" >
		<table>
		<tr><td>
		<apex:outputlabel value="Date Warnings:" style="font-weight:bold;"/> <br/>
			<apex:outputpanel id="StartNull" rendered="{!NewProduct.Start_Date__c == null}">
			&nbsp; <apex:outputtext value="Start Date is Missing"  /> <br/>
			</apex:outputpanel>
			<apex:outputpanel rendered="{!NewProduct.End_Date__c == null}">
			&nbsp; <apex:outputtext value="End Date is Missing" /> <br/>
			</apex:outputpanel>
			<apex:outputpanel rendered="{!DateError}">
			&nbsp; <apex:outputtext value="End Date is less than or equal to Start Date" /> <br/>
			</apex:outputpanel>
		</td><td></td><td>
		<apex:outputlabel value="Quantity and Price Warnings:" style="font-weight:bold;"/> <br/>
			<apex:outputpanel rendered="{!NewProduct.Total_Amount_Paid__c == null && (NewProduct.Total_Amount_Paid__c >=0)==false}">
			&nbsp; <apex:outputtext value="Total Amount Paid is missing"  /> <br/>
			</apex:outputpanel>		
			<apex:outputpanel rendered="{!NewProduct.Unit_Price__c == null && (NewProduct.Unit_Price__c >=0)==false}">
			&nbsp; <apex:outputtext value="Unit Price is missing" /> <br/>
			</apex:outputpanel>		
			<apex:outputpanel rendered="{!NewProduct.Unit_Quantity__c == null && (NewProduct.Unit_Quantity__c >=0)==false}">
			&nbsp; <apex:outputtext value="Unit Quantity is missing" /> <br/>
			</apex:outputpanel>		
			<apex:outputpanel id="UnitQuantity" rendered="{!NewProduct.Unit_Quantity__c != null && NewProduct.Unit_Quantity__c < 1}">
			&nbsp; <apex:outputtext value="Unit Quantity is less than 1" /><br/>
			</apex:outputpanel>		
		</td></tr>
		</table>		 
	</apex:pageblock>	
</apex:form>

 

And here is a snippet of the form with the fields being populated by the end user:

	<apex:outputpanel id="SelectContractProducts" >
		<apex:pageblock id="ContractProductsBlock" title="Select Contract Products" rendered="{!Display}"  >
			<apex:pageblockbuttons location="bottom">
				<apex:outputpanel id="Addbuttons">
				<apex:CommandButton value="Add to Cart" action="{!AddProduct}" rerender="TheEditPage,table,SelectContractProducts,ProductList, Warnings" rendered="{!Product != '' && NewProductValidation ==false}" status="LoadStatus" /> 
				<apex:CommandButton value="Add to Cart and Default" action="{!AddProductNClear}" rerender="TheEditPage,table,SelectContractProducts,ProductList, Warnings" rendered="{!Product != '' && NewProductValidation ==false}" status="LoadStatus" /> 
				<apex:CommandButton value="Refresh"  rerender="SelectContractProducts"  rendered="false"/>
				</apex:outputpanel>
			</apex:pageblockbuttons>	
				 <apex:pageblocksectionitem >
				 	<apex:outputlabel value="Unit Quantity" />
				 	<apex:outputpanel id="UnitQuantity">
				 	<apex:inputfield value="{!NewProduct.Unit_Quantity__c}" rendered="{!Product != '' || Product != null}">
						<apex:actionsupport action="{!CalculateTotal}" event="onblur" rerender="UnitQuantity, WarningBlock, CappedAmt, Rec_Rev_Term, Addbuttons, TotalPaid, Monthly, Annual, OneTime, Discount" status="status" >
							<apex:param name="Unit_Quantity" value="Unit_Quantity" assignTo="{!UpdatedField}" />
						</apex:actionsupport>
					</apex:inputfield>			
					</apex:outputpanel>
				 </apex:pageblocksectionitem>
				<apex:pageblocksectionitem >				
					<apex:outputlabel value="Unit Price" />
					<apex:outputpanel id="UnitPrice">
					<apex:inputfield value="{!NewProduct.Unit_Price__c}" rendered="{!Product != '' || Product != null}">
						<apex:actionsupport action="{!CalculateTotal}" event="onblur" rerender="CappedAmt, Rec_Rev_Term, Addbuttons, TotalPaid, Monthly, Annual, OneTime, Discount, Warnings" status="status" >
							<apex:param name="Unit_Price" value="Unit_Price" assignTo="{!UpdatedField}" />
						</apex:actionsupport>					
					</apex:inputfield>				
					</apex:outputpanel>					
				</apex:pageblocksectionitem>
				<apex:pageblocksectionitem >				
					<apex:outputlabel value="Start Date" />
					<apex:inputfield value="{!NewProduct.Start_Date__c}" rendered="{!Product != '' || Product != null}" >
						<apex:actionsupport action="{!CalculateTotal}" event="onblur" rerender="StartNull, CappedAmt, test, Rec_Rev_Term, Addbuttons, Monthly, Annual, OneTime, Discount" status="status" >
							<apex:param name="Start_Date" value="Start_Date" assignTo="{!UpdatedField}" />
						</apex:actionsupport>
					</apex:inputfield>					
				</apex:pageblocksectionitem>	   </apex:pageblocksection>   
  </apex:pageblock>
 </apex:outputpanel> 
  	

 

 

It's a fairly long form so I didn't copy and paste everything.

 

I've tried two methods:

 

1. Outputpanel around each field. The rendered attribute is on the outputpanel. When user enters data on the form #2 it rerenders the whole form. Example of this is the "Unit Price" field

2. Outputpanel around each field. The rendered attribute and ID is on the outputpanel. When User enters data on the form #2 it rerenders the specific outputpanel. Example is the "Start Date" rerendering "StartNull"

3. Same scenario as number two but rerenders both the outputpanel and the whole form

 

Other thoughts that I've tried and didn't get to work. Outputpanel on each field. The render attribute is on these outputpanels. All outputpanels are nestled in an Outputpanel with an ID and NO render attribute. When user enter data on form #2 it rerenders the Outter Outputpanel (the one with the ID).

 

What am I doing wrong? What's the best practice I should follow when having multiple pageblocks forms and fields that I need to rerender?

 

Hi everyone!

 

Like many of us, my team has been having some challenges adopting the new Global Search feature. There's lots of great additions to this, but I have some teams that only search Accounts, Contacts, Leads, and Opportunities (Sales). We also have a strong argument for using the old search based on certain features and performance that didn't get carried over to Global Search.

 

Our Challenge? We want to keep Chatter and Global Search.

 

Create a Default Saved Search option:

I posted this on this idea: https://sites.secure.force.com/ideaexchange/ideaView?c=09a30000000D9xtAAC&id=08730000000JRVd

 

This workaround takes advantage of Internet Explorers ability to create "Custom Search Providers"

You can create a custom search provider to save a default Search Option.

For example this URL searches for "TEST" on Accounts, Cases, and Contacts: https://na5.salesforce.com/_ui/common/search/client/ui/UnifiedSearchResults?sen=001&sen=500&sen=003&str=TEST&cache=gfb6ue46

The key here is the "sen=" this appears to reference the 3 character code for the object. The EASIEST way to do this is to click Search Options, Check which objects you want as a default and then save the Search Results URL. I used "TEST" in this example in order to use this URL for my custom search provider.
Here's the URl for the Custom Search Creation. You can also get there by clicking "Find more providers" in the search box (upper right corner of the browser)
http://www.ieaddons.com/en/createsearch.aspx

 

Access Old Search without turning off Global

 

You can access the old search tool using this URL: https://na5.salesforce.com/search/SearchResults

How to use this? Well you could just spread a bookmark around, but what's the fun in that?

You could create a custom search provider using this URL: : https://na5.salesforce.com/search/SearchResults?searchType=1&sen=0&setLast=1&sbstr=TEST&search=+Go

 

But what's the fun in that:)

 

I"m currently planning on creating a either a little Javascript page or if I want to get fancy a VF page that references the above search link. I can then place this little page as a left column homepage component. Viola old search and Global search active at the same time!

 

Why do this?

 

Here's a list of our reasons:

  • Global Search doesn't default to partial word search. You MUST use a wildcard. Old search will automatically do a partial word search. For example: MICH will return completely different accounts in the old search than new search
  • Data overload: Many of our users don't care about all the other objects and records. For instance they don't care if "Paul Lucas" might return in a case comment. They're looking for the contact only. For this group, Global Search returns a bunch of useless data
  • Global Search doesn't sort based on "Best Match" Think of Yahoo & google. If you search for "Paul Lucas" the results at the top will match both "Paul" and "Lucas." With Global search it's in a some order I haven't figured out yet. This means a Case Comment that hits "Lucas" but not Paul will sort above the contact that contains a hit for "Paul" and "Lucas" So what? As an end user having to click that filter list or scroll down is an extra step and it feels like it takes significant more time. Combined the fact that closest matching returns are buried among lots of other records I simply don't care about is frustrating and annoying

Hope this helps everyone!

 

There's some confusion with my test group over what shows up in their feed.

 

I've broken this up into two sections: 1. Following a Team Member and 2. Following an Object Records.

 

This is what I've experienced based on some small tests. Please let me know if this is correct and expected behavior:

 

Following a Team Member

Following a team member I see the following:

  • Changes to that Person's Profile/User via feed tracking -- IE Email Address
  • Status Updates
  • Replies to the team member's status update
  • Posts to the Team Member's Profile page - regardless if I'm following the user who posted

Following an Object Record

  • Posts via Feed Tracking on that Object Record
  • Posts by other team members on that object Record Regardless if I"m following that Team Member
  • Replies to posts from Feed tracking or other team Members

And I think that's it.

 

What I don't see is when a user I'm following causes Feed tracking to update a Object Record that I"m not following. So the only time I'll ever see "Steve updated to the stage to Contracting" is if I'm following that object or I go to Steve's profile page.

 

Is that correct? I somewhat expected I would see the Team Member's posts on Object Records including broadcast from Feed Tracking if I'm following that Team Member. What It looks like here is if I have someone who posts a question on an Opportunity -- only those people following that Opportunity would see it. Which means that for true collaboration - our managers and product managers would have to follow every Opportunity which would quickly be more than 500 records. The only other alternative is the users posts on their profile which we then lose that "history" on the Opportunity -- or we have to have someone request to follow the opportunity. Either seems to be counter productive if you're trying to streamline communicaiton.

 

 

I'm sorry if this isn't the correct board for this topic -- but I didn't see any general Chatter areas to post a non-developer Chatter question.

 

Our Chatter presentation to management got very negative reviews. How do people respond to frustrations that "It's just one more place to document" and "This is just one more time sink to have to respond to people who could get their answers by just researching the object?"

 

We tried to emphasis the collaboration aspect and was dismissed as "not important"

 

What have other people done to get their middle management to buy into the benefits of Chatter?

 

How do you convince them that it's not a "documentation" tool but a collaboration tool?

 

Our Operations Manager, Product Manager, and Marketing representative could see the benefit, but the managers that directly supervise the staff who would be "feeding" chatter and utilizing it found Chatter to be just "one more place" to document. For them, the capability of having "collaboration" by executives is seen as negative because there's just one more place they are obligated to respond to -- when the question could be addressed by looking at the record notes.

Hey everyone.

 

I'm scratching my head on this one. I have a test class with a system asserts. Everything evaluates correctly if I open that Test Class and click "Run Tests."

 

However, when I go to the Apex Classes page and click "Run Tests" across all my test classes -- the system assert fails.

 

I'm having a hard time tracking this down. My expectation would be that the test class would return consistent results. Anyone have any thoughts of where I can begin to look?

I have a fairly big class that I'm testing that requires a lot of data to be created and tested on.

 

Right now I have multiple methods in my test class, that tests separate portions of the class.

 

Do I need to create test objects within each method? Or can I have all my test objects created in my first test method and have them exist throughout the test class?

 

What are best practices for handling test object creation? 

I have a field that I want to be 90% controlled by some APEX code - but I still want the user to be able to select 1 value. All other values would be set by the code.

 

The issue I"m having is setting a validation rule that will either be ignored when updated via the trigger/class or have the Trigger/Class simply ignore the validation rule.

 

I thought I could get this by using "Without Sharing" but I must have mis understood that function.

 

Any thoughts? The closest I got is to put a hidden field that gets turned on by the trigger to ignore the validation, and then have a workflow or an after trigger than turns that field back off. Seems a bit much.

Hi everyone!

 

Like many of us, my team has been having some challenges adopting the new Global Search feature. There's lots of great additions to this, but I have some teams that only search Accounts, Contacts, Leads, and Opportunities (Sales). We also have a strong argument for using the old search based on certain features and performance that didn't get carried over to Global Search.

 

Our Challenge? We want to keep Chatter and Global Search.

 

Create a Default Saved Search option:

I posted this on this idea: https://sites.secure.force.com/ideaexchange/ideaView?c=09a30000000D9xtAAC&id=08730000000JRVd

 

This workaround takes advantage of Internet Explorers ability to create "Custom Search Providers"

You can create a custom search provider to save a default Search Option.

For example this URL searches for "TEST" on Accounts, Cases, and Contacts: https://na5.salesforce.com/_ui/common/search/client/ui/UnifiedSearchResults?sen=001&sen=500&sen=003&str=TEST&cache=gfb6ue46

The key here is the "sen=" this appears to reference the 3 character code for the object. The EASIEST way to do this is to click Search Options, Check which objects you want as a default and then save the Search Results URL. I used "TEST" in this example in order to use this URL for my custom search provider.
Here's the URl for the Custom Search Creation. You can also get there by clicking "Find more providers" in the search box (upper right corner of the browser)
http://www.ieaddons.com/en/createsearch.aspx

 

Access Old Search without turning off Global

 

You can access the old search tool using this URL: https://na5.salesforce.com/search/SearchResults

How to use this? Well you could just spread a bookmark around, but what's the fun in that?

You could create a custom search provider using this URL: : https://na5.salesforce.com/search/SearchResults?searchType=1&sen=0&setLast=1&sbstr=TEST&search=+Go

 

But what's the fun in that:)

 

I"m currently planning on creating a either a little Javascript page or if I want to get fancy a VF page that references the above search link. I can then place this little page as a left column homepage component. Viola old search and Global search active at the same time!

 

Why do this?

 

Here's a list of our reasons:

  • Global Search doesn't default to partial word search. You MUST use a wildcard. Old search will automatically do a partial word search. For example: MICH will return completely different accounts in the old search than new search
  • Data overload: Many of our users don't care about all the other objects and records. For instance they don't care if "Paul Lucas" might return in a case comment. They're looking for the contact only. For this group, Global Search returns a bunch of useless data
  • Global Search doesn't sort based on "Best Match" Think of Yahoo & google. If you search for "Paul Lucas" the results at the top will match both "Paul" and "Lucas." With Global search it's in a some order I haven't figured out yet. This means a Case Comment that hits "Lucas" but not Paul will sort above the contact that contains a hit for "Paul" and "Lucas" So what? As an end user having to click that filter list or scroll down is an extra step and it feels like it takes significant more time. Combined the fact that closest matching returns are buried among lots of other records I simply don't care about is frustrating and annoying

Hope this helps everyone!

 

I have a non-sobject field called "InvoiceDates" in my controller extension. On the VF page there is both an InputTextarea and an outputtext for the same field. The idea is the inputtextarea is pre-populated, but editable by the user. When the user updates that field and clicks a refresh button, they can see a "preview" of the document that will be created.

 

So far things work great for the inputtext area. I placed \n in the string which provides my line breaks. However when I go to output the value it shows up on a single line.

 

Part of method defining string

string vDate = string.valueof(StartDate.Month() +'/'+ StartDate.Day()+'/'+ StartDate.Year()); String Term = 'Term ' + string.valueof(i+2) + ': '; InvoiceDates = InvoiceDates + Term + Vdate + '\n';

VF Page area

 

(this works)

<apex:inputtextarea value="{!InvoiceDates}" id="InvoiceDates" style="width:300px;height:150px"/>

(Output not displaying with line breaks) <apex:outputtext value="{!InvoiceDates}" /> (Also tried) {!InvoiceDates}

 

the component references says outputtext "escape the rendered text if it contains sensitive HTML and XML characters" I'm assuming that using outputtext would "strip" my \n, so I tried just placing the string without an outputtext - but get the same data string line.

 

The only way I have been able to work around this is to create a list<string> instead of a concatenated String. This works on the display, but doesn't work for the user Inputtextarea well. Any suggestions on how I can get my output to include the \n ?

I am just starting to learn about Describe methods because I think it is what I need in order to do what I need to do. I am posting here to see if there are any more skilled developers that can tell me if I'm on the right path. So, here's the deal...

 

Our Contacts are synced with an ERP via Informatica. The ERP is capable of merging Contact records, but Informatica does not seem to be capable of passing those changes down to SFDC. So, I need to make those changes with a trigger.

I have it worked out so when a Merge takes place in the ERP, Informatica will pass the SFID of the master Contact record to the Child contact record. Which I can use to trigger a yet to be written merge class in apex.

 

My first hope was that I could simply use the merge dml statement, but learned that the statement can only do 3 records at atime. In other words, you can't 'bulkify' a merge dml.

 

So, now I am faced with recreating the merge statement. It seems I could do this by simply querying for all of the existing child objects of a Contact record. The problem there is that I will have to remember to add code whenever I add a new object as a child to the Contact object.

 

So, it seemed like a good opportunity to learn about the Describe methods.

 

My question is...Is this possible? Would it be possible to get a list of Contacts from a trigger, and use the Describe methods to dynamically query for all of the child objects of each Contact, and then actually make updates to the records in those child objects?

 

Thanks,

Andy

 

Hi all - I've got a custom object for which there are two basic kinds of records, parents and children. There is a same-object Lookup field on that object that looks up to the object called Object_Self_Lookup__c. I want to use this to relate the children to the parents. 

 

The object also has an external Id called External_Id_Field__c.

 

I'm generating large batches of these records in a scheduled Apex class, and maintaining two different lists, one of parents, one of children. Each record, no matter the type, is assigned a unique value to External_Id_Field__c.

 

My goal is that I can insert the list of Parent records first, having set all their external ids, and then insert the list of children, and have the lookup to the parent record resolved by way of the external Id. I've like to avoid adding a trigger, or making a second pass to get the reference set if it's possible.

 

Is this possible? If so, what am I doing wrong here? This is simplified version of my full code, but this doesn't work either.

 

Thanks!

 

List<Custom_Object__c> parentList = new List<Custom_Object__c>();
List<Custom_Object__c> childList = new List<Custom_Object__c>();

Custom_Object__c objOne = new Custom_Object__c();
objOne.External_Id_Field__c = '1234';
parentList.add(objOne);

Custom_Object__c objTwo = new Custom_Object__c();
objTwo.Object_Self_Lookup__r = objOne;
childList.add(objTwo);

insert parentList;
insert childList;

 

Hey all,

 

So I have come to a bit of an impass in a trigger I am writting. It may be because it's early and I can't think yet, but I am just not quite sure how to logically solve this problem.

 

Here is the deal, this trigger is responsible for updating a contact associated with a task. When the task is saved, the status field is checked. If the task is completed, an associated date field on the related contact is set to the completion date on the task (if the date to be used for the update is later than the one currently existing). This is to keep track of things such as 'Last stay in touch call', 'Last meeting', etc. The tasks represent interactions with a contact, and when the task is completed they want to mark the contact so they know the last time that kind of action was performed. I have this working perfectly currently.

 

Where it gets complicated is if a task is deleted. They have decided that they want the information to 'roll back' if a task is deleted. They want the field on the contact to be 'recalculated' to find the task that is now the newest that applies to the field that just got deleted. So if the most recent task that set the 'last stay in touch call' gets deleted, they want the system to find the next most recent and use that. This is where I am a bit stuck. The only approach I can think of (while keeping it bulk friendly) is something like:

 

1) Query for all tasks associated with any contact that appeared in this list of newly deleted tasks.
 

2) Iterate over every task. Look to see if the 'Activity_Type__c' matches that of the task that just got deleted for this contact.
 

3) If it is a match on the field, check to see if it most recent than any other entry (could probably eliminate this by sorting the query by the date, and skipping duplicates in my loop). 

 

4) Using the list of tasks, continue with the trigger logic as normal.

 

The issue I have here is, what if one contact is getting multiple tasks deleted at one time? Because when I am iterating through the list of tasks for every contact, I'd have to iterate over every task for them in the trigger context, then find a matching task in the query I just ran, and... argh it gets so complicated and cumbersom. Also, this approach seems excruciatingly inefficient. Does anyone have any better ideas? Below is my code thus far so you can see where I am at. Thanks so much!

 

/**********************************************
Name: ContactActivityRecordTrigger
Author: Daniel Llewellyn
Date 3/14/2012
Description: Will update a contact related to a task when a task is completed. The contact has various date fields that may
                          be populated based on the type of task. Updates performed by the elquoa marketing tool or anyone from 
                          marketing do not fire these updates
***********************************************/                          

trigger ContactActivityRecordTrigger on Task(after insert, after undelete, after update) 
{
    
    try
    {    
        list<Task> tasks;
        if(Trigger.Isundelete)
        {
            tasks = trigger.old;
        }
        else
        {
            tasks = trigger.new;
        }
        //create map of contacts that will contain contacts to update
        map<Id,Contact> contactMap = new map<id,Contact>();
        
        //create a map of users that contain the names of the users related to the tasks.
        map<Id,User> userMap = new map<id,User>();
        
        //we will need to find the DS_Role__c field for all the contacts. So create a map of the contact id, to the contact record
        //so we can run one query, and populate them map, then get the contact details when we need them later without needing
        //to have a query in our loop.
        for (Task thisTask: tasks) 
        {
            //we are only interested in this task if it has a contact, so no contact, just skip adding an entry for this task.
            if(thisTask.WhoId != null)
            {
                contactMap.put(thisTask.WhoId,null);
            }
            if(thisTask.OwnerId != null)
            {
                 userMap.put(thisTask.OwnerId,null);
            }
        }
        
        //populate the map with the id of the contact, then the details about that contact.
        for(Contact con : [select id, DS_Role__c,Last_Meeting_Sales_Call__c,Last_Call__c,Last_Email__c,Last_Demo__c,Last_Mass_Email__c,Last_Sent_Info__c,Last_Marketing_Activity__c from contact where id in :contactMap.keySet()])
        {
            contactMap.put(con.id,con);
        }
    
        //populate the map with the id of the contact, then the details about that contact.
        for(User usr : [select id, Name from User where id in :userMap.keySet()])
        {
            userMap.put(usr.id,usr);
        }
       
       //if this is a delete trigger, the current list of tasks has actually been deleted, so we need to find
       //the task that is now the most recent for each user of the same type that just got deleted
       if(trigger.isDelete)
       {
           //find all the tasks for all the users
           list<task> allTasks = [select id, WhoId, OwnerId,Status,Activity_Type__c, ActivityDate from task where whoId in :contactMap.keySet() order by ActivityDate desc ];
           
           //so now I have to loop over all the tasks I just fetched, and then find all the tasks for the associated contact and see if there is a match and.... arg I have no idea.
           for(Task task : allTasks)
           {
           
           }
       }
       
        //iterate over every task passed in
        for (Task thisTask: tasks)     
        {
            //if this task does not have a contact related to it, then just skip this task and continue.
            if(thisTask.WhoId == null)
            {
                continue;
            }    
            
             //create a reference to the contact associated with this task that we will update
            Contact thisContact =contactMap.get(thisTask.WhoId);
    
            //create a reference to the owner associate with this task
            User thisUser = userMap.get(thisTask.OwnerId);
           
            date activityDate;
            if( thisTask.ActivityDate != null)
            {            
                activityDate = thisTask.ActivityDate;
            }
            else
            {
                activityDate = Date.newInstance(thisTask.LastModifiedDate.year(),thisTask.LastModifiedDate.month(),thisTask.LastModifiedDate.day()); 
            }
            //check if the task status is completed
            if (thisTask.Status.toLowerCase() == 'completed') 
            {                
                //make sure the owner of the task is not eloqua marketing, and make sure the contact's role is not marketing/communications
                if (thisUser.Name.toLowerCase() != 'eloqua marketing' && thisContact.DS_Role__c != 'marketing/communications') 
                {
                    if (thisTask.Activity_Type__c == 'Meeting/Sales Call' && (activityDate > thisContact.Last_Meeting_Sales_Call__c || thisContact.Last_Meeting_Sales_Call__c == null) ) 
                    {
                        thisContact.Last_Meeting_Sales_Call__c = activityDate;
                    }
                    else if (thisTask.Activity_Type__c == 'Call' && (activityDate > thisContact.Last_Call__c ||  thisContact.Last_Call__c == null))
                    {
                        thisContact.Last_Call__c = activityDate;
                    }
                    else if (thisTask.Activity_Type__c == 'Email' && (activityDate > thisContact.Last_Email__c || thisContact.Last_Email__c == null))
                    {
                        thisContact.Last_Email__c = activityDate;
                    }
                    else if (thisTask.Activity_Type__c == 'Demo' && (activityDate > thisContact.Last_Demo__c || thisContact.Last_Demo__c == null)) 
                    {
                        thisContact.Last_Demo__c = activityDate;
                    }
                    else if (thisTask.Activity_Type__c == 'Mass Email' && ( activityDate > thisContact.Last_Mass_Email__c || thisContact.Last_Mass_Email__c == null)) 
                    {
                        thisContact.Last_Mass_Email__c = activityDate;
                    }
                    else if (thisTask.Activity_Type__c == 'Sent Info' && ( activityDate > thisContact.Last_Sent_Info__c || thisContact.Last_Sent_Info__c == null ))
                    {
                        thisContact.Last_Sent_Info__c = activityDate;
                    }
                    else 
                    {
                        if (thisTask.ActivityDate > thisContact.Last_Marketing_Activity__c || thisContact.Last_Marketing_Activity__c == null) 
                        {
                            thisContact.Last_Marketing_Activity__c = activityDate;
                        }          
                    }
                }
            }
            contactMap.put(thisContact.id,thisContact);
        }
   
        //we don't need an all or nothing update, so use database.update with the all or nothing flag set to false
        if(!contactMap.values().isEmpty())
        {
            database.update(contactMap.values(),false);
        }
    }    
    catch(exception e)
    {
        system.debug('Error occured updating related contact' + e);
        
        //Send an email to the admin after an error occures
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {'Kenji776@gmail.com'};
        mail.setToAddresses(toAddresses);
        mail.setSubject('Error in ContactActivityRecordTrigger');
        mail.setPlainTextBody('An error occured while running the trigger.' + e.getMessage() + ' On Line Number ' + e.getLineNumber());
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });        
    }    
    
}

 

Hi all,

 

I'm trying to get my Siteforce page to connect to a custom object in Salesforce. I've added a repeater and a repeater element, and I'd like to get the repeater element to display data from a custom field on my custom object. However, the only fields which show up for connecting are the standard and system fields on the object.

 

The same is true for the repeater itself, when setting up a Filter, and also for Custom Code elements - only standard fields, not custom. Surely there's a way of doing this that I'm missing?

 

Thanks,

Hetty

Hopefully that subject makes sense.

 

I'm having a puzzling issue. This issue cannot be reproduced on purpose and my debug logs haven't shown anything to hint what's going on. Here's the scenario:

 

I have a visualforce page that is intended to build up a series of Sobjects and then insert those Sobjects with a single DML. The user enters each item in called "NewProduct" which is then added to the list<sobjects>. The new Product is then "reset" for the user to enter a new one -- based on the previous values.


The goal is to give the user the capability to enter a new record, have the system perform a series of client side (javascript) calculations, add the records to a "product cart" and then save the whole cart to the server.

 

This works... most of the time. Every now and then the list of sobjects - or my "product cart" - has one of the items in the list over-written by the incoming "NewProduct." It doesn't happen all the time. I can't reproduce it, and I'm not sure what I'm doing wrong in my code that could cause this problem.

 

So with no further ado - here's the method in the controller that is "adding" the product to the cart:

    public void AddProduct()
    {       
        //values of current New Product
        system.debug('Starting Values of NewProduct!');
        
        system.debug('UQ: ' + NewProduct.Unit_Quantity__c);		
        system.debug('UP: ' + NewProduct.Unit_Price__c );
        system.debug('TAP: ' + NewProduct.Total_Amount_Paid__c );
        system.debug('SD: ' + NewProduct.Start_Date__c);         
        system.debug('ED: ' + NewProduct.End_Date__c );
        system.debug('ARRT: ' + NewProduct.Annualized_Rec_Rev_Term__c);
        system.debug('MRP: ' + NewProduct.Monthly_Recurring_Price__c );
        system.debug('ARP: ' + NewProduct.Annual_Recurring_Price__c );        
        system.debug('OTP: ' + NewProduct.One_Time_Price__c);
        
        ID UIProd = NewProduct.Contract_Product__c;
        date StartDate = NewProduct.Start_Date__c;
        date EndDate =   NewProduct.End_Date__c;
		integer UQ = integer.valueof(NewProduct.Unit_Quantity__c);		
        decimal UP = NewProduct.Unit_Price__c ;
        decimal TAP = NewProduct.Total_Amount_Paid__c;
        decimal CA = NewProduct.Capped_Amount__c;
         
        UpdatedField = 'All';

        system.debug('Size after variable: ' + prods.size());
        system.debug('NewProduct to Add: ' + NewProduct);
 
        if(Schedule =='Month')
        {
            //NewProduct.Annual_Price__c = (getPriceBookOpp().Amount / NewProduct.Quantity__c);
        }
        prods.add(NewProduct);      
		/* Add NewProduct into ProductCart */
		ProductCart.add(new cProd(NewProduct));
        for(cProd cp :ProductCart)
        {
            if(cp.vname == 'changeme')
            {
                cp.vname = string.valueof(counter)+ string.valueof(NewProduct.Contract_Product__c);
            }
        }
        counter = counter+1;
        ID AccountID = NewProduct.Account__c;
        ID ProductID = NewProduct.Contract_Product__c;

        boolean NewClient = NewProduct.New_Client__c;
		/* Next 3 lines Clone Product to "Reset" new product with same values */
        Contract_Product__c TempProduct = NewProduct.clone(false,true,false, false);
        NewProduct = new Contract_Product__c(); 
        NewProduct = TempProduct.clone(false,true,false, false);          

    }   

/*Wrapper Class and Product Cart Methods */
    
    public class cProd
    {
        public Contract_Product__c Prod {get; set;}
        public Boolean cSelected {get; set;}
        public string vName {get; set;}
        
        public cProd(Contract_Product__c p)
        {
            Prod = p; //Contract Product object
            cSelected = false; //Selected Checkbox
            vname='changeme';                        
        }
    }   
    private list<cProd> ProductCart {get;set;}  
    
    public list<cProd> getProductCart()
    {           
        system.debug('This is the getProductCart: ' +ProductCart);
        return ProductCart;
    }

 

Anyone see what I'm doing wrong here to cause my problem? Anyone have suggestions on how to make this better?

Hey folks, I'm having some real difficulty here.

 

Here's what I'm trying to do. My goal is to have very quick client-side "warnings and errors" messages display on a VF page. Going to controller and back everytime users are entering data simply takes way too long.

 

I'm already using Javascript on that page to handle some client-side calculation. So I'm planning on also using Javascript to Identify when a data error has occured and then display text within a output panel. I want this text red, bold and centered on the page.

 

I've been able to get the text to display in an output panel, be bold and red - but I can never get it to be centered.

 

Here's a slimmed down version of what I got.

 

<apex:page standardcontroller="Contract_Product__c" extensions="Contract_Product_Add_Extension_jquery" id="page">
	<apex:form rendered="{!Master.AccountID != null && Master.Lock_Status__c != 'Locked' || $Profile.Name == 'System Administrator'}" id="ProductForm">
		<apex:outputpanel id="SelectContractProducts" layout="none">
			<apex:pageblock id="ContractProductsBlock" title="Select Contract Products"  rendered="{!Display}">
				<apex:outputpanel id="Warnings" >
					<table width="100%" id="WarningsTable">
						<tr id="WarningsRow">
							<td id="WarningsCells">
							</td>
						</tr>
					</table>
				</apex:outputpanel>
			</apex:pageblock>
		</apex:ouputpanel>
	</apex:form>
</apex:page>

 

If I remove the WarningsTable (and all chidlren) I can update the OutputPanel "Warnings" succesfully with

document.getElementById('{!$Component.page.ProductForm.ContractProductsBlock.Warnings}').innerHTML

 However trying to update the table I've been unsuccessful in getting the Table, Row, or Cell IDs. The only reason I'm using a table is to get the text to be centered.

 

Anyone provide some guidance? I either need to get the text centered in the output panel so it's centered within the pageblock or I need to get to the TD value so I can add and delete warnings.

Last night, we started having tests fail in our dev environment.  We have the following methods (shortened)

 



public static void updateTargetDate(...) {
     Set<Id> futureIds = new Set<Id>();
     ...
     // Add Ids
     ...
     if (!futureIds.isEmpty()) {
          updateTargetDateFromMilestone(futureIds);
     }
}

@future
public static void updateTargetDateFromMilestone(Set<Id> caseIds) {
     ...
}

 

Yesterday at noon (we run all tests in dev at noon and midnight) all the tests were running without error.  At midnight most of our tests were failing with the following error:

 

System.TypeException: Invalid conversion from runtime type SET<String> to SET<Id>

 

with a referral to the method of updateTargetDateFromMilestone(Set<Id> caseIds).  This file has not been updated since June 24th 2011.

 

So the question is, has anyone else seen this error crop up?  I know that in Apex Strings and Id "should" be interchangeable, however, it doesn't matter in this case since the Set being made is of type Id and the Set parameter for the calling method is of type Id.

  • September 30, 2011
  • Like
  • 0

Ok, so I am trying to do the following but I am very limited on HTML coding.

 

I have two SFDC instances (1 & 2) - On the web to lead form there are multiple product intrest to select from(A,B,C).

 

If product "A" is selected, I want it to go to instance "1", if product "B or C" is selected, go to instance "2". Lets say I just used a standard pick list so only one option could be selected.

 

Is the above even possible?

 

Now what if I used multiple pick list and a customer chose A & B, could I have it create a lead in both instances?

 

Or should I just do SFDC to SFDC?

 

Thanks for you Help!!!

PB

 

I have a batch class that accepts a query string.

 

I"m testing the function and want to pass over a query to the batch for very specific records that I can test. I would like to pass over either a single id or a set.

 

Can I format a query string to include the single quotes necessary when formatting a filter for a single ID? I know I could modify the class to include another variable but I would rather not. I'm only doing this as a test and wouldn't actually use that variable ever again after the test.

 

For example:

 

I want: 
Select MyFied__c from Contract where id = '8003000000021gz';

but as a string literal:

string q = 'select MyField__c from Contract where id =' .... 

 

I must be doing something very simply stupid.

 

I have two JS Functions, one takes a single variable and a second JS function that takes two variables.

 

All of these variables are in my Apex Controller and updated based on user input. I can't just call the variable directly in the function because it only get's set on the page load and not when a user makes an update.

 

For my first JS function with only 1 varilable I call using an ActionFunction that calls the PageReference to update the variable in the Controller and then calls my JS Function oncomplete and passes the variable to the JS Function.

 

Like this:

  <apex:actionFunction name="DurationCalculate" action="{!CalDuration}" rerender="Rec_Rev_Term,PanelTesting" oncomplete="setARRT({!duration})" >
  </apex:actionFunction>

<script type="text/javascript">
	function setARRT(duration)
	{		
		var months = duration;
		
		//set ARRT data
		document.getElementById('{!$Component.page.ProductForm.ContractProductsBlock.pbs.pbsiARRT.OutputARRT_m}').innerHTML = months;
	}
</script>

 This works perfectly!

 

So I tried doing this with my function that takes two variables. The actionfunction gets called but the actual JS function isn't.

 

  <apex:actionFunction name="CalPriceType"  rerender="PanelTesting" oncomplete="setPrices({!duration},{!Price_Type})" >  																				 
  </apex:actionFunction>	

<script type="text/javascript">
	function setPrices(duration,PriceType)
	{
		if(PriceType == 'Recurring')
		{
			.... do this
		}
		return false;
	}
</script>

 What am I doing wrong? Both {! duration } and {! Price_Type} can change base on the user input. The values are set correctly in the controller.

Okay,

 

I'm feeling incredibly stupid here. I've been using a Apex Class to handle a lot of the calculations for a page. This works and it also incredibly slow. There are multiple inputs with each one requiring a series of calculations and partial page re-renders. This causes a lot of slow down with all the client -> server communication.

 

So, I'm switching to Javascript. I've had some success with all the references and websites out there. I've successfully updated all the calculations that are done on InputText and InputField components. My issue is that this doesn't seem to work on OutputText and Outputfields.

 

Here's a quick example. It's more complex than this but really simply I'm having a javascript function populate InputFields, OutputFields and OutputText after the function is called.

 

<apex:page id="thepage">
<script type="text/javascript">
	function jsUpdateFields(){
		var vnum = 10;
		var vdollar = 5;
		var vtext = 'hello';
		
		document.getElementByID('{!Component.thepage.theform.thepageblock.InputField}').value = vnum;
		document.getElementByID('{!Component.thepage.theform.thepageblock.OutputField}').value = vdollar;
		document.getElementByID('{!Component.thepage.theform.thepageblock.OutputText}').value = vtext;
		return false;
	}
</script>
	<apex:form id="theform">
		<apex:pageblock id="thepageblock"
			<apex:inputfield value="{!Myobject.MyNumber__c}" id="InputField" />
			<apex:outputfield value="{!MyObject.MyCurrency__c}" id="OutputField" />
			<apex:outputtext value="{!MyObject.CustomText__c}" id="OutputText" />
		<a href="#" onclick="jsUpdateFields()">Run Javascript</a>
		</apex:pageblock>		
	</apex:form>
</apex:page>

 What happens: The inputfields update perfectly. The outputField and OutputText have no updates. If I change those components to inputs they work fine.

Here's the thing I don't want to have those to be inputs.

 

I've also tried using an apex function that calls the javascript function and then rerenders an outputpanel where my output fields are located. This also doesn't seem to work.

help! and thank you

So I'm creating my first functions in Javascript for visualforce.

 

I started by created the script directly on the page. This works and it takes a large amount of space.

 

So instead I planned on creating a bunch of functions and uploading those as a static resource. Then have a single script on the page that calls the functions and sets the element id.

 

When everything is on the page directly it works fine. The moment I remove my functions and upload to a static resource I get a syntax error.

 

Here's a sample of a really simple function. It accepts to variables, multiples them, and returns the result.

 

<script type="text/javascript">
	function TAPCalculate(UQ, UP){		
		var P = UQ * UP;		
		return P;
	}
</script>

 

I created this .js file and then uploaded as a static resource called 'Contract_Calcs"

 

My visualforce page then has an include script:

<apex:includeScript value="{!$Resource.Contract_Calcs}"/>

 

And then I call this function from the script on my page. I don't even get to the point of calling the function and instantly get a syntax error in firebug. Firebug states my first line of the function is wrong. That's the var P = UQ * UP;

 

It works on the page -- why doesn't it work when I upload it as a static resource?

 

 

Hi all,I want to display a popup window in vvisualforce page.on click on the image need to display an popup in visual force page,.

Ok,

 

So I've been using a controller to do a bunch of math functions on Inputfields on my page. The response of the page has degraded quite a bit so I decided to move my math functions to jquery.

 

So I'm starting with my simpliest formula where I have an inputfield for Unit Quantity, Unit Price, and Total Amount Paid.  So I created this function:

 

<script type="text/javascript">
	$j = jQuery.noConflict();
	function jsCalculate(){
		var UQ = document.getElementById('{!$Component.page.theform.ContractProductsBlock.pbs.pbsiUQ.InputUQ}').value;
		var UP = document.getElementById('{!$Component.page.theform.ContractProductsBlock.pbs.pbsiUP.InputUP}').value;
		var P = UQ * UP;
		document.getElementById('{!$Component.page.theform.ContractProductsBlock.pbs.pbsiTAP.InputTAP}').value = P;
}
</script>

 

So Here's what I'm having issues with. If I set the InputTAP value to UQ or to UP i get the correct number when the function is called. However when I try to assign it to P or do the math directly in the value set (InputTtap.value = UQ * UP)

I get an "NaN" error message instead of the product.

What am I doing wrong here? The function is being called and I'm getting the right values from my input fields but the math portion seems to fail.

 

 

I'm trying to set up an approval process including approval assignment email templates.

 

In these templates I'd like to address the receiving user, however this doesn't seem to work:

 

 

The template:

 

 

 

In the mail I get this:

 

 

 

 

Anyone has an idea what might be the problem?

 

 

Thanks in advance!