• Skeeter
  • NEWBIE
  • 75 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 23
    Replies
I am trying to create apex sharing for read-only access on a private object to a custom lookup field, but it doesn't seem to be making the record visible.  

Any help is greatly appreciated.
 
Trigger Requester_Ticket_Sharing on BMCServiceDesk__Incident__c (after insert, after update) {
  
  if(trigger.isInsert){

  List<BMCServiceDesk__Incident__Share> ticketShares = new List<BMCServiceDesk__Incident__Share>();

  for(BMCServiceDesk__Incident__c inc : trigger.new){

  BMCServiceDesk__Incident__Share hiringManagerShare = new BMCServiceDesk__Incident__Share();

  hiringManagerShare.ParentId = inc.Id;

  hiringManagerShare.UserOrGroupId = inc.Requester__c;

  hiringManagerShare.AccessLevel = 'Read';

  hiringManagerShare.RowCause = Schema.BMCServiceDesk__Incident__Share.RowCause.Requester_Access__c;

  // Add the new Share record to the list of new Share records.
  ticketShares.add(hiringManagerShare);
  }
  // Insert sharing records and capture save result

  Database.SaveResult[] lsr = Database.insert(ticketShares,false);

  // Create counter
  Integer i=0;

  // Process the save results
  for(Database.SaveResult sr : lsr){
  if(!sr.isSuccess()){
  // Get the first save result error
  Database.Error err = sr.getErrors()[0];

  if(!(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION

  && err.getMessage().contains('AccessLevel'))){
  // Throw an error when the error is not related to trivial access level.
  trigger.newMap.get(ticketShares[i].ParentId).
  addError(
  'Unable to grant sharing access due to following exception: '
  + err.getMessage());
  }
  }
  i++;
  }

  }

}

 
I'm trying to create a validation rule that will prevent a user from changing the stage of an opportunity to anything but 'Unqualified' unless one of the following criteria is true.
1. Division does not contain Payer, Marketing, HR
2. Score > 0
3. Business Type = Renewal
4. AOV = 0 or <= 20000

I thought I had it correct, but when I tested an oppty with the division of HR, score = 0 and AOV = 50k it passed and it shouldn't have.

Any help is appreciated.
 
AND(
NOT(ISPICKVAL(StageName,"Unqualified")),
ISCHANGED(StageName),
NOT(
OR(
CONTAINS(Division__c,"HR"),
CONTAINS(Division__c,"Payer"),
CONTAINS(Division__c,"Marketing"),
Score__c > 0,
ISPICKVAL(Business_Type__c,"Renewal"),
AOV__c <= 20000)))

 
I'm having problems getting any coverage to my test class.  I'm not sure what I'm missing.  Any help is greatly appreciated.

Controller
public class ExecFinController {

  public ExecFinController(ApexPages.StandardController controller) {

    }
	public Flow.Interview.BI_Executive_Finance_Flow myFlow { get; set; }
    
	public PageReference getOID() { 
        
  	Schema.DescribeSObjectResult result = BI_Executive_Financial_Dashboard__c.SObjectType.getDescribe(); 
        
  	PageReference pageRef = new PageReference('/' + result.getKeyPrefix() + '/o'); 
  	pageRef.setRedirect(true); 
        
  	return pageRef; 
}
}
Visualforce Page
 
<apex:page StandardController="BI_Executive_Financial_Dashboard__c" extensions="ExecFinController" TabStyle="BI_Executive_Financial_Dashboard__c">
    <flow:interview name="BI_Executive_Finance_Flow" finishLocation="{!OID}"/>
</apex:page>

Test Class
@isTest(SeeAllData=true)
private class BIExecFinControllerTest 
{

    public static testmethod void ExecFin()
    {
        
        Date currentDate = date.today();
   
                      
      BI_Executive_Financial_Dashboard__c exec = new BI_Executive_Financial_Dashboard__c();
        exec.Period__c = 'Monthly';
        exec.Amount_for_Period__c = 100;
        exec.Period_Begins_On__c = currentDate;
        exec.Business_Unit_Text__c = 'Test Unit';
        exec.Period_Metric__c = 'Test';
        insert exec; 
        
        Test.startTest();
        
        List<BI_Executive_Financial_Dashboard__c> fin = new List<BI_Executive_Financial_Dashboard__c>();
                
        ApexPages.Standardcontroller stdexec = new ApexPages.Standardcontroller(exec);
        ExecFinController controller = new ExecFinController(stdexec);
        
        PageReference FlowPageRef = Page.BI_Financial_Dashboard;
    	Test.setCurrentPage(FlowPageRef);
        
        Test.stopTest();
     
     
    }
    
}


 
I am trying to create a custom button that will start a visual flow and finish at the list view of that object.  
The VF page does not show as an option to overwrite the new button.  I'm pretty sure this is because I am not using a standard controller.

Any help is greatly appreciated.

