• craigmh
  • SMARTIE
  • 639 Points
  • Member since 2010

  • Chatter
    Feed
  • 24
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 336
    Replies

I am working on trigger for email to case which is working. But I have a new problem. The trigger is causing aproblem from when ticket is created through Salesforce(logging in salesforce and creatig a ticket). I am trying to create a ticket, this is the error I am getting.

Error: Invalid Data. Review all error messages below to correct your data. Apex trigger CaseContactOwnerName caused an unexpected exception, contact your administrator: CaseContactOwnerName: execution of BeforeInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times): Trigger.CaseContactOwnerName: line 13, column 1

Here is trigger:

trigger CaseContactOwnerName on Case(before insert)

{

List<Case> newCase = new List<Case>();

List<Contact> con = new List<Contact>();

List<String> emailList = new List<String>();


for(Case c: trigger.new)

{

system.debug('*********' + Trigger.new);

 

//create a new email id for the case(s) being created emailList.add(c.SuppliedEmail); }

con= [select id from Contact where email=:emailList];
}

Please help me in making query selective in the above code because I have no idea what have to be done?
 

Thanks, Abhishek Ray

Hi,

 

Iam trying to pull Salesforce id of record in Account on the basis of a record value (field: Duns number) from the contact 
Iam new to Triggers and Apex ..
please help me how to go about this,...  

The situation is this:

I have a production org where various changes over time MIGHT cause tests (which originally passed) to now fail. What happens if I run all of the tests in Prod, but the 75% is not met? Will the Prod Org suddenly disable it's self and stop working? 

 

ALSO, I've developed some new classes and pages in my DEV org. I've written the test classes and everything is good ... more than 75% coverage. So the question is: If I migrate just those new classes to production, will tests automatically run for just those NEW classes, or will ALL tests for everything in Prod run??? Assuming it will run ALL the tests, what happens if the 75% coverage is not met?

 

Thanks,

Mike

Hi,

 

How can i make this soqgl query more efficent so i dont hit any govner limits

 

        String query;
        if(contractIds == null || contractIds.size() == 0)
            query = 'Select id FROM Ceto_Contract__c WHERE (Status__c = :statusActive OR Status__c = :statusPending) AND (Contract_Expiration_Date__c > :runDate OR Contract_Expiration_Date__c = null) AND (Cancellation_Date__c > :runDate OR Cancellation_Date__c = null)';
            
        if(Test.isRunningTest())
            query += ' limit 1';
        return query;

 

Thanks

Hi,

 

   I have changed a little bit code from xmlstreamreaderdemo which I got from google.It is not returning the value when i changed the code can anyone help me in this issue

 

here is the code that I got from google

public class XmlStreamReaderDemo {

// Create a class Book for processing      

  public class Book {   

   String name;     

   String author;   

 }

   Book[] parseBooks(XmlStreamReader reader) {  

    Book[] books = new Book[0];

     while(reader.hasNext()) {

//  Start at the beginning of the book and make sure that it is a book        

      if (reader.getEventType() == XmlTag.START_ELEMENT) {       

      if ('Book' == reader.getLocalName()) {

//  Pass the book to the parseBook method (below)                 

     Book book = parseBook(reader);               

  books.add(book);         

    }      

    }    

     reader.next();

     }  

   return books;

   }

// Parse through the XML, deterimine the auther and the characters      

  Book parseBook(XmlStreamReader reader) {    

  Book book = new Book();     

 book.author = reader.getAttributeValue(null, 'author');     

while(reader.hasNext()) {        

 if (reader.getEventType() == XmlTag.END_ELEMENT) {         

   break;        

}

 else if (reader.getEventType() == XmlTag.CHARACTERS) {          

  book.name = reader.getText();   

      }        

 reader.next();     

}     

 return book;

   }

// Test that the XML string contains specific values

        static testMethod void testBookParser() {

     XmlStreamReaderDemo demo = new XmlStreamReaderDemo();

     String str = '<books><book author="Chatty">Foo bar</book>' + '<book author="Sassy">Baz</book></books>';

     XmlStreamReader reader = new XmlStreamReader(str);     

Book[] books = demo.parseBooks(reader);

     System.debug(books.size());

     for (Book book : books) {    

    System.debug(book);  

    }   

 }

}

 

 

and the code which i edited is

 

public class XmlStreamDemo {

     public string link{get;set;}  

  public string socialnetwork{get;set;}   

    public class Network{     

String name;     

 String field;

   }

   Network[] parseNetworks(XmlStreamReader reader) {     

Network[] socialnetwork= new Network[0];     

 while(reader.hasNext()) {        

  if (reader.getEventType() == XmlTag.START_ELEMENT) {           

  if ('Network' == reader.getLocalName()) {

               Network link = parseNetwork(reader);            

     socialnetwork.add(link);            

 }        

  }       

  reader.next();     

}    

return socialnetwork;  

  }   

 Network parseNetwork(XmlStreamReader reader) {   

   Network link = new Network();    

  link.field= reader.getAttributeValue(null, 'Image');   

   while(reader.hasNext()) {     

    if (reader.getEventType() == XmlTag.END_ELEMENT) {       

     break;        

 }

else if (reader.getEventType() == XmlTag.CHARACTERS) {     

       link.name = reader.getText();       

  }      

   reader.next();     

 }     

return link;  

}  

Public void refer() {

     XmlStreamDemo demo = new XmlStreamDemo();

     String str = '<socialnetwork><link Image="Chatty">Aruna</link>' +  '<link Image="Sassy">Baz</link></socialnetwork>';     

   XmlStreamReader reader = new XmlStreamReader(str);       

   Network[] socialnetwork= demo.parseNetworks(reader);

     System.debug('======'+socialnetwork.size());

  // System.debug('==========='+socialnetwork);    

  for (Network link:socialnetwork) {  

      System.debug('-------'+link);     

}  

  }

}

 

whenever I paste the first code I'm getting the values in system.debug.....but when i tried my own code it's returning the size as '0'.can anyone help me in this issue

Hi,

 

We have a config sandbox linked to a full sandbox, linked to production.

 

We are in the process of implementing some new code, can someone help me - do the field ID's change between the environments?

 

for example, we have a button that does a custom clone via a VF page and updates a lookup field. this field, do the ID's change between the different orgs or / and will salesforce auto correct this?

 

Thanks for any help in advance

Hello Board,

 

We have a managed package which has Job as one of the object.

 

We have introduced a new field(TextField) for the Job object in new version.

 

We want to populate data for this field.

 

How can we populate data for this field?

 

Thanks,
Devendra

 

Hi all does anyone know how i can create a map which has an id then a list of opportunities associated with it? 

 

something like 

 

map<string, List<Opportunity>> oppMap = newmap<string, List<Opportunity>>([select o.Sugar_ID__c, o.id from Opportunitywhere AccountId = null]);

 

where the Sugar_ID__c is the key and the opp id is the value, i know what i need to do just not sure how to do it. 

 

Thanks All

I have an approval process, and as a result of the approval process, I would like the system to update the Account Owner field to be the user who submitted the approval request. I've created two custom fields that I think should help me accomplish this.

 

1) a text field called Submitter_ID__c that automatically updates (as part of the approval process) to display the User ID of the user that submitted the approval request

 

