• TheresaAnderson
  • NEWBIE
  • 80 Points
  • Member since 2010

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 24
    Replies
I need a way to send a scheduled report to a public distribution list in Outlook.   Without building a rule in my Outlook instance, does anyone have a sample trigger or class that accomplishes this task?

The following trigger is creating 2 record to the custom object.  The first record represents the before results and the second record is the new information.

 

trigger CreateAlertonOpptyNextSteps on Opportunity (before update, before insert) {
  List<Opportunity> uOppty = new List<Opportunity>();
  List<Opportunity_Next_Steps_History__c> ltask = new List<Opportunity_Next_Steps_History__c>();
  for(Opportunity a: Trigger.new){
    if(a.SYS_ONS_Created__c = True && (a.X1st_Next_Step__c != '' && a.X2nd_Next_Step__c != '' && a.X3rd_Next_Step__c != '')
       && (a.X1st_Next_Step__c != Trigger.oldMap.get(a.Id).X1st_Next_Step__c || 
           a.X2nd_Next_Step__c != Trigger.oldMap.get(a.Id).X2nd_Next_Step__c ||
           a.X3rd_Next_Step__c != Trigger.oldMap.get(a.Id).X3rd_Next_Step__c)){
     Opportunity_Next_Steps_History__c t = new Opportunity_Next_Steps_History__c();
     t.Opportunity_ID__c=a.Id;
...

    t.SYS_ONS_Created_History__c = True;
     ltask.add(t);     
     Insert ltask;
    }
    a.SYS_ONS_Created__c = False;
    update uoppty;
   }}

 

What am I missing?

I want to default a word template based on button on the account layout.  Button name is 'Account Application'.

 

I have the code to trigger the event to select the template, but I want to by pass the option and default the template from the button click.

 

Any suggestions?  Can I simply add the command in the button?

 

 

For some reason, in my chatter post - the value nullis is passed through rather than the Account name from the record.  Any suggestions on why the Account name is not passing through to the Chatter Group?

 

trigger ChatterPostSURLStatus on Contract (after update) {
  List<CollaborationGroup> oG = [Select ID, Name from CollaborationGroup where Name = 'SURL Renewal'];
  for(Contract c: Trigger.new){
    
      Date mySURLDate = Date.Today();
      Date myActivatedDt = date.valueOf(c.ActivatedDate);
      if((c.RecordTypeId=='xxxxxxxxxxxxx' || c.RecordTypeId =='xxxxxxxxxxxxxxxxxxxxxxxx')
          && c.Status == 'Granted' && c.sys_post_granted_chatter__c == True){
          FeedPost sPost = new FeedPost();
          sPost.ParentId = oG[0].Id;
          sPost.Type = 'TextPost';
          sPost.Body = c.Account + ' is now supported on Warranty';
          insert sPost;
      }
     }
}

Can you help me with the following error msg?

 

Initial term of field expression must be a concrete SObject List

 

trigger ChatterPostSURLStatus on Contract (after update) {

  for(Contract c: Trigger.new){
    CollaborationGroup[] oG = [Select ID, Name from CollaborationGroup];
      if(c.Status == 'Granted' && c.ActivatedDate==Today() && oG.Name == 'Renewal'){
          FeedPost sPost = new FeedPost();
          sPost.ParentId = oG.ID;
          sPost.Body = c.Account && 'is now supported on SURL';
          insert sPost;
          }
    }
}

Can someone assist?  I'm receiving the subject error message with the following code.

 

trigger CreateBOM on Commission__c (after insert) {
    List<Commission__c> cpay = new List<Commission__c>();
//    List<Opportunity> copty = new List<Opportunity>();
    for(Opportunity obom : [select Id, Product_Family__C from Opportunity where Id = :cpay.Opportunity_Name__c]){

        for(OpportunityLineItem bomoli : [Select UnitPrice, Quantity, PricebookEntry.Product2.ProductCode,
                                   PricebookEntry.Product2Id, ListPrice, PricebookEntry.Product2.Name, Description
                                   From OpportunityLineItem where OpportunityId = :obom.Id]) {

        If(obom.product_family__c == 'Software'){
            Commission_Request_BOM__c[] ast = new Commission_Request_BOM__c[]{};
            Commission_Request_BOM__c bom = new Commission_Request_BOM__c();
//            for(OpportunityLineItem ol: BOMOLI){
                bom = new Commission_Request_BOM__c();
                bom.Opportunity__c = bomoli.Id;
                bom.Product__c = bomoli.PricebookEntry.Product2.Name;
                bom.Quantity__c = bomoli.Quantity;
                bom.List_Price__c =  bomoli.ListPrice;
                bom.Line_Description__c = bomoli.Description;
                bom.Product_Code__c = bomoli.PricebookEntry.Product2.ProductCode;
                insert bom;
//                }
          }
         }
     }     
}