Visualforce Page
<apex:page Controller="ExecFinController" TabStyle="BI_Executive_Financial_Dashboard__c">
    <flow:interview name="BI_Executive_Finance_Flow" finishLocation="{!OID}"/>
</apex:page>

Controller
public class ExecFinController {

public Flow.Interview.BI_Executive_Finance_Flow myFlow { get; set; }

public PageReference getOID() { 
  Schema.DescribeSObjectResult result = BI_Executive_Financial_Dashboard__c.SObjectType.getDescribe(); 
  PageReference pageRef = new PageReference('/' + result.getKeyPrefix() + '/o'); 
  pageRef.setRedirect(true); 
  return pageRef; 
}

}

 
Hi,

Is it possible to create a checkbox formula field to check the box if the multi-select picklist field has more than one selection?

Thank you!
I'm having problems getting my validation to work.  It should prevent the stage to be changed to anything but unqualified unless one of the following is true.

1. Owner Division does not contain = ‘Finance’, ‘IT’, ‘Marketing’
2. Score > 0
3. Business Type = Renewal
4. Owner Division equals ‘Finance’ and Total <= $20,000
5. Total = 0

This is what I have, but it doesn't seem to be working.  It is allowing me to change the stage when no statements above are true.
 
OR( 
AND( 
NOT(ISPICKVAL(StageName,"Unqualified")), 
ISCHANGED(StageName), 
NOT( 
OR( 
CONTAINS(Opportunity_Division__c,"IT"), 
CONTAINS(Opportunity_Division__c,"Finance"), 
CONTAINS(Opportunity_Division__c,"Marketing"), 
Score__c > 0, 
ISPICKVAL(Business_Type__c,"Renewal"), 
Total__c = 0.00)), 
AND( 
NOT(ISPICKVAL(StageName,"Unqualified")), 
ISCHANGED(StageName), 
CONTAINS(Opportunity_Division__c,"Finance"), 
NOT(Total__c <= 20000))))

 
Criteria: User should not be able to change the stage of an oppty to anything but unqualified except if these conditions are true.

Division does not contain sales or finance
lead score > 0
type = renewal
total = 0.00

I have it working, but now I need to add the following to not include in the validation:
If the division contains sales and total  <= 10000

I'm not sure how to add that portion, since the current is looking for not contains 'Sales'
AND( 
NOT(ISPICKVAL(StageName,"Unqualified")), 
ISCHANGED(StageName), 
NOT( 
OR( 
CONTAINS(Division__c,"Sales"), 
CONTAINS(Division__c,"Finance"), 
Score__c > 0, 
ISPICKVAL(Type__c,"Renewal"), 
Total__c = 0.00)))

 
I need to update my trigger to not fire if the Staff__c lookup field on the escalated ticket is not null.  I wasn't sure where to include 
Staff__c != null