2) a checkbox called Reassign_Account_Owner__c that will be marked as true as an action on the last approval step.

 

What I would like to do is build a trigger that fires when the Reassign_Account_Owner__c field is TRUE and updates the Account Owner using the User ID that is in the Submitter_ID__c field.

 

I'm new to Apex though and I'm not sure of the best way to start this. Does anyone have any ideas or anywhere they can point me to get some direction? Thank you very much!

 

I have a trigger that I update before wether a insert or update. The problem that I am having is that I update the value in the trigger before section.  But for some reason that update to the object is trigger another update.  Is there a way to either not have the trigger, trigger the update after or capture the object before the trigger.

 

Thanks

 

JWG

for(Lead lead: leads)

 

what the each lead is representing

 

For(Lead lead: tigger.new)

 

I want know the difference

 

thanks

So I've got a query where I'm trying to see if a user did something within the past 15 minutes

The query asks if theres a record where created date is greater than now - 15 minutes, limit 1

It works fine when theres results, but when theres no results, the query doesnt work

I was hoping I could ask to see if the result object is null, but instead I receive an error

 

Do i need to make a list for this just to see if its empty?

Im only looking to see if one record exists, so using a list seems to be overkill

Hi All,

 

I've written a trigger on the lead object :

 

 trigger foo  on Lead (after update)