Does anyone have a formula to calculate the Lead Age (creation date - conversion date)?  We are measuring the age of our Lead process.

 

Thank you.

What is the best approach for adding a Client Logo into a custom object in Salesforce? 

@isTest

public class testCreateAssetonClosedWon {
   
    static testMethod void testCreateAssetonClosedWon(){
       
        List<Account> a = [select Id, CurrencyIsoCode, name from Account where Id = 'wwwwwwww'];
        Opportunity o = new Opportunity();
        Quote q = new Quote();
        QuoteLineItem ql = new QuoteLineItem();

// create opportunity for testing
       
        o.AccountId = a.Id;  (line with error)
        o.Name = a.name + ' - test';
        o.StageName = 'Stage 3: Commit Funding';
        o.type = 'vvvvvvvvvvvvvvv';
        o.Line_of_Business__c = 'North America';
        o.license__c = 'Existing';
        o.CurrencyIsoCode = a.CurrencyIsoCode;
        o.CloseDate = date.today();
        insert o;

// create software quote for testing

        q.Name = a.name + ' - Quote test';
        q.OpportunityId = o.Id;
        q.erp__c = 'SAP';
        q.contactId = 'xxxxxx';
        q.ExpirationDate = date.today() + 30;
        insert q;
       
//create quote line items

        PricebookEntry pbID = [select Id, CurrencyIsoCode from PricebookEntry where PriceBook2ID = 'xxxxxxxxxxxxxxxxxx'
                              and CurrencyIsoCode = 'USD' and Id = 'xxxxxxxxxf' Limit 1];
        ql.QuoteId = q.Id;
        ql.Quantity = 100;
        ql.UnitPrice = 1188.00;
        ql.PricebookEntryId = pbId.Id;
        insert ql;
       
        q.status = 'Approved';
        q.Approval_Level__c = 'Approved';
        q.Quote_Approved__c = True;
//        q.IsSyncing = True;
        update q;
       
        o.StageName= 'Stage 7: Closed/Won';
        update o;
    }
}

I have a trigger that is executing 2 tasks rather than 1.  I was informed by Salesforce, the problem is related to the workflow rules; meaning the trigger is being activated twice.

 

What should I be doing differently to have the trigger executed once?

Can anyone share sample code to create a task based on a custom field on an Account record?  I believe I'm making my code way too difficult.

 

 

I'm looking for a trigger that will copy the contents of a comment field on the account record and paste into the new task that is created through a workflow rule. 

 

Does anyone have an example?

Where does the records reside when the Offline feature is enabled?  Are the records on the user's computer or in the cloud?

The following code works but not the way I expected.   The problem is if the checkbox is true, the fomula continues to add 1 everytime the record is updated. 

 

IF(Sys_SA_6_1__c = True, 1,0) +
IF( Sys_SA_6_2__c = True, 1,0) +
IF( Sys_SA_6_3__c = True, 1,0) +
IF( Sys_SA_6_4__c = True, 1,0) / 4

 

What I would prefer to have is like the following.  But the PRIORVALUE is not allowed with a checkbox. 

 

( IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) +

IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) +

IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) +

IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) ) / 4

 

Does anyone have a suggestion on how to resolve?  Ultimately, I want a field (%) to determine how many checkboxes are true for the first time and divide by 4 to support the % (knowning that the checkbox could  be true at any given time).

The following code works but not the way I expected.   The problem is if the checkbox is true, the fomula continues to add 1 everytime the record is updated. 

 

IF(Sys_SA_6_1__c = True, 1,0) +
IF( Sys_SA_6_2__c = True, 1,0) +
IF( Sys_SA_6_3__c = True, 1,0) +
IF( Sys_SA_6_4__c = True, 1,0) / 4

 

What I would prefer to have is like the following.  But the PRIORVALUE is not allowed with a checkbox. 

 

( IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) +

IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) +

IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) +

IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) ) / 4

 

Does anyone have a suggestion on how to resolve?  Ultimately, I want a field (%) to determine how many checkboxes are true for the first time and divide by 4 to support the % (knowning that the checkbox could  be true at any given time).

I need help with a trigger to set a  checkbox true on the Opportunity object when a certain task is completed.

 

IF

Task Status = 'Completed'

Task Type = 'Face to Face Meeting'

 