I tried at this line but it didn't work.
if(mapOfTicket.get(n.ParentId).client__c == n.OwnerId){

 
trigger NoteAI on Note (after insert) {
    
    //Collect all ParentIds into a set
    Set<Id>incIds = new Set<Id>();
    
    for(Note n : trigger.New){
        if(n.ParentId.getSobjectType() == EscalatedTicket__c.SobjectType){
        	incIds.add(n.ParentId);
        }
    }
    
    Map<Id,EscalatedTicket__c> mapOfTicket = new Map<Id,EscalatedTicket__c>([select Id,client__c , ClientUpdated__c from EscalatedTicket__c where id in:incIds]);
    Boolean updateValues = false;
    for(Note n : trigger.new){
    	if(mapOfTicket.ContainsKey(n.ParentId)){
    		if(mapOfTicket.get(n.ParentId).client__c == n.OwnerId){
    			mapOfTicket.get(n.ParentId).ClientUpdated__c = true;
    			updateValues = true;
    		}
    	}
    }
    
    if(updateValues){
    	update mapOfTicket.values();
    }
}


 
Not sure what I'm missing to get the error.  Any help is greatly appreciated.

Test Class
@isTest(SeeAllData=true)
private class ChatterFeedItemTest 
{
 static testMethod void TestChatterFeedInsert()
    {

    User cl = [SELECT Id From User WHERE ID = :UserInfo.getUserId()];
               
    Escalated_Ticket__c inc = new Escalated_Ticket__c();
    inc.Client__c = cl.id;
    inc.Summary__c = 'Test Subject';
    inc.Description__c = 'Test Description';
    inc.Client_Updated__c = False;
    insert inc;
        
    //Start Test
    Test.startTest();    
        
    // Create Chatter Post on test incident
    FeedItem testFeed1 = new FeedItem();
    testFeed1.ParentId = inc.Id;    
    testFeed1.Body = 'Test Feed 1 Post'; 
    testFeed1.Type = 'TextPost';
    insert testFeed1;
    
    // Create Chatter Comment on test incident
    FeedComment testFeed1Comment = new FeedComment();
    testFeed1Comment.CommentBody = 'Test Feed 1 Comment';
    testFeed1Comment.FeedItemId = testFeed1.Id;
    testFeed1Comment.CommentType='TextComment';
    insert testFeed1Comment;
            
    // Create Chatter Post on test incident
    FeedItem testFeed2 = new FeedItem();
    testFeed2.Body ='Test Feed 2 Post';
    testFeed2.ParentId = inc.Id;
    testFeed2.Type = 'TextPost';
    insert testFeed2;
            
    // Create Chatter Comment on test incident
    FeedComment testFeed2Comment = new FeedComment();
    testFeed2Comment.CommentBody ='#answer Test Feed 2 Comment';
    testFeed2Comment.FeedItemId = testFeed2.Id;
    testFeed2Comment.CommentType='TextComment';
    insert testFeed2Comment;      
        
    //Update Test Incident
	inc.Client_Updated__c = True;
    update inc;  
  
    //Stop Test
    Test.stopTest();  
   
    }
}

Trigger
 
trigger ChatterFeedItemTriggerAI on FeedItem (after insert) {

	//Collect all ParentIds into a set
    Set<Id>incIds = new Set<Id>();
    
    //List of all Escalated Tickets to be updated with the flag
    List<Escalated_Ticket__c> toUpdate = new List<Escalated_Ticket__c>();
    
    //Collect all ParentIds    
    for(FeedItem i : trigger.New){
        if(i.ParentId.getSobjectType() == Escalated_Ticket__c.SobjectType && i.Type == 'TextPost'){
        incIds.add(i.ParentId);
        }
    }
    
    //Collect all escalated ticket records with the above list of parentIds and return only those records
    Map<Id,Escalated_Ticket__c> mapofInc = new Map<Id,Escalated_Ticket__c>([select Id,Client__c,Client_Updated__c from Escalated_Ticket__c where id in:incIds]);
    Boolean updateValues = false;
    for(FeedItem i : trigger.new){
        if(mapofInc.ContainsKey(i.ParentId)){
            if(mapofInc.get(i.ParentId).Client__c == i.CreatedById){
                mapofInc.get(i.ParentId).Client_Updated__c = true;
                updateValues = true;
            }
        }
    }
    if(updateValues){
        update mapofInc.values();
    }
}


 
  • September 25, 2015
  • Like
  • 0
I created a trigger to populate a checkbox on a custom object when a note is added. Now I need to add the criteria that the creator of the note is the same as a user lookup on the custom object.  I'm not sure how to get the lookup and add to the criteria.

I need the trigger to fire only when the note creator = id from the client__c lookup field on the ticket__c object.

Any help is greatly appreciated.
 
trigger NoteAI on Note (after insert) {
    
    //Collect all ParentIds into a set
    Set<Id>incIds = new Set<Id>();
    
    //List of all Incidents to be updated with the flag
    List<EscalatedTicket__c> toUpdate = new List<EscalatedTicket__c>();
    
    //Collect all ParentIds    
    for(Note n : trigger.New){
        if(n.ParentId.getSobjectType() == EscalatedTicket__c.SobjectType){
        incIds.add(n.ParentId);
        }
    }
    
    //Collect all records with the above list of parentIds and return only those records
    List<EscalatedTicket__c> TicList = [select Id, ClientUpdated__c from EscalatedTicket__c where id in:incIds];
    if(toUpdate !=null){
        for(EscalatedTicket__c inc:TicList){
            inc.ClientUpdated__c = true;
            toUpdate.add(inc);
        }
        if(toUpdate.size()>0){
        Database.update(toUpdate,false);    
        }
    
    }

}

 
  • September 23, 2015
  • Like
  • 0
I'm trying to create a formula to calculate the average of 5 questions (1-5 values), but not include any null values.  I tried the following, but it doesn't seem to work.  If I null out all the answers and leave one with 4, it displays the average as 0.00.  

Any help is greatly appreciated.
(IF(ISNULL(Answer2__c),0,Answer2__c)+IF(ISNULL(Answer3__c),0,Answer3__c)+IF(ISNULL(Answer4__c),0,Answer4__c)+IF(ISNULL(Answer6__c),0,Answer6__c)+IF(ISNULL(Answer7__c),0,Answer7__c))
/
(IF(ISNULL(Answer2__c),0,1)+IF(ISNULL(Answer3__c),0,1)+IF(ISNULL(Answer4__c),0,1)+IF(ISNULL(Answer6__c),0,1)+IF(ISNULL(Answer7__c),0,1))

 
I'm having issues with my trigger when I'm trying to pull 2 different record types.  I should pull either the customersupport case record type or customer_service record type for the support cases.
Comparison arguement must be of compatible types (Id,RecordType)
Any help is greatly appreciated.
 
trigger ContactSupportSurveyDates on Case (before update) {

Case[] oldvalue = trigger.old;
Case[] newvalue = trigger.new;
Integer i=0;

Map<ID,RecordType> rt_Map = New Map<ID,RecordType>([Select ID, Name From RecordType Where sObjectType = 'Case']);    
for (Case c : trigger.new)
{

if (oldvalue[i].Survey_Date__c <> newvalue[i].Survey_Date__c)
   
{

Contact t = [select Id,Last_Support_Survey_Date__c,Last_Implementation_Survey_Date__c from Contact where Id =:c.ContactId limit 1];

if (c.RecordTypeId == rt_Map.get('Customer_Service') || c.RecordTypeId == rt_Map.get('CustomerSupport')) //support case id
{ 
t.Last_Support_Survey_Date__c = c.Survey_Date__c; 
update t; 
}

if (c.RecordTypeId == rt_Map.get('Pharmacy_Implementation')) // implementation case id
{
t.Last_Implementation_Survey_Date__c = c.Implementation_Survey_Date__c;
update t;

}}}}

 
I have 2 outbound messages set as a system user with full admin rights to send as.  When I perform a test in the full sandbox the outbound message is sent.  When any user that is not a full admin creates and closes the case it doesn't fire the outbound message, but it does the other action that is part of the workflow which is a field update.  

Any ideas why it's not queuing and firing off the outbound message for non-admins, but successully performs the other actions in the same workflow?

Thank you.  

 
IF(
ISPICKVAL(Status,'Not Started'),
NOW() -CreatedDate,null)
I'm trying to create a formula on the task that will calculate how long a task has been in the status of not started and keep that information when the status changes.  

Currently, my formula populates the field but nulls it out when the status is change to anything else.
I'm trying to create a formula based on combination of 2 fields.  Not sure what I'm missing.

(Class Name = Application & Application Count is not blank) = application count +1
(Class Name != Application & Application Count is not blank) = application count
(Class Name = Application & Application Count is blank) = 1
(Class Name != Application & Application Count is blank) = 0
 
IF(
AND(
Class__r.ClassName__c = 'Application',
NOT(ISBLANK(Application_Count__c)), Application_Count__c + 1)),
IF(
AND(
Class__r.ClassName__c != 'Application',
NOT(ISBLANK(Application_Count__c)), Application_Count__c)),
IF(
AND(
Class__r.ClassName__c = 'Application',
ISBLANK(Application_Count__c))),1,
IF(
AND(
Class__r.ClassName__c != 'Application',
ISBLANK(Application_Count__c),0,NULL))

 
I'm trying to write a validation rule where if a checkbox is check then certain values cannot be used.  I've tried a couple of different variations but the validation is firing when it shouldn't be.
 
#1
AND(
Project_Phase__r.Project__r.Capital_Project__c = FALSE, 
OR( 
ISPICKVAL(Accounting_Category__c,'App Dev Phase - Analysis' ) , 
ISPICKVAL(Accounting_Category__c,'App Dev Phase - Design ' ) , 
ISPICKVAL(Accounting_Category__c,'App Dev Phase - Build' ), 
ISPICKVAL(Accounting_Category__c,'App Dev Phase - Implementation' ), 
ISPICKVAL(Accounting_Category__c,'App Dev Phase - Testing' )
))


#2
AND( 
OR( 
ISPICKVAL(Accounting_Category__c,"App Dev Phase - Analysis") , 
ISPICKVAL(Accounting_Category__c,"App Dev Phase - Design") , 
ISPICKVAL(Accounting_Category__c,"App Dev Phase - Build"), 
ISPICKVAL(Accounting_Category__c,"App Dev Phase - Implementation"), 
ISPICKVAL(Accounting_Category__c,"App Dev Phase - Testing), 
OR( 
Project_Phase__r.Project__r.Capital_Project__c = FALSE )))

 
I have a workflow that updates a checkbox on an activity if the WhoId starts with 00Q (lead id) and if the checkbox is false.  It doesn't work when a task is created, but works when I edit and save.  Not sure what I'm missing

AND( 
Left(WhoId, 3) = "00Q", 
IsLead__c = False)

Any help is greatly appreciated.
I was wondering if I could get some assistance with an image formula field.  Any help is greatly appreciated.
Error: Incorrect number of parameters for function 'IMAGE()'. Expected 2, received 1

grade = D and the score is less than 50 (0 stars)
grade = D and the score is greater than 50 (1 star)
grade = C and the score is less than 50 (1 star)
grade = C and the score is greater than 50 (2 stars)
grade = B and the score is less than 50 (2 stars)
grade = B and the score is greater than 50 (3 stars)
grade = A and the score is less than 50 (3 stars)
grade = A and the score is greater than 50 (4 stars)
 
IF(AND(pi__grade__c = 'D',pi__score__c<50),IMAGE("img/samples/stars_000.gif"),

IF(AND(pi__grade__c = 'C',pi__score__c<50),IMAGE("img/samples/stars_100.gif"),
IF(AND(pi__grade__c = 'D',pi__score__c>50),IMAGE("img/samples/stars_100.gif"),

IF(AND(pi__grade__c = 'C',pi__score__c>50),IMAGE("img/samples/stars_200.gif"),
IF(AND(pi__grade__c = 'B',pi__score__c<50),IMAGE("img/samples/stars_200.gif"),

IF(AND(pi__grade__c = 'B',pi__score__c>50),IMAGE("img/samples/stars_300.gif"),
IF(AND(pi__grade__c = 'A',pi__score__c<50),IMAGE("img/samples/stars_300.gif"),


IF(AND(pi__grade__c = 'A',pi__score__c>50),IMAGE("img/samples/stars_400.gif"),"Rating"))))))))

 
I recently deployed a trigger to require rejection comments on an approval process along with the test class.  I didn't have any issues in sandbox and received 100% code coverage, but after deploying succesfully to production inbound change sets will sometimes fail and generate the trigger error.  Any help is greatly appreciated.  I'm not sure what I'm missing.
 
System.DmlException: Process failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Select the back button and provide a rejection reason comment.: [] 
Stack Trace: Class.RequireRejectionCommentTestClass.testRejectionWithComment: line 65, column 1
 
trigger RequireRejectionComment on License_Request__c (before update) {
       Map<Id, License_Request__c> rejectedRequests = new Map<Id, License_Request__c>{};
    
      for(License_Request__c lic: trigger.new)
      {

        License_Request__c oldLic = System.Trigger.oldMap.get(lic.Id);
    
        if (oldLic.Approval_Status__c != 'Rejected' 
         && lic.Approval_Status__c == 'Rejected')
        { 
          rejectedRequests.put(lic.Id, lic);  
        }
      }
       
      if (!rejectedRequests.isEmpty())  
      {

        
        List<Id> processInstanceIds = new List<Id>{};
        
        for (License_Request__c lics : [SELECT (SELECT ID
                                                  FROM ProcessInstances
                                                  ORDER BY CreatedDate DESC
                                                  LIMIT 1)
                                          FROM License_Request__c
                                          WHERE ID IN :rejectedRequests.keySet()])
        {
            processInstanceIds.add(lics.ProcessInstances[0].Id);
        }
          
        // Now that we have the most recent process instances, we can check
        // the most recent process steps for comments.  
        
        for (ProcessInstance pi : [SELECT TargetObjectId,
                                       (SELECT Id, StepStatus, Comments 
                                        FROM Steps
                                        ORDER BY CreatedDate DESC
                                        LIMIT 1 )
                                   FROM ProcessInstance
                                   WHERE Id IN :processInstanceIds
                                   ORDER BY CreatedDate DESC])   
        {                   
          if ((pi.Steps[0].Comments == null || 
               pi.Steps[0].Comments.trim().length() == 0))
          {
            rejectedRequests.get(pi.TargetObjectId).addError(
              'Select the back button and provide a rejection reason comment.');
          }
        }  
      } 

    }

 
I'm trying to create a trigger to prevent deletion of a child record if the parent record has a status of approved.  I'm not sure what I'm missing.  on the testentry.add line it is saying invalid field test__c for SObject sheet__c
trigger PreventEntryDeletion on Test__c (before delete) {

Set<ID> testentry = New Set<ID>();
    
    List<sheet__c> l = [Select Id From sheet__c Where status = 'Approved' and Id IN :trigger.oldMap.KeySet()];
    for(sheet__c objp : l)
    {
        testentry.add(objp.test__c);
    }
   
    For(test__c obja : trigger.old){
        
        If(testentry.contains(obja.ID))
            obja.addError('You cannot delete a test entry on an approved sheet.');
    }
        
    }

  • September 08, 2014
  • Like
  • 0
I'm having problems getting any coverage to my test class.  I'm not sure what I'm missing.  Any help is greatly appreciated.

Controller
public class ExecFinController {

  public ExecFinController(ApexPages.StandardController controller) {

    }
	public Flow.Interview.BI_Executive_Finance_Flow myFlow { get; set; }
    
	public PageReference getOID() { 
        
  	Schema.DescribeSObjectResult result = BI_Executive_Financial_Dashboard__c.SObjectType.getDescribe(); 
        
  	PageReference pageRef = new PageReference('/' + result.getKeyPrefix() + '/o'); 
  	pageRef.setRedirect(true); 
        
  	return pageRef; 
}
}
Visualforce Page
 
<apex:page StandardController="BI_Executive_Financial_Dashboard__c" extensions="ExecFinController" TabStyle="BI_Executive_Financial_Dashboard__c">
    <flow:interview name="BI_Executive_Finance_Flow" finishLocation="{!OID}"/>
</apex:page>

Test Class
@isTest(SeeAllData=true)
private class BIExecFinControllerTest 
{

    public static testmethod void ExecFin()
    {
        
        Date currentDate = date.today();
   
                      
      BI_Executive_Financial_Dashboard__c exec = new BI_Executive_Financial_Dashboard__c();
        exec.Period__c = 'Monthly';
        exec.Amount_for_Period__c = 100;
        exec.Period_Begins_On__c = currentDate;
        exec.Business_Unit_Text__c = 'Test Unit';
        exec.Period_Metric__c = 'Test';
        insert exec; 
        
        Test.startTest();
        
        List<BI_Executive_Financial_Dashboard__c> fin = new List<BI_Executive_Financial_Dashboard__c>();
                
        ApexPages.Standardcontroller stdexec = new ApexPages.Standardcontroller(exec);
        ExecFinController controller = new ExecFinController(stdexec);
        
        PageReference FlowPageRef = Page.BI_Financial_Dashboard;
    	Test.setCurrentPage(FlowPageRef);
        
        Test.stopTest();
     
     
    }
    
}


 
I am trying to create a custom button that will start a visual flow and finish at the list view of that object.  
The VF page does not show as an option to overwrite the new button.  I'm pretty sure this is because I am not using a standard controller.

Any help is greatly appreciated.

Visualforce Page
<apex:page Controller="ExecFinController" TabStyle="BI_Executive_Financial_Dashboard__c">
    <flow:interview name="BI_Executive_Finance_Flow" finishLocation="{!OID}"/>
</apex:page>

Controller
public class ExecFinController {

public Flow.Interview.BI_Executive_Finance_Flow myFlow { get; set; }

public PageReference getOID() { 
  Schema.DescribeSObjectResult result = BI_Executive_Financial_Dashboard__c.SObjectType.getDescribe(); 
  PageReference pageRef = new PageReference('/' + result.getKeyPrefix() + '/o'); 
  pageRef.setRedirect(true); 
  return pageRef; 
}

}

 
Criteria: User should not be able to change the stage of an oppty to anything but unqualified except if these conditions are true.

Division does not contain sales or finance
lead score > 0
type = renewal
total = 0.00

I have it working, but now I need to add the following to not include in the validation:
If the division contains sales and total  <= 10000

I'm not sure how to add that portion, since the current is looking for not contains 'Sales'
AND( 
NOT(ISPICKVAL(StageName,"Unqualified")), 
ISCHANGED(StageName), 
NOT( 
OR( 
CONTAINS(Division__c,"Sales"), 
CONTAINS(Division__c,"Finance"), 
Score__c > 0, 
ISPICKVAL(Type__c,"Renewal"), 
Total__c = 0.00)))

 
I need to update my trigger to not fire if the Staff__c lookup field on the escalated ticket is not null.  I wasn't sure where to include 
Staff__c != null

I tried at this line but it didn't work.
if(mapOfTicket.get(n.ParentId).client__c == n.OwnerId){

 
trigger NoteAI on Note (after insert) {
    
    //Collect all ParentIds into a set
    Set<Id>incIds = new Set<Id>();
    
    for(Note n : trigger.New){
        if(n.ParentId.getSobjectType() == EscalatedTicket__c.SobjectType){
        	incIds.add(n.ParentId);
        }
    }
    
    Map<Id,EscalatedTicket__c> mapOfTicket = new Map<Id,EscalatedTicket__c>([select Id,client__c , ClientUpdated__c from EscalatedTicket__c where id in:incIds]);
    Boolean updateValues = false;
    for(Note n : trigger.new){
    	if(mapOfTicket.ContainsKey(n.ParentId)){
    		if(mapOfTicket.get(n.ParentId).client__c == n.OwnerId){
    			mapOfTicket.get(n.ParentId).ClientUpdated__c = true;
    			updateValues = true;
    		}
    	}
    }
    
    if(updateValues){
    	update mapOfTicket.values();
    }
}


 
I created a trigger to populate a checkbox on a custom object when a note is added. Now I need to add the criteria that the creator of the note is the same as a user lookup on the custom object.  I'm not sure how to get the lookup and add to the criteria.

I need the trigger to fire only when the note creator = id from the client__c lookup field on the ticket__c object.

Any help is greatly appreciated.
 
trigger NoteAI on Note (after insert) {
    
    //Collect all ParentIds into a set
    Set<Id>incIds = new Set<Id>();
    
    //List of all Incidents to be updated with the flag
    List<EscalatedTicket__c> toUpdate = new List<EscalatedTicket__c>();
    
    //Collect all ParentIds    
    for(Note n : trigger.New){
        if(n.ParentId.getSobjectType() == EscalatedTicket__c.SobjectType){
        incIds.add(n.ParentId);
        }
    }
    
    //Collect all records with the above list of parentIds and return only those records
    List<EscalatedTicket__c> TicList = [select Id, ClientUpdated__c from EscalatedTicket__c where id in:incIds];
    if(toUpdate !=null){
        for(EscalatedTicket__c inc:TicList){
            inc.ClientUpdated__c = true;
            toUpdate.add(inc);
        }
        if(toUpdate.size()>0){
        Database.update(toUpdate,false);    
        }
    
    }

}

 
  • September 23, 2015
  • Like
  • 0
I'm trying to create a formula to calculate the average of 5 questions (1-5 values), but not include any null values.  I tried the following, but it doesn't seem to work.  If I null out all the answers and leave one with 4, it displays the average as 0.00.  

Any help is greatly appreciated.
(IF(ISNULL(Answer2__c),0,Answer2__c)+IF(ISNULL(Answer3__c),0,Answer3__c)+IF(ISNULL(Answer4__c),0,Answer4__c)+IF(ISNULL(Answer6__c),0,Answer6__c)+IF(ISNULL(Answer7__c),0,Answer7__c))
/
(IF(ISNULL(Answer2__c),0,1)+IF(ISNULL(Answer3__c),0,1)+IF(ISNULL(Answer4__c),0,1)+IF(ISNULL(Answer6__c),0,1)+IF(ISNULL(Answer7__c),0,1))

 
I'm having issues with my trigger when I'm trying to pull 2 different record types.  I should pull either the customersupport case record type or customer_service record type for the support cases.
Comparison arguement must be of compatible types (Id,RecordType)
Any help is greatly appreciated.
 
trigger ContactSupportSurveyDates on Case (before update) {

Case[] oldvalue = trigger.old;
Case[] newvalue = trigger.new;
Integer i=0;

Map<ID,RecordType> rt_Map = New Map<ID,RecordType>([Select ID, Name From RecordType Where sObjectType = 'Case']);    
for (Case c : trigger.new)
{

if (oldvalue[i].Survey_Date__c <> newvalue[i].Survey_Date__c)
   
{

Contact t = [select Id,Last_Support_Survey_Date__c,Last_Implementation_Survey_Date__c from Contact where Id =:c.ContactId limit 1];

if (c.RecordTypeId == rt_Map.get('Customer_Service') || c.RecordTypeId == rt_Map.get('CustomerSupport')) //support case id
{ 
t.Last_Support_Survey_Date__c = c.Survey_Date__c; 
update t; 
}

if (c.RecordTypeId == rt_Map.get('Pharmacy_Implementation')) // implementation case id
{
t.Last_Implementation_Survey_Date__c = c.Implementation_Survey_Date__c;
update t;

}}}}

 
I have 2 outbound messages set as a system user with full admin rights to send as.  When I perform a test in the full sandbox the outbound message is sent.  When any user that is not a full admin creates and closes the case it doesn't fire the outbound message, but it does the other action that is part of the workflow which is a field update.  

Any ideas why it's not queuing and firing off the outbound message for non-admins, but successully performs the other actions in the same workflow?

Thank you.  

 
I'm trying to create a formula based on combination of 2 fields.  Not sure what I'm missing.

(Class Name = Application & Application Count is not blank) = application count +1
(Class Name != Application & Application Count is not blank) = application count
(Class Name = Application & Application Count is blank) = 1
(Class Name != Application & Application Count is blank) = 0
 
IF(
AND(
Class__r.ClassName__c = 'Application',
NOT(ISBLANK(Application_Count__c)), Application_Count__c + 1)),
IF(
AND(
Class__r.ClassName__c != 'Application',
NOT(ISBLANK(Application_Count__c)), Application_Count__c)),
IF(
AND(
Class__r.ClassName__c = 'Application',
ISBLANK(Application_Count__c))),1,
IF(
AND(
Class__r.ClassName__c != 'Application',
ISBLANK(Application_Count__c),0,NULL))

 
I'm trying to write a validation rule where if a checkbox is check then certain values cannot be used.  I've tried a couple of different variations but the validation is firing when it shouldn't be.
 
#1
AND(
Project_Phase__r.Project__r.Capital_Project__c = FALSE, 
OR( 
ISPICKVAL(Accounting_Category__c,'App Dev Phase - Analysis' ) , 
ISPICKVAL(Accounting_Category__c,'App Dev Phase - Design ' ) , 
ISPICKVAL(Accounting_Category__c,'App Dev Phase - Build' ), 
ISPICKVAL(Accounting_Category__c,'App Dev Phase - Implementation' ), 
ISPICKVAL(Accounting_Category__c,'App Dev Phase - Testing' )
))


#2
AND( 
OR( 
ISPICKVAL(Accounting_Category__c,"App Dev Phase - Analysis") , 
ISPICKVAL(Accounting_Category__c,"App Dev Phase - Design") , 
ISPICKVAL(Accounting_Category__c,"App Dev Phase - Build"), 
ISPICKVAL(Accounting_Category__c,"App Dev Phase - Implementation"), 
ISPICKVAL(Accounting_Category__c,"App Dev Phase - Testing), 
OR( 
Project_Phase__r.Project__r.Capital_Project__c = FALSE )))

 
I have a workflow that updates a checkbox on an activity if the WhoId starts with 00Q (lead id) and if the checkbox is false.  It doesn't work when a task is created, but works when I edit and save.  Not sure what I'm missing

AND( 
Left(WhoId, 3) = "00Q", 
IsLead__c = False)

Any help is greatly appreciated.
I was wondering if I could get some assistance with an image formula field.  Any help is greatly appreciated.
Error: Incorrect number of parameters for function 'IMAGE()'. Expected 2, received 1

grade = D and the score is less than 50 (0 stars)
grade = D and the score is greater than 50 (1 star)
grade = C and the score is less than 50 (1 star)
grade = C and the score is greater than 50 (2 stars)
grade = B and the score is less than 50 (2 stars)
grade = B and the score is greater than 50 (3 stars)
grade = A and the score is less than 50 (3 stars)
grade = A and the score is greater than 50 (4 stars)
 
IF(AND(pi__grade__c = 'D',pi__score__c<50),IMAGE("img/samples/stars_000.gif"),

IF(AND(pi__grade__c = 'C',pi__score__c<50),IMAGE("img/samples/stars_100.gif"),
IF(AND(pi__grade__c = 'D',pi__score__c>50),IMAGE("img/samples/stars_100.gif"),

IF(AND(pi__grade__c = 'C',pi__score__c>50),IMAGE("img/samples/stars_200.gif"),
IF(AND(pi__grade__c = 'B',pi__score__c<50),IMAGE("img/samples/stars_200.gif"),

IF(AND(pi__grade__c = 'B',pi__score__c>50),IMAGE("img/samples/stars_300.gif"),
IF(AND(pi__grade__c = 'A',pi__score__c<50),IMAGE("img/samples/stars_300.gif"),


IF(AND(pi__grade__c = 'A',pi__score__c>50),IMAGE("img/samples/stars_400.gif"),"Rating"))))))))

 
I recently deployed a trigger to require rejection comments on an approval process along with the test class.  I didn't have any issues in sandbox and received 100% code coverage, but after deploying succesfully to production inbound change sets will sometimes fail and generate the trigger error.  Any help is greatly appreciated.  I'm not sure what I'm missing.
 
System.DmlException: Process failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Select the back button and provide a rejection reason comment.: [] 
Stack Trace: Class.RequireRejectionCommentTestClass.testRejectionWithComment: line 65, column 1
 
trigger RequireRejectionComment on License_Request__c (before update) {
       Map<Id, License_Request__c> rejectedRequests = new Map<Id, License_Request__c>{};
    
      for(License_Request__c lic: trigger.new)
      {

        License_Request__c oldLic = System.Trigger.oldMap.get(lic.Id);
    
        if (oldLic.Approval_Status__c != 'Rejected' 
         && lic.Approval_Status__c == 'Rejected')
        { 
          rejectedRequests.put(lic.Id, lic);  
        }
      }
       
      if (!rejectedRequests.isEmpty())  
      {

        
        List<Id> processInstanceIds = new List<Id>{};
        
        for (License_Request__c lics : [SELECT (SELECT ID
                                                  FROM ProcessInstances
                                                  ORDER BY CreatedDate DESC
                                                  LIMIT 1)
                                          FROM License_Request__c
                                          WHERE ID IN :rejectedRequests.keySet()])
        {
            processInstanceIds.add(lics.ProcessInstances[0].Id);
        }
          
        // Now that we have the most recent process instances, we can check
        // the most recent process steps for comments.  
        
        for (ProcessInstance pi : [SELECT TargetObjectId,
                                       (SELECT Id, StepStatus, Comments 
                                        FROM Steps
                                        ORDER BY CreatedDate DESC
                                        LIMIT 1 )
                                   FROM ProcessInstance
                                   WHERE Id IN :processInstanceIds
                                   ORDER BY CreatedDate DESC])   
        {                   
          if ((pi.Steps[0].Comments == null || 
               pi.Steps[0].Comments.trim().length() == 0))
          {
            rejectedRequests.get(pi.TargetObjectId).addError(
              'Select the back button and provide a rejection reason comment.');
          }
        }  
      } 

    }

 
I'm trying to create a trigger to prevent deletion of a child record if the parent record has a status of approved.  I'm not sure what I'm missing.  on the testentry.add line it is saying invalid field test__c for SObject sheet__c
trigger PreventEntryDeletion on Test__c (before delete) {

Set<ID> testentry = New Set<ID>();
    
    List<sheet__c> l = [Select Id From sheet__c Where status = 'Approved' and Id IN :trigger.oldMap.KeySet()];
    for(sheet__c objp : l)
    {
        testentry.add(objp.test__c);
    }
   
    For(test__c obja : trigger.old){
        
        If(testentry.contains(obja.ID))
            obja.addError('You cannot delete a test entry on an approved sheet.');
    }
        
    }

  • September 08, 2014
  • Like
  • 0