• Ker Vin.ax1237
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 10
    Replies

Per SFDC documentation, you can only submit 2000 batch jobs per 24 hours.

 

Let's say you have an APEX batch job. This batch job in turns creates multiple batches (database batchable?) as it needs to match against specific fields in the entire Lead database.

 

Does the 2000 batch per 24 hours apply to the APEX batch job only or to all the multiple batches that it creates? Just need to confirm this.

Basically, there is a picklist field on Lead called "Program". The values of this picklist have to be synchornized with the values defined in an external application. While updating  the field with a value is straightforward enough (as in a simple field update using dataloader/SOAP API),  I have no idea as to how to update the allowed picklist values of the field. 

 

Can someone give a suggestion?

According to this document 
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

Total number of callouts (HTTP requests or Web services calls) in a request10
Maximum timeout for all callouts (HTTP requests or Web services calls) in a request120 seconds


I assume this means that there can be a total of 10 calls every two minutes. As in, organization-wide, only a max of 10 calls TO the external application and FROM the external application is allowed.

Is this correct? Also, can someone provide an example how governer limits work for webservice APIs? I'm a bit confused as to how to they are applied......as in how the maximum number of calls is calculated?

Hi there, just wanted to get some information from the users around here. I'm fairly new to the APEX scene and can't quite find the information I want to know.

As I understand, SFDC processes records in batches and therefore APEX coding/triggers have to be written in a manner of "batch processing". I understand that there is a limit of concurrent batches. Also, there is a limit to the number of records returned from any SOQL query. My questions are as follows

1) When writing a trigger and using the     Set<Id> idsToUpdate = trigger.newmap.keySet();command, won't we hit the limit fairly quickly if there is a large update running? As I understand, the command captures all records that execute the trigger. If I were to update 5000 records, then there will be that many entries in that set. Won't this be an issue?

2) Let's say that there is a limit of concurrent batch jobs. Using the above as an example, I want to match each newly created record to every other record in the database using Database.batchable. 
So, I can issue a (for Sobject objectname : objectList) loop and then pass each [objectname] into a Database.batchable job. 
As I understand, there is a limit to the number of concurrent batch jobs. For a sufficiently large number of records, this limit will be hit quite quickly right?

Can anyone suggest a better way for situation (2)?

From the sfdc documentation, the execution is as follows.

  1. Executes all before triggers.
  2. Runs most system validation steps again, such as verifying that all required fields have a non-null value, and runs any user-defined validation rules. The only system validation that Salesforce doesn't run a second time (when the request comes from a standard UI edit page) is the enforcement of layout-specific rules.
  3. Saves the record to the database, but doesn't commit yet.
  4. Executes all after triggers.
  5. Executes assignment rules.
  6. Executes auto-response rules.
  7. Executes workflow rules.
  8. If there are workflow field updates, updates the record again.
  9. If the record was updated with workflow field updates, fires before and after triggers one more time (and only one more time), in addition to standard validations. Custom validation rules are not run again.


I have written a "After insert" trigger that will create and attach a task that has customized comment information (based on the lead that triggers it). I want this task to be created AFTER the assignment rules have been executed. Otherwise, the task will be assigned to one person and the lead to another.

To do this, I wrote a workflow rule that will update a flag to true and modified the trigger to only execute the task creation if the flag is set to true. My understanding is that the on the first run, the trigger won't work because the flag is false, assignment rules will then change the Lead Owner, Workflow rules will update the flag and then lastly the trigger will execute (properly this time)

Unfortunately, the trigger doesn't seem to execute the second time. Is my understanding wrong? When I reviewed the debug log, the 2nd execution of the trigger that I was expecting doesn't occur.

My Leads have a validation rule such that once someone views a Lead, they can't leave the status as "Open" (as in if the Status is "Open" and the Creation DateTime is not the current date time, then trigger an error message).

 

Now, we are using the Web-to-Lead to pump questions from the website into SFDC directly. The Web-to-Lead basically writes the contact information and their query into Leads (queries are written to a non visible field called " QA"). I wrote  a trigger executing on "After insert" such that a Task will be created, the QA from Lead will be copied into the Comments in the Task and then the QA field will be cleared.

 