Then set

Sys SA 01 = True

Goal:  I want to create a trigger from Opportunities.  The trigger will create tasks when values are selected from a Multi-select custom field.  The values change as the Opportunity stage value changes.  I have the multi-select field dependent on the stage.  Now I need help with the trigger.  I will need IF statement to verify the multi-select values choosen.

 

Suggestions?

How can I reassign the Amount value on the Opportunity to each a custom field?  My goal is to have Forecast see our Net Revenue field from the opportunity page.

The following trigger is creating 2 record to the custom object.  The first record represents the before results and the second record is the new information.

 

trigger CreateAlertonOpptyNextSteps on Opportunity (before update, before insert) {
  List<Opportunity> uOppty = new List<Opportunity>();
  List<Opportunity_Next_Steps_History__c> ltask = new List<Opportunity_Next_Steps_History__c>();
  for(Opportunity a: Trigger.new){
    if(a.SYS_ONS_Created__c = True && (a.X1st_Next_Step__c != '' && a.X2nd_Next_Step__c != '' && a.X3rd_Next_Step__c != '')
       && (a.X1st_Next_Step__c != Trigger.oldMap.get(a.Id).X1st_Next_Step__c || 
           a.X2nd_Next_Step__c != Trigger.oldMap.get(a.Id).X2nd_Next_Step__c ||
           a.X3rd_Next_Step__c != Trigger.oldMap.get(a.Id).X3rd_Next_Step__c)){
     Opportunity_Next_Steps_History__c t = new Opportunity_Next_Steps_History__c();
     t.Opportunity_ID__c=a.Id;
...

    t.SYS_ONS_Created_History__c = True;
     ltask.add(t);     
     Insert ltask;
    }
    a.SYS_ONS_Created__c = False;
    update uoppty;
   }}

 

What am I missing?

Hi everyone,

 

I am trying to create a Apex trigger that automatically creates a new task record for me once a checkbox field named "School Assigned" on my custom object, "Buffalo", is checked. I want a lot of the fields in the new task record to be automatically populated in the process. The code creates the new tasks fine, but unfortunately I have been having a lot of trouble setting up the code to populate the following default fields on the Task object: 1. Owner (AKA Assigned to) and 2. What (AKA Related to). The code is copied below, with the problem lines of code in blue and the corresponding error message I get in red. I know very little about Apex, any help is very much appreciated!

 

--------------------------------------------------------------------------------------------------------------------------------------------------------

 

trigger createTaskOnBuffaloX on Buffalo__c (after insert, after update) {

List <task> taskToInsert = new List <task> ();

for (Buffalo__c b : Trigger.new) {

if (b.School_assigned__c == true) {

task task = new task ();

task.ActivityDate = b.First_CO__c;
task.Subject = 'First CO';
task.owner = b.owner;   Error: Compile Error: Field is not writeable: Owner

task.what = b.name; Error: Compile Error: Illegal assignment from String to SOBJECT:Name



taskToInsert.add(task);


}//end if

}//end for o

try {
insert taskToInsert;
} catch (system.Dmlexception e) {
system.debug (e);
}

}

For some reason, in my chatter post - the value nullis is passed through rather than the Account name from the record.  Any suggestions on why the Account name is not passing through to the Chatter Group?

 

trigger ChatterPostSURLStatus on Contract (after update) {
  List<CollaborationGroup> oG = [Select ID, Name from CollaborationGroup where Name = 'SURL Renewal'];
  for(Contract c: Trigger.new){
    
      Date mySURLDate = Date.Today();
      Date myActivatedDt = date.valueOf(c.ActivatedDate);
      if((c.RecordTypeId=='xxxxxxxxxxxxx' || c.RecordTypeId =='xxxxxxxxxxxxxxxxxxxxxxxx')
          && c.Status == 'Granted' && c.sys_post_granted_chatter__c == True){
          FeedPost sPost = new FeedPost();
          sPost.ParentId = oG[0].Id;
          sPost.Type = 'TextPost';
          sPost.Body = c.Account + ' is now supported on Warranty';
          insert sPost;
      }
     }
}

Can you help me with the following error msg?

 

Initial term of field expression must be a concrete SObject List

 

trigger ChatterPostSURLStatus on Contract (after update) {

  for(Contract c: Trigger.new){
    CollaborationGroup[] oG = [Select ID, Name from CollaborationGroup];
      if(c.Status == 'Granted' && c.ActivatedDate==Today() && oG.Name == 'Renewal'){
          FeedPost sPost = new FeedPost();
          sPost.ParentId = oG.ID;
          sPost.Body = c.Account && 'is now supported on SURL';
          insert sPost;
          }
    }
}

