• EtienneCoutant
  • NEWBIE
  • 105 Points
  • Member since 2008

  • Chatter
    Feed
  • 4
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 33
    Replies

Hi All,

 

Greeting to All

 

I would like know the what is best way to customize the saleforce interface , which include the creating custome buttons & associated funcationality? Can you advise on any article?

 

 

 

 

Thanks,

Rao

I'm trying to build a statement to update some records. I'm having trouble understanding the method and syntaxt. Trying to do this via PHP, forming statements based on this page http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_update.htm

 

In a nutshell I don't understand what the first term "Contact" in this line from the docs is:

Contact c = [select account.name from contact
             where lastName = 'Carter' limit 1];

 

I'm trying to build a statement like this:

 

$qry = "XXX cbp = [SELECT Supplier_Code__c FROM MyObj__c WHERE ManufacturerName__c = 'Fish Corp'];";
$qry .= "cbp.Supplier_Code__c = 'FISHCO';";
$qry .= "UPDATE cbp;";

 

But lost as to what/where the "XXX" term is or where to find it re my custom object...

Hope this makes sense

Thanks.

I am trying to set up a field (Lead Score) which gives my leads a numerical vlaue based on a couple  fields: Lead status & Rating...for instance if Lead status= "Nego. Contract Sent" and the Rating field = "Hot"...then this prospect would have a rating of 20 because "Nego. Contract Sent" has a value of 10 and the "Hot" rating also has a value of 10 giving them a rating of 20. If the Lead status="Information Flyer Sent" and the rating is still "Hot" they would have a value of 17 (10 for Hot and 7 for "information flyer"

 

I started to setup a workflow rule which said if "Rule Criteria Lead: Rating equals Warm,INTERESTED NOW,Cold,Hot" but then got stumped on the Workflow Action which I think would need to be a field update...

 

This is bascially what I am trying to do and I am definitely open to other options if somebody has a better way of doing this. This seems to logically make sense to me but you guys may have more experience and think of something else. Your help is appreciated!

Hi,

 

Is there a way to detect in Apex if the system is a Sandbox or a Dev Edition?

 

Thanks.

 

 

 

 

Is it possible to retrieve list custom settings? Is there an equivalent to getInstance(String dataset_name) in the php toolkit?
 

Hi,

 

I have created a Class that implements the Schedulable interface for a batch Apex class called batchable:

 

 

global class scheduledBatchable implements Schedulable{ global void execute(SchedulableContext sc) { batchable b = new batchable(); database.executebatch(b); } }

 

 Now I am not sure how I can write my test class... Can i call execute() ? What should be the SchedulableContext?

 

 

 

 

Hi,

 

When the Contact creation is part of a Lead conversion, before insert triggers that I have on Contact are not triggered. Is there a workaround?

Thx! 

Hi,

 

Can someone help, I keep getting the error:

System.DmlException: Insert failed. First exception on row 0 with id 00oS0000000AOgYIAW; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

 

But I am pretty sure that there is no Id specified in my insert call.

Here is my code:

 

 

public PageReference save() { List<OpportunityLineItemSchedule> revenueSchedulesToUpdate = new List<OpportunityLineItemSchedule>(); List<OpportunityLineItemSchedule> revenueSchedulesToInsert = new List<OpportunityLineItemSchedule>(); for(revenueSchedulesDate revenueSchedulesDate:revenueSchedulesDates){ for(OpportunityLineItemSchedule revenueSchedule:revenueSchedulesDate.getRevenueSchedules()){ if(revenueSchedule.get('Id') == null) revenueSchedulesToInsert.add(revenueSchedule); else revenueSchedulesToUpdate.add(revenueSchedule); } if(revenueSchedulesToUpdate.size() > 0) update revenueSchedulesToUpdate; if(revenueSchedulesToInsert.size() > 0) insert revenueSchedulesToInsert; } return Page.revenueScheduleView2; }

 

 

 

Hi,

 

Does anyone know if there are some governor limits for Workflow Email alerts?

I was told by Salesforce Support Tier 1 that there was no limitations on that, expect for the 2,000 emails a day, but it seems that there are some limitations.

When I update 500 contacts in order to trigger a Workflow that sends an email, this does not show in the Email logs. Same with 50 contacts, it only works with smaller batches so far (15 at a time...)

 

Any idea ?

 

Thanks

Etienne 

Hi,

I was reading in the Salesforce Summer '09 Force.com Apex Code Developer's Guide that we will be able to use Batch Apex to build complex processes, like data cleansing...

 



Will it be possible to start a Batch job from a trigger? If yes, is there any limitations due to governors?

 

Thanks,

Etienne

Hi,

 

The Mail Merge template that I use lists the purchased Products and their descriptions. Some of the descriptions contain a ', which is always translated into &#39 ; on the word document resulting from the Mail Merge. Is there a way to avoid that?

 

Thanks,

Etienne

http://wiki.apexdevnet.com/index.php/Checkbox_in_DataTable

 

I created a page and a class exactly like it is explained in the link above and that worked well. However, when I added the parameter immediate="true" on the actions, it totally stopped working.

 

Anyone has an idea why? What is the impact of  the immediate parameter except skipping validation?

Thanks,

 

Etienne

Hi,

 

Is it possible show/hide blocks based on the User Profile, using the parameter 'rendered'? More generally, do we have access to User profile info in a Visualforce page?

 

Thanks.

 

Hi,

 

I created a Roll-Up Summary field on Opportunity to count the number of Line Items with a revenue schedule:

Roll-Up Summary (COUNT Opportunity Product)

 

I assumed that it would return an Integer, but when I want to put that field in a Visualforce page, it shows it with decimals, e.g. 2.0

Is there a way to only display the Integer part?

 

Thanks!

Hi,

I created a trigger on Tasks, so that whenever a Task is created it adds the score associated to the task to the related Contact/Lead.

Here is the code of the trigger:
Code:
trigger addActivityScore on Task (after insert) { 

for (Task activity:Trigger.new) { 
   if (activity.WhoId != null && (''+activity.WhoId).startsWith('00Q')) 
   { 
      Lead lead = [select Id, Activity_Score__c from Lead where Id =: activity.WhoId limit 1]; 
      if(lead.Activity_Score__c == null) lead.Activity_Score__c = 0; 
      lead.Activity_Score__c += activity.Activity_Score__c; 
      update lead; 
   } 
   else if(activity.WhoId != null && (''+activity.WhoId).startsWith('003')) 
   { 
      Contact contact = [select Id, Activity_Score__c from Contact where Id =: activity.WhoId limit 1]; 
      if(contact.Activity_Score__c == null) contact.Activity_Score__c = 0; 
      contact.Activity_Score__c += activity.Activity_Score__c; 
      update contact; 
   } 
  } 
} 

When I pushed this trigger on production, it worked until someone filled the Web-To-Lead form, that comes out of the box with Salesforce.com
Then I received error messages from both the Apex code, and the Web-To-Lead queue, with the following error:

  • From the Web-To-Lead queue:
Alert: Salesforce experienced the following problem creating the lead below:

Reason: common.apex.TriggerExecutionException: Apex trigger addActivityScore caused an unexpected exception, contact your administrator: addActivityScore: maximum trigger depth exceeded

  • From the Apex code:
Reason: common.apex.TriggerExecutionException: Apex trigger addActivityScore caused an unexpected exception, contact your administrator: addActivityScore: maximum trigger depth exceeded

I am not sure why I am getting a maximum trigger depth exceeded exception as the trigger is not reccursive. Can someone help?

 
Thx
Etienne
Hi,

From what I have understood about Governors, the limit is 20 Queries and 20 DML Statements for a trigger.
However, I am really wondering if this is for ONE trigger, or for all the triggers executed at the same time.

I have 2 triggers on 2 different objects, and each of them is executing 15 queries. When ran separately, it works perfectly, but it happens that those 2 triggers are executed at the same time. In that case I get an error 'too many queries: 21'. My guess is that the system is counting 15 + 15 = 30 queries, which is obviously over the limits...

Does someone know the answer?
thanks a lot!!!
I am using:
PHP toolkit 11.0b
PHP 5.1.6

I am migrating some code from Salesforce API version 7.0 to the version 11.1.
It seems that Validation Rules were not verified upon record creation/update with the version 7.0, but it is now. Is there a way to force the System to ignore Validation Rules when creating/updating records via the API 11.1 ?

Thanks a lot!
Hi

I am using:
PHP toolkit-11_0b
PHP 5.1.6
Salesforce API version 11


I am trying to send Emails via the API, related to cases, using a Template in Salesforce.
When the Salesforce case has a Contact, the following function works well:

/**
* Create an Array of Emails for an Array of Cases
* @param conn Connexion to Salesforce using Partner API
* @param $cases Array of Cases (Custom Class with set and get methods)
*/
function emailMerge($conn,$cases)
{
$results = array();
foreach ($cases as $case){
$singleEmail = new SingleEmailMessage();
$singleEmail->useSignature = false;
$singleEmail->templateId = SALESFORCE_TEMPLATE_ID;
$singleEmail->targetObjectId = $case->getFirstContactId();
if($case->getSuppliedEmail()!= null) $singleEmail->toAddresses = $case->getSuppliedEmail();
$singleEmail->whatId = $case->getId();
array_push($results,$singleEmail);
}
$conn->sendSingleEmail($results);
}


However, when there is no Contact on the case record, I keep getting the error, as it should.

[errors] => stdClass Object
(
[fields] =>
[message] => Only emails to contacts can specify whatId.
[statusCode] => INVALID_ID_FIELD
[targetObjectId] =>
)

I just wonder if it is possible to send an Email (using a template) when the Case has only the WebEmail info, and no Contact. I could do that from the web app, by leaving the 'To' field empty, but no from the API. Any reason why? Any workarounds?
I am using:
PHP toolkit-11_0b
PHP 5.1.6
Salesforce API version 11


I am trying to retrieve the Account name or id, when querying on Cases from the API, but I could not find a way to do that:

SELECT Id, Account.Name FROM Case --> Doe not work with PHP

SELECT Id, AccountId FROM Case --> No such column 'AccountId' on entity 'Case'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

SELECT Name, (SELECT Id FROM Cases WHERE Id = '".$MyCase->Id."') FROM Account --> Didn't understand relationship 'Cases' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.


Someone can help me on that?
Thanks a lot,
Etienne

Hi,

 

Can someone help, I keep getting the error:

System.DmlException: Insert failed. First exception on row 0 with id 00oS0000000AOgYIAW; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

 

But I am pretty sure that there is no Id specified in my insert call.

Here is my code:

 

 

public PageReference save() { List<OpportunityLineItemSchedule> revenueSchedulesToUpdate = new List<OpportunityLineItemSchedule>(); List<OpportunityLineItemSchedule> revenueSchedulesToInsert = new List<OpportunityLineItemSchedule>(); for(revenueSchedulesDate revenueSchedulesDate:revenueSchedulesDates){ for(OpportunityLineItemSchedule revenueSchedule:revenueSchedulesDate.getRevenueSchedules()){ if(revenueSchedule.get('Id') == null) revenueSchedulesToInsert.add(revenueSchedule); else revenueSchedulesToUpdate.add(revenueSchedule); } if(revenueSchedulesToUpdate.size() > 0) update revenueSchedulesToUpdate; if(revenueSchedulesToInsert.size() > 0) insert revenueSchedulesToInsert; } return Page.revenueScheduleView2; }

 

 

 

Hi All,

 

Greeting to All

 

I would like know the what is best way to customize the saleforce interface , which include the creating custome buttons & associated funcationality? Can you advise on any article?

 

 

 

 

Thanks,

Rao

Hi All,

 

I am at the end of my patience with myself here, cause I cannot figure out what I am missing. 

 

This is a custom object, Work Order, that has a look up to an Opportunity.  There can be many Work Orders related to the same opportunity.

 

Trigger fires when

  • the Work Order stage field is updated to either one of the closed values;
  • if all of the Work Orders related to that opportunity are closed, then update the opportunity stage, if not, do nothing.

I can get this to save, run the test, but it never updates anything.  I have changed this code so many times, I have no idea where I am screwing up and would appreciate some pointer.

 

At present - I am getting an error on line 24:         Map <ID, Opportunity> updateOpps = new Map <ID, Opportunity> ([SELECT id, stageName, (select ID, Opportunity__c from Work_Orders__r)
        from Opportunity where id in :affectedOpps]);

 

Error reads:  IN Operator must be used with iterable expression.

 

I am stil very much a beginner, so please be explicit if you are telling me something I need to do:)

 