My problem starts here. The validation rule doesn't allow me to save the "QA" as blank because the status is Open. Is there a way to bypass this validation rule just for this scenario? Or is there a better way?

 

Any comments will be appreciated. 

Is there a way to display "There are XXX Leads assigned to you that are pending your review" upon logging in? It could be a reminder ala Task Due Reminder, alert or even a sidebar HTML area. I've tried to do all three but failed misrably...

 

Any suggestions will be received with thanks, any method will be fine as long as the user is notified upon logging in. I can get the data well enough but I just can't think of a way to display it to the user.

I'm trying to notify the user upon login 'There are XXX Leads assigned to you that you have not read'. While I can easily get the number of Leads, the problem is how to notify the user. 

 

Is there any way to do a pop-up (ala the task due reminder upon login) or even a javascript alert? Worse case, some sort of HTML area on the sidebar? I've tried the HTML area btw, didn't work too well, can't seem to call salesforce protocols.....

I have a Javascipt/HTML enquiry page that uses the Web-to-Lead to create Leads automatically. I'm just wondering, is it possible to move that entire page into Force.com Sites without much re-coding? If yes, then can someone provide a basic guide?

 

For example, we use multiple checkboxes instead of a multi picklist to provide a better experience for the user. Will such changes be able to be brought over?

I'm just starting out on apex coding and I understand that triggers aren't actually executed per record, but in batches. I just wanted to confirm something

 

 for (Task tasksToUpdate: trigger.new)

 

Does the above for statement sufficiently capture all tasks that might execute the trigger at the same time? Or do I have to do something like an array assignment to update this? Can anyone provide a sample?

Can anyone help out with this? Basically, I want the following conditions

1) Description is not blank

2) Remarks = blank

3) Subject does not start with 'Email:'

 

if ((tasks.Description != null) &= (tasks.Remarks__c == null) &= (tasks.Subject.startsWith('Email:')== false))

 

I wrote something like this, but I think the relational operators are wrong. Is there a guide for this

I wanted to create a trigger that basically copies the first 50 characters of the Comments field in Task to a custom field. It looks kinda like this

 

for (Task tasksToUpdate: trigger.new){
Integer max=tasksToUpdate.Description.length();
if (max != 0) {
Integer endCharacter = 0;
if (max < 50)
endCharacter = max;
else
endCharacter = 50;
tasksToUpdate.Comments_Short__c = tasksToUpdate.Description.substring(0,endCharacter) ;
}
}

All well and good, but when I try to execute this with a blank Comments field, the error "execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object" shows up. I think I'm supposed to have a catch-exception when it is blank/null, but I can't understand why this doesn't work. Any ideas?

I'm just starting to try out APEX programming, so this is probably going to make experts laugh.......

I have a formula field that strips the Mobile Phone number and only stores numeric data. 
SUBSTITUTE( SUBSTITUTE( SUBSTITUTE( SUBSTITUTE( SUBSTITUTE( MobilePhone, ")", "" ), "-", "" ), "+", "" ), " ", "" ), "(", "" )

All well and good, then I thought "Can't I just use an APEX trigger to strip those characters out and just store the numeric data in the same field?"

.....well, I failed. The substitute command doesn't compile in APEX. Can someone point in me in the right direction? Or am I barking up the wrong tree here?

Hi there, just wanted to get some information from the users around here. I'm fairly new to the APEX scene and can't quite find the information I want to know.

As I understand, SFDC processes records in batches and therefore APEX coding/triggers have to be written in a manner of "batch processing". I understand that there is a limit of concurrent batches. Also, there is a limit to the number of records returned from any SOQL query. My questions are as follows

1) When writing a trigger and using the     Set<Id> idsToUpdate = trigger.newmap.keySet();command, won't we hit the limit fairly quickly if there is a large update running? As I understand, the command captures all records that execute the trigger. If I were to update 5000 records, then there will be that many entries in that set. Won't this be an issue?

2) Let's say that there is a limit of concurrent batch jobs. Using the above as an example, I want to match each newly created record to every other record in the database using Database.batchable. 
So, I can issue a (for Sobject objectname : objectList) loop and then pass each [objectname] into a Database.batchable job. 
As I understand, there is a limit to the number of concurrent batch jobs. For a sufficiently large number of records, this limit will be hit quite quickly right?