{

  System.debug('Starting foo');

 

  if (Trigger.old[0].IsConverted == false && Trigger.new[0].IsConverted == true)

          {

 // lead is being converted do sanity check to make sure all fields are filled out if not

//  add a  Trigger.new[0].addError('missing info') to fail the conversion.


  }

}

 

running this code in the UI seems to work fine which is a good start. Now I'm trying to write my unit tests for this class however I believe that the trigger is not being fired (Test coverage of selected Apex Trigger is 0% at least 1% test coverage is required.) Also the 'Starting foo' debug message is not present in the log file. I have the log level set to finest possible.

 

Here is my first unit test method

 

static testMethod void foo_ValidateOnConvert_ValidValues() 

{

Lead myTestLead = new Lead();
myTestLead.Email = 'kbradley@merx.com';
myTestLead.LastName = 'Bradley';

 

insert myTestLead; 

 

Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(myTestLead.id);

LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);

Database.LeadConvertResult lcr = Database.convertLead(lc);

 

System.assert(lcr.isSuccess() == true);

}

 

TIA for any ideas and suggestions,

 

KJB

 

 

 

 

 

 

I have a list I need to sort by a primary key as well as a secondary key - I tried ORDER BY fieldName AND fieldNAME as well as ORDER BY fieldName AND BY fieldName - neither one compiled on save. 

 

Any ideas? 

 

Thanks!

 

JoAnn

Hi.. 

 

I have the following page

 

<apex:page controller="ValueManager" showheader="false">

<apex:pageblock >
<apex:pageblocktable value="{!Value}" var="par">

<apex:column headervalue="Parent Value">
<apex:outputtext value="{!par.Name}"/>
</apex:column>

<apex:column headervalue="Child Value">
<apex:pageblocktable value="{!par.Child_Parent_Value__r}" var="ch">
<apex:column value="{!ch.Name}" headervalue="Value"/>
<apex:column value="{!ch.VSDesc__c}" headervalue="Description"/>
</apex:pageblocktable>
</apex:column>

<apex:column headervalue="Description">
<apex:outputtext value="{!par.VSDesc__c}"/>
</apex:column>

</apex:pageblocktable>
</apex:pageblock>

</apex:page>

 

I want to remove the headers of the 'Child Value' i.e 'Value' and 'Description' if no record exist...

 

Can anyone tell me how can it be done?? 

 

Thanks

  • February 17, 2012
  • Like
  • 0

We change the owner of our opportunities when the owner changes from one certain stage to another, but need to have the previous owner for a report. I want to put the name of the previous owner in a custom lookup field that I created when the stage changes from "App In" to something else. I'm really a beginner with triggers, can anyone help? I've tried doing it with workflows and it doesn't allow me to do it. I'm thinking I need an apex trigger.

 

Any ideas?

Hello.  I have been doing the initial development of an app in my sandbox for several weeks...so I have essentially disregarded what has been in my production version because no one is using it yet.

 

Well, I am about do upload my app - and have run into an issue.  I noticed that I have a "Test Controller A" in my production org.  I had uploaded this to the production version a while back just to test the upload process...so it serves absolutely no purpose. 

 

My problem is that I am trying to figure out how to delete this controller.  There is no "delete" link in the production version for this controller.  What is more concerning is that I deleted this controller from my sandbox several weeks ago...so I am not sure how to get rid of it.

 

Any thoughts?

 

Thanks.

Hi,

 

I am trying to get the previous stage value showing up in a custom field without success.

 

Do you now how can I have a "previous stage" field in the record without having to use the history tracking!

 

It is for reporting and I can not track on opportunities with products and history tracking!!!

 