Thanks!!!!

 

 

Trigger CheckOpportunityWorkorders on Work_Order__c (after insert, after update) {

   set<id> oppids = new set<id>();

     	
	    if(Trigger.isInsert || Trigger.isUpdate)
   		    	for (Work_Order__c wo: Trigger.new) {
            if (wo.stage__c == 'Work Order Closed - Quickbooks' ||  wo.stage__c == 'Job Completed' ){
      		oppids.add(wo.Opportunity__c);
      		String oid = wo.Opportunity__c;
      		
 	    if(oppIDs .size() > 0) {
 
  Map <ID, Opportunity> affectedOpps = new Map <ID, Opportunity> ([select id, stageName, (select id, Opportunity__c from Work_Orders__r 
  	where Work_Order__c.stage__c != 'Work Order Closed - Quickbooks' OR stage__c != 'Job Completed') 
	from Opportunity where id in :oppids]);

	
	System.debug('Opportunity: '+affectedOpps.get(oid).StageName);     		
   

      	if (affectedOpps .size()==0){	
		
		Map <ID, Opportunity> updateOpps = new Map <ID, Opportunity> ([SELECT id, stageName, (select ID, Opportunity__c from Work_Orders__r)
		from Opportunity where id in :affectedOpps]);
		String upID = wo.Opportunity__c;
		 	if(updateOpps.containskey(upID))
		 	
 //       	d = updateOpps.get(upID);
				 
			upID.stageName = 'Job Complete';
			
			update updateOpps;
      	}
		
		
 
}
}
}
}

 