Can anyone suggest a better way for situation (2)?

From the sfdc documentation, the execution is as follows.

  1. Executes all before triggers.
  2. Runs most system validation steps again, such as verifying that all required fields have a non-null value, and runs any user-defined validation rules. The only system validation that Salesforce doesn't run a second time (when the request comes from a standard UI edit page) is the enforcement of layout-specific rules.
  3. Saves the record to the database, but doesn't commit yet.
  4. Executes all after triggers.
  5. Executes assignment rules.
  6. Executes auto-response rules.
  7. Executes workflow rules.
  8. If there are workflow field updates, updates the record again.
  9. If the record was updated with workflow field updates, fires before and after triggers one more time (and only one more time), in addition to standard validations. Custom validation rules are not run again.


I have written a "After insert" trigger that will create and attach a task that has customized comment information (based on the lead that triggers it). I want this task to be created AFTER the assignment rules have been executed. Otherwise, the task will be assigned to one person and the lead to another.

To do this, I wrote a workflow rule that will update a flag to true and modified the trigger to only execute the task creation if the flag is set to true. My understanding is that the on the first run, the trigger won't work because the flag is false, assignment rules will then change the Lead Owner, Workflow rules will update the flag and then lastly the trigger will execute (properly this time)

Unfortunately, the trigger doesn't seem to execute the second time. Is my understanding wrong? When I reviewed the debug log, the 2nd execution of the trigger that I was expecting doesn't occur.

My Leads have a validation rule such that once someone views a Lead, they can't leave the status as "Open" (as in if the Status is "Open" and the Creation DateTime is not the current date time, then trigger an error message).

 

Now, we are using the Web-to-Lead to pump questions from the website into SFDC directly. The Web-to-Lead basically writes the contact information and their query into Leads (queries are written to a non visible field called " QA"). I wrote  a trigger executing on "After insert" such that a Task will be created, the QA from Lead will be copied into the Comments in the Task and then the QA field will be cleared.

 

My problem starts here. The validation rule doesn't allow me to save the "QA" as blank because the status is Open. Is there a way to bypass this validation rule just for this scenario? Or is there a better way?

 

Any comments will be appreciated. 

Hi ,

 

   I have a formula field called opportunity stage in the case object. When this case opportunity stage(which is a formula)  goes to Closed/Won the case status(which is a picklist) should go to Resolved.

  I am trying the following trigger. But it displays error when i save the case record. Please help!

 

   

trigger updatecasestatus1 on case (before insert, before update) {
List<case> casetobeupdated = new List<case>();
for(case c : Trigger.new){
if(c.Opportunity_Stage__c == 'Closed/Won')
{

c.status = 'Resolved';
casetobeupdated.add(c);
}
}

if(casetobeupdated != null && !casetobeupdated.isEmpty())
{
update casetobeupdated;
}
}

 

 

Can anyone help out with this? Basically, I want the following conditions

1) Description is not blank

2) Remarks = blank

3) Subject does not start with 'Email:'

 

if ((tasks.Description != null) &= (tasks.Remarks__c == null) &= (tasks.Subject.startsWith('Email:')== false))

 

I wrote something like this, but I think the relational operators are wrong. Is there a guide for this

I wanted to create a trigger that basically copies the first 50 characters of the Comments field in Task to a custom field. It looks kinda like this

 

for (Task tasksToUpdate: trigger.new){
Integer max=tasksToUpdate.Description.length();
if (max != 0) {
Integer endCharacter = 0;
if (max < 50)
endCharacter = max;
else
endCharacter = 50;
tasksToUpdate.Comments_Short__c = tasksToUpdate.Description.substring(0,endCharacter) ;
}
}

All well and good, but when I try to execute this with a blank Comments field, the error "execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object" shows up. I think I'm supposed to have a catch-exception when it is blank/null, but I can't understand why this doesn't work. Any ideas?

Hi there,

I need to import a custom case trigger from sandbox to production. Any idea how to do that,

  • October 11, 2011
  • Like
  • 0