Any ideas.....??

 

Thanks

  • February 13, 2012
  • Like
  • 0

Hi,

 

 Can someone please help me here - i am getting this error 

line 7, column 27: Method does not exist or incorrect signature: accountContractMap.get(String)

 

Map<Id, List<Contract>> accoutContractMap = new Map<Id, List<Contract>>();
//Prepare the map of Account Id as key and the list of contracts associated with it
for(Contract c: [SELECT Id, AccountId, CreatedDate, Status from Contract Limit 100])
{
if(accoutContractMap.get(c.AccountId) != null)
{
System.debug(accountContractMap.get(c.Status));
accountContractMap.get(c.AccountId).add(c);
}
else
{
List<Contract> temp = new List<Contract>();
temp.add(c);
accountContractMap.put(c.AccountId, temp);
}
}
System.debug('Map of account id and the list of contracts is' + accoutContractMap);

 

thanks so much.

I know it must me a syntax issue , but why my "and" on the rendered is not working ?

 

Thanks!

 

<apex:page standardController="Opportunity" rendered="{!Opportunity.Split_OK__c == True} && {!Opportunity.Split_count__c = 0}" >
 <script language = "JavaScript">

alert ('You have checked the SPLIT box. Please create a record for the Split and specify the percentage of the Split');

 </script>
</apex:page>

 

I currently have a utility that works on converting currency amounts efficiently.

 

I built this to deal with the aggregates issue:

"If a query includes aGROUP BYorHAVINGclause, any currency data returned by using an aggregate function, such asSUM()orMAX(), is in the organization's default currency. You cannot convert the result of an aggregate function into the user's currency by calling theconvertCurrency()function."

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_querying_currency_fields.htm

 

I have a VisualForce page where Account is the standard controller, and I'm doing a sum of custom object records. Since the Organization is multi-currency, the non-org default Accounts show the sums in the org default currency. I built an Apex class to deal with this and other minor currency-related issues, and thought it might be generally useful.

 

Is there enough interest for me to put this up on AppExchange?

Here is the error message in the email (IDs hidden):

 

Apex script unhandled trigger exception by user/organization: 005xxxxxxxxxxxx/00Dxxxxxxxxxxxx

TRIGGERNAME: execution of AfterUpdate

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

Trigger.TRIGGERNAME: line 70, column 1

 

The trigger copies a custom object that holds the products for Lead. When the Lead is converted to an Opportunity, the trigger creates an OpportunityLineItem for each Lead Product, like so (after update on the Lead, pbIDs is a Map<string, Id> with the PricebookEntry IDs):

 

for(LeadProduct__c prod:leadProducts) {
	OpportunityLineItem newProd = new OpportunityLineItem();
	newProd.PricebookEntryId = prod.PricebookEntry__c;
	newProd.OpportunityId = l.ConvertedOpportunityId;
	newProd.Quantity = prod.Quantity__c;
	newProducts.add(newProd);
}
insert newProducts;

 

I was thinking that there may be some trigger doing an Insert with an ID, but wouldn't the error email have the name of that trigger? It has the name of mine. And as you can clearly see, my trigger is not specifying the ID for the records that it's inserting.

 

What's even stranger is that the User ID specified in the email does NOT exist. I checked it, and got an "Insufficient Privileges: You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary." I send the ID to my system admin, and THEY get the same exact issue. So I'm thinking that this may be occurring in a test, since this process is working correctly, except for one user that doesn't actually exist.

The Quick Save button isn't working in my sandbox on CS12, running Spring '12. This is for Apex Classes and Triggers. Anyone else experiencing this?

I have a custom object that I'm developing with. Is there any way to test in Apex whether or not the current user has the View All Data permission on this custom object alone, not the organization-wide one?

I get this error on my page for Users with a Profile that don't have the "View All Data" permission:

Content cannot be displayed: No such column 'Id' on entity 'Partner'. 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.

 

But I don't see ANY place to change the permissions for the Partner sObject. Does anyone know where this is?

Is there a DEV 531 Exam? I was studying for the 401 exam and noticed that it's not really development material. Not only that, but a certified admin at my company gave me the notes from the admin exam, and the "development" one is the same material with different wording.

 