public with sharing class testCheckOpportunityWorkOrders {

    static testMethod void myTest() {

		Account a = new Account(name='test', type = 'customer');
		insert a;
       //Insert a test opportunity
		
       Opportunity o = new Opportunity();
       o.AccountId = a.id;
       o.StageName='Target';
       o.Name='test';
       o.closeDate=Date.today();

       insert o;
       
       system.debug('opportunity id' + Opportunity.ID);
       
         //Insert a Work_Order

       Work_Order__c wo = new Work_Order__c();

       wo.Opportunity__c = o.id;
       
       wo.Stage__c = 'Job Completed';
       wo.Close_Date_WO__c=Date.today();

  
       insert wo;
 		system.debug('workorder' + wo.ID);
 		      
       Work_Order__c ww = new Work_Order__c();

       ww.Opportunity__c = o.id;
       
       ww.Stage__c = 'Return Trip Needed';
       ww.Close_Date_WO__c=Date.today();
  
       insert ww;
       
       ww.Stage__c = 'Work Order Closed - Quickbooks';
       update ww;
       
       wo.Stage__c = 'Work Order Closed - Quickbooks';
       update wo;
       
		system.debug('workorder' + ww.ID + ww.Stage__c);
		
       Opportunity updated_Opportunity = [SELECT ID, WO_Count__c FROM Opportunity WHERE Id = :o.Id];

       //Verify that the values of the opp were changed by the trigger
       
  //System.assertEquals(opportunity, [Select WO_Count__c from Opportunity Where ID = :o.ID].wo_count__c);
  
 
     }
static testMethod void testBulkInsert() {

  List<Opportunity> opps = new List<Opportunity>();
  
 }

}

 

 

 