Hi, everyone

 

I need your help to understand and fix this problem:

I built an apex text class in a sandbox environment (i'm using eclipse) but when I run this apex test class I'm getting this error: System.QueryException: List has no rows for assignment to SObject. The problem is that the object really has records both in sandbox and in production environment !!!! I run that query in Force.com Explorer, salesforce.shema Explorer, etc. and there I can see the existing records but in the test all the time throws that error... Could anyone please guide me why is it happening and how can it be fixed?

Does anyone have a formula to calculate the Lead Age (creation date - conversion date)?  We are measuring the age of our Lead process.

 

Thank you.

@isTest

public class testCreateAssetonClosedWon {
   
    static testMethod void testCreateAssetonClosedWon(){
       
        List<Account> a = [select Id, CurrencyIsoCode, name from Account where Id = 'wwwwwwww'];
        Opportunity o = new Opportunity();
        Quote q = new Quote();
        QuoteLineItem ql = new QuoteLineItem();

// create opportunity for testing
       
        o.AccountId = a.Id;  (line with error)
        o.Name = a.name + ' - test';
        o.StageName = 'Stage 3: Commit Funding';
        o.type = 'vvvvvvvvvvvvvvv';
        o.Line_of_Business__c = 'North America';
        o.license__c = 'Existing';
        o.CurrencyIsoCode = a.CurrencyIsoCode;
        o.CloseDate = date.today();
        insert o;

// create software quote for testing

        q.Name = a.name + ' - Quote test';
        q.OpportunityId = o.Id;
        q.erp__c = 'SAP';
        q.contactId = 'xxxxxx';
        q.ExpirationDate = date.today() + 30;
        insert q;
       
//create quote line items

        PricebookEntry pbID = [select Id, CurrencyIsoCode from PricebookEntry where PriceBook2ID = 'xxxxxxxxxxxxxxxxxx'
                              and CurrencyIsoCode = 'USD' and Id = 'xxxxxxxxxf' Limit 1];
        ql.QuoteId = q.Id;
        ql.Quantity = 100;
        ql.UnitPrice = 1188.00;
        ql.PricebookEntryId = pbId.Id;
        insert ql;
       
        q.status = 'Approved';
        q.Approval_Level__c = 'Approved';
        q.Quote_Approved__c = True;
//        q.IsSyncing = True;
        update q;
       
        o.StageName= 'Stage 7: Closed/Won';
        update o;
    }
}

Can anyone share sample code to create a task based on a custom field on an Account record?  I believe I'm making my code way too difficult.

 

 

I'm looking for a trigger that will copy the contents of a comment field on the account record and paste into the new task that is created through a workflow rule. 

 

Does anyone have an example?

The following code works but not the way I expected.   The problem is if the checkbox is true, the fomula continues to add 1 everytime the record is updated. 

 

IF(Sys_SA_6_1__c = True, 1,0) +
IF( Sys_SA_6_2__c = True, 1,0) +
IF( Sys_SA_6_3__c = True, 1,0) +
IF( Sys_SA_6_4__c = True, 1,0) / 4

 

What I would prefer to have is like the following.  But the PRIORVALUE is not allowed with a checkbox. 

 

( IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) +

IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) +

IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) +

IF(PRIORVALUE(Sys_SA_6_1__c) = False, 1, 0) ) / 4

 

Does anyone have a suggestion on how to resolve?  Ultimately, I want a field (%) to determine how many checkboxes are true for the first time and divide by 4 to support the % (knowning that the checkbox could  be true at any given time).

I need help with a trigger to set a  checkbox true on the Opportunity object when a certain task is completed.

 

IF

Task Status = 'Completed'

Task Type = 'Face to Face Meeting'

 

Then set

Sys SA 01 = True

Goal:  I want to create a trigger from Opportunities.  The trigger will create tasks when values are selected from a Multi-select custom field.  The values change as the Opportunity stage value changes.  I have the multi-select field dependent on the stage.  Now I need help with the trigger.  I will need IF statement to verify the multi-select values choosen.

 

Suggestions?

Goal: use a trigger to update a custom field on the Task (OppNumber) with a field on the Opportunity that is selected in the WhatID field (if an Opp is selected)

 

I thought this would be easy to do using a lookup and just passing the value, but you apparently cannot create a lookup on the Activity/Task object. 

 

I know I can pull in the record ID for the opp related via the WhatID field, but how can I refer to a specific field on that record? (Such as the Opportunity Number).

 

Open to suggestions.