If I'm going to get certified, I want to take an exam that actually deals with what I use. So is there a DEV 531 exam or something similar, that actually has Visualforce/Apex on it?

I've run into an issue with a trigger...it does a picklist describe on three separate fields, so each time it fires, it only has 3 describes. I've bulkified it so that this isn't done in a loop. The issue is that the trigger is limited by the batch size of 200 records. So if I insert 1000 records, the trigger runs 5 times, and 15 describes are performed. Since the picklist describe limit is 100, and it's for the entire DML operation, not just each batch, this means I can only run the trigger 33 times. At 200 records per batch, that's 6,600 records, which is definitely a good-sized chunk. But being able to insert 10,000 records at a time, I bump into the picklist describe limit first. I'm just wondering if there's a better methodology, other than storing the picklist values somewhere else, and referencing that instead of doing describes.

Here is my code:

 

sObject obj = database.query('Select DateField__c From OpportunitySchedule__c Where Id = \'' + string.escapeSingleQuotes(objId) + '\' Limit 1');
date dtSelectedDate = date.valueOf(obj.get('DateField__c'));

 

 DateField__c is of datatype date, not datetime.

 

When I try to run this code, this is the error that I get:

Invalid date: 2011-06-25 00:00:00

 

When I try to cast it as a datetime, this is the error that I get:

Invalid date/time: 2011-06-25 00:00:00

 

When the date is cast as a string, is it converted to a format that is impossible to get back to a date or date/time by any method other than manual parsing?

 

FYI, here's my hack fix, after the query:

 

string strDate = string.valueOf(obj.get('DateField__c'));
strDate = strDate.substring(0, strDate.indexOf(' '));
date dtSelectedDate = date.valueOf(strDate);

 

I've found that when I do a describe on any SObject, the Unique property of the Id field is returned as False. Is this done by design? I was expecting this to be returned as True. I searched for any reason as to why this might be, but couldn't find anything. Does anyone have any input?

I've had an issue with deleting records, which I thought was caused by the size of the batches. But when I run this in the System Log:

 

delete [Select Id From CustomObject__c Limit 1];

 

I get this error:

 

EXCEPTION_THROWN|[1]|System.DmlException: Delete failed. First exception on row 0 with id xxxxxxxxxxxxxxxxxx; first error: UNKNOWN_EXCEPTION, Operation affected too many rows: []

 

How is it possible that one row is too many? Is there a daily limit for DML rows?

 

I have a quick question about the Comparison Operators documentation. I just wanted to make sure I wasn't going crazy. On that page, I saw this example under the LIKE operator:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_comparisonoperators.htm

 

For example, the following query matches Appleton, Apple, and Bappl , but not Appl: 
SELECT AccountId, FirstName, lastname FROM Contact WHERE lastname LIKE 'appl_%'

 

Looking at this example, I can't see why Bappl would match. Not only is there no wildcard for the "B", but there is no character after the "l" for the underscore wildcard. Am I completely missing something, or is this simply an oversight in the documentation?

  • September 13, 2011
  • Like
  • 0

Is there any way to set up uncaught exceptions to be emailed to multiple users?  I'm currently developing Apex classes/triggers for a client, and we would both like to receive these emails, but it seems limited to only the developer.

Hi ,

I am learning how to use visualforce. And I copy an example of visualforce developer guide.  And when I save to salesforce server from ecilpse, I meet this error message"Attribute taborderhint is not supported for <apex:inputField> when this component is a direct or indirect child of <apex:dataTable>". codes as below:

<apex:page controller="OppsController">
<apex:form>
<apex:dataTable value="{!OpportunitiesWithIndex}" var="oppWrapped">
<apex:column>
<apex:facet name="header">Opportunity</apex:facet>
<apex:outputField value="{!oppWrapped.opp.name}"/>
</apex:column>
<apex:column>
<apex:facet name="header">Amount</apex:facet>
<apex:inputField value="{!oppWrapped.opp.amount}"
taborderhint="{!oppWrapped.tabIndex}"/>
</apex:column>
</apex:dataTable>
</apex:form>
</apex:page>

 

 