I'm trying to build a statement to update some records. I'm having trouble understanding the method and syntaxt. Trying to do this via PHP, forming statements based on this page http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_update.htm

 

In a nutshell I don't understand what the first term "Contact" in this line from the docs is:

Contact c = [select account.name from contact
             where lastName = 'Carter' limit 1];

 

I'm trying to build a statement like this:

 

$qry = "XXX cbp = [SELECT Supplier_Code__c FROM MyObj__c WHERE ManufacturerName__c = 'Fish Corp'];";
$qry .= "cbp.Supplier_Code__c = 'FISHCO';";
$qry .= "UPDATE cbp;";

 

But lost as to what/where the "XXX" term is or where to find it re my custom object...

Hope this makes sense

Thanks.

I am trying to set up a field (Lead Score) which gives my leads a numerical vlaue based on a couple  fields: Lead status & Rating...for instance if Lead status= "Nego. Contract Sent" and the Rating field = "Hot"...then this prospect would have a rating of 20 because "Nego. Contract Sent" has a value of 10 and the "Hot" rating also has a value of 10 giving them a rating of 20. If the Lead status="Information Flyer Sent" and the rating is still "Hot" they would have a value of 17 (10 for Hot and 7 for "information flyer"

 

I started to setup a workflow rule which said if "Rule Criteria Lead: Rating equals Warm,INTERESTED NOW,Cold,Hot" but then got stumped on the Workflow Action which I think would need to be a field update...

 

This is bascially what I am trying to do and I am definitely open to other options if somebody has a better way of doing this. This seems to logically make sense to me but you guys may have more experience and think of something else. Your help is appreciated!

Hi - I am trying to set a validation rule which will not let the sales team enter a close date less than the date when they mark an opportunity to closed/won. 

 

This is what I have:

AND(ISPICKVAL( StageName, 'Closing Agreement (Won)',  CloseDate < today()))

 

This is the error message:

Error: Incorrect number of parameters for function ISPICKVAL(). Expected 2, received 3

 

Any thoughts?

 

Thanks

Is there a way of deactivating the whole Price Book?  As you would appreciate to deactivate the individual product price netry is a "nightmare" in itself.  Thus I am trying to find a quicker way to deactivate the whole Price Book rather than deleting it. Please help.

 

When you try to delete a product or price book that is used on an opportunity or quote, Salesforce.com displays a list of the opportunities or quotes using it. If you are deleting a price book, you have to go to each opportunity or quote listed and remove the price book from them. If you are deleting a product, you have to remove the product from every opportunity and quote that uses it. Then, delete the price book or product and it will be stored in the Recycle Bin temporarily, during which time, you can recover it and all its related price book entries.

Well, this is going to be a "nightmare" as we already have Opportunities that are using the products and price books.

 

That is why deactivating is the best way of doing it (as per recomendation).

 

James(NewbieOne)

 

 

I have a page that uses the standard Lead controller. I'd like to create a link that sends user to the Send Email page for this lead.

 

I have tried the following syntax but it is not work, error: Field $Action.Activity.SendEmail does not exist. Check spelling.

 

{!URLFOR($Action.Activity.SendEmail,Lead.Id)}

 

Any ideas?

 

Thanks,

Jason

 

Hi all,

 

I'm trying to write my first trigger and am running into some errors.  It is probably baby stuff, but we all have to start somewhere.  Can someone please help with the error?

 

I'm trying to pull a field (text) from the Associated Account to a separate field (picklist) on the Opportunity.

 

Thanks for the help/lesson in advance!

 

 

trigger setXCenter on Opportunity (before insert, before update) { for(Opportunity oppObject : trigger.new) { Account acctObject = [Select Default_X_Center__c from Account where id = :oppObj.Account]; oppObject.Cost_Center__c = acctObject.Default_X_Center__c; }

 I'm getting this error:

 

 Error: Compile Error: No such column 'Default_X_Center__c' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. at line 19 column 29

 

Thanks 

 

  • March 08, 2010
  • Like
  • 0
One of our email workflow rules was triggered but the email was never received.  We pulled an email log and noticed that in one day 6 emails from different email alerts went to ValidationQueue@salesforce.com.  Has anyone have this issue?
Message Edited by hhuie on 02-25-2010 10:02 AM
  • February 25, 2010
  • Like
  • 0

So far in my apex playing time I have been able to parse out values from a string of characters

private void testBookParser() { XmlStreamReaderDemo demo = new XmlStreamReaderDemo(); String str = '<books><book author="Manoj">Foo bar</book>' + '<book author="Mysti">Baz</book></books>'; XmlStreamReader reader = new XmlStreamReader(str); books = demo.parseBooks(reader); //System.debug(books.size()); //for (Book book : books) {System.debug(book); //} }

 

 

However, syntatically how can I read in a URL string which contains XML (eg. 'https://na6.salesforce.com/servlet/servlet.ReportList') so that I can parse it?

 

Any help would be appreciated!

  • December 14, 2009
  • Like
  • 0

Hi,

 

When the Contact creation is part of a Lead conversion, before insert triggers that I have on Contact are not triggered. Is there a workaround?

Thx! 

Hi,

 

Can someone help, I keep getting the error:

System.DmlException: Insert failed. First exception on row 0 with id 00oS0000000AOgYIAW; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

 

But I am pretty sure that there is no Id specified in my insert call.

Here is my code:

 

 

public PageReference save() { List<OpportunityLineItemSchedule> revenueSchedulesToUpdate = new List<OpportunityLineItemSchedule>(); List<OpportunityLineItemSchedule> revenueSchedulesToInsert = new List<OpportunityLineItemSchedule>(); for(revenueSchedulesDate revenueSchedulesDate:revenueSchedulesDates){ for(OpportunityLineItemSchedule revenueSchedule:revenueSchedulesDate.getRevenueSchedules()){ if(revenueSchedule.get('Id') == null) revenueSchedulesToInsert.add(revenueSchedule); else revenueSchedulesToUpdate.add(revenueSchedule); } if(revenueSchedulesToUpdate.size() > 0) update revenueSchedulesToUpdate; if(revenueSchedulesToInsert.size() > 0) insert revenueSchedulesToInsert; } return Page.revenueScheduleView2; }

 

 

 

Hello.

 

I am willing to have the items in my picklist (multi select) dynamically populated, say, from some other object's field values.

 

Any guidance will be helpful.

 

Thanks

For our vendor letters we could have a choice of 3 fax numbers and a null.

Vendor Location Vendor Fax (If Print Billing vendor = false & Contact Name is null)

Vendor Location Contact Fax (If Print Billing Vendor = false &Contact Name is not null)

Vendor Location Billing Fax (If the Print Billing Vendor =true & Billing contact is null)

Null (if print billing vendor = true and the billing contact is not null)

 

IF( Print_Billing_Vendor__c=False&& isnull(Vendor_Contact__c )=True, (Vendor_Fax__c ),
IF( Print_Billing_Vendor__c=False&& isnull(Vendor_Contact__c )=False, (Contact_Fax__c ), IF( Print_Billing_Vendor__c=True&& isnull( Billing_Vendor_Contact__c )=False, (Billing_Vendor_Fax__c ),"")))

 

All fields are text fields except the Print Billing Vendor is a check box.

 

This formula is not working even though I do not get a syntax error.

What am I missing?

 

Thank you in advance.

 

 

  • July 06, 2009
  • Like
  • 0