apex:

public class OppsController {
// Get a set of Opportunities
public ApexPages.StandardSetController setCon {
get {
if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT name, type, amount, closedate FROM Opportunity]));
setCon.setPageSize(5);
}
return setCon;
}
set;
}
public List<Opportunity> getOpportunities() {
return (List<Opportunity>) setCon.getRecords();
}
public List<OppWrapper> getOpportunitiesWithIndex() {
List<Opportunity> opps = this.getOpportunities();
List<OppWrapper> oppsWrapped = new List<OppWrapper>();
Integer idex = 1;
for (Opportunity opp : opps) {
oppsWrapped.add(new OppWrapper(opp, idex));
idex++;
}
return oppsWrapped;
}

 

 

 

Hi All,

 

 I have two after insert triggers on sameobject.I want to know which one will execute first?

 

Thanks

I am pretty new to APEX and with help wrote a trigger to auto-update a lookup field based on selecting a value on a picklist field on the account object. It works fine on the Account object.  Now I am trying to replictae it on a custom object and the code below is giving me errors.

 

Error: Compile Error: unexpected token: 'Map" at line 1 column 14



public static Map<String, List<Primary_Sales_Rep__c>> filterPrimarySalesRepsWithChangedVerticals(List<Primary_Sales_Rep__c> incomingPrimarySalesReps,
Map<Id, PrimarySalesRep__c>oldPrimarySalesRepIdToOldPrimarySalesRep)
{

Map<String, List<PrimarySalesRep__c>> verticalNametoPrimarySalesRepList = new Map<String, List<PrimarySalesRep__c>>();

//For all PrimarySalesRep that were sent to out Trigger
for(PrimarySalesRep__c incomingPrimarySalesRep : incomingPrimarySalesReps)
{
//Change conditions
//1.Vertical is now being set
//2. Vertical is being changed

Boolean isChanged
Boolean isInsert - oldPrimarySalesRepIdToOldPrimarySalesRep == null;
PrimarySalesRep__c oldPrimarySalesRep = isInsert ? null : oldPrimarySalesRepIdToOldPrimarySalesRep.get(incomingPrimarySalesRep.Id);

isChanged = (( isInsert && incomingPrimarySalesRep__c.Vertical_Major__c != null)
||(!isInsert && oldPrimarySalesRep__c.Vertical_Major__c != incomingPrimarySalesRep__c.Vertical_Major__c));

if(isChanged)
{
if(!verticalNameToPrimarySalesRepList.containsKey( incomingPrimarySalesRep__c.Vertical_Major__c))
verticalNameToPrimarySalesrepList.put(incomingPrimarySalesRep__c.Vertical_Major__c, new List<PrimarySalesRep__c>));

verticalNameToPrimarySalesrepList.get( incomingPrimarySalesrep__c.Vertical_Major__c).add(incomingPrimarySalesrep__c);
}

}
return verticalNametoPrimarySalesRepList;
}

 

I am working on trigger for email to case which is working. But I have a new problem. The trigger is causing aproblem from when ticket is created through Salesforce(logging in salesforce and creatig a ticket). I am trying to create a ticket, this is the error I am getting.

Error: Invalid Data. Review all error messages below to correct your data. Apex trigger CaseContactOwnerName caused an unexpected exception, contact your administrator: CaseContactOwnerName: execution of BeforeInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times): Trigger.CaseContactOwnerName: line 13, column 1

Here is trigger:

trigger CaseContactOwnerName on Case(before insert)

{

List<Case> newCase = new List<Case>();

List<Contact> con = new List<Contact>();

List<String> emailList = new List<String>();


for(Case c: trigger.new)

{

system.debug('*********' + Trigger.new);

 

//create a new email id for the case(s) being created emailList.add(c.SuppliedEmail); }

con= [select id from Contact where email=:emailList];
}

Please help me in making query selective in the above code because I have no idea what have to be done?
 

Thanks, Abhishek Ray

hi..

 i wrote trigger on contract object.and it have some fields like start date,end date..and the contract period is 1year.but my need is before 60days of end date email will sent to the user..

 

 

i write the trigger..and i add the function today() the email is came..but how to add the 60days before of end date??

 

can anyone suggest me please??

 

Thanks&Regards

Bhagi.n

  • July 02, 2012
  • Like
  • 0

Hi i want to delete the record from the pageblocktable when the user uncheck the checkbox from that column.itmust delete the specfice record from account object..cn anyone help me

 

 

 

 

 

thanks in advance

 

  • July 02, 2012
  • Like
  • 0

Hi,

 

 

I created a custom button and i want that button should work for queue member only if anyone else is clicking that button then it should show alert message that you are not the member of queue. How i can implement this in custom button creation using javascript or anything else.

 

Thanks in Advance.

 

Thanks:))))

Hi,

 

Iam trying to pull Salesforce id of record in Account on the basis of a record value (field: Duns number) from the contact 
Iam new to Triggers and Apex ..
please help me how to go about this,...  

I was wondering if anyone had an idea of how I could go about solving this problem.  I have two websites, but only one API user (I'm not going to pay a monthly fee for another user strictly for API usage).  I want to setup workflow e-mail alerts as follows:

 

1. When a case comment is created on Site A, send an e-mail to some e-mail address.

2. When a case comment is created on Site B, send an e-mail to some other e-mail address.

 

Does anyone have any ideas for how I could detect where the comment was created from?  Salesforce doesn't let you create any custom fields on comments, so that won't work.  I can't base it on who created the comment since it's always the same API user.  Do I have any worthwhile options here?

 

Thanks

I believe I just found two bugs (?) in the platform that I can't seem to find documentation on. The first is a compilation issue. You can't apparently assign to a private static variable if it has a setter but no getter.

 

public class X {
    private static boolean Y {
        set {
            y = value;
        }
    }

    static {
        x.y = true;  // This line fails to compile: 'Variable is not visible'
    }
}

 The second problem is with code coverage. If a getter/setter is on the same line as the variable declaration, you get code coverage, otherwise, you don't. Example follows.

 

// EXPECTED RESULT: 100% CODE COVERAGE
// ACTUAL RESULT: 66% CODE COVERAGE
public class X { public static boolean Y { get { return true; } } public static boolean Z { // THIS LINE DOES NOT GET CODE COVERAGE get { return false; } }
public static testMethod void test() {
System.assertEquals(true,x.y);
System.assertEquals(false,x.z);
} }

Has this been a problem for anyone else?

 

MS Excel has a function where you can write out a number, for example 50 would be fifty. You use SpellNumber(50) I think.

 

Is there an equivalent within Salesforce?  I need to take a currency field and write it out when creating a contract with the Ts and Cs in it.

Hi,

 

My Test class is giving Too Many Future Calls Exception in Production Environment though it worked fine in the TEST environment (i.e. without any failure).

While deploying to production the test class is throwing

System.LimitException : Too many future calls :11

 

I have checked the number of times future method is called, it is less than 10 for each test method (So it wasn't giving any failure in TEST env.)

 

What may be the reason of the failure coming in Production Enviroment specifically?

Hello Community,

 

I want to retrieve the records of the custom/standard object of the current user. 

 

In addition, what if for example I want to grab the records of the current user and their profiled organization. I.E Bob's profile has set Organization to "Rakio". I want to grab records that belong to Bob who is the current user logged in, and "Rakio"

 

Thank you,
David 

Hi, I am trying to find the available RecordTypes for a User or User's Profile from my APEX class. Any idea how can this be done?

Can someone point me to the documentation for SOQL's "WHERE x IN :y" syntax, where y is a collection type (list, set, map).  I've tried searching for it, but "where" and "in" are such generic terms that my searches are essentially as useful as just searching for "soql" alone.

 

Thanks!

I need the security token of Sandbox and Production. But there is no option under setup configuration for regenerating it. 

My profile is System Admin but still I am facing this problem.

 

I also tried to regenerate the token by changing the password. But no mail is sent to the id associated with the user accessing the sandbox.

 

Please help.

 

Thanks