• Abhishek Ray
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 27
    Questions
  • 27
    Replies

Hi Everyone,

 

I need to pull the field in Opportunity Contact Role called "IsPrimary" which either True or False as an API in salesforce. How I can achieve? I will take the value of this field  "IsPrimary" and put into another custom field. Will that be possible? I was thinking to create a trigger? Please help me.

 

Thanks

Abhishek

Hi,

 

Let’s say we started using SFDC for our case management. We do have articles and solutions both working here. But for the articles, any article > 30 days is not showing up on the support portal. I don't know how to enable that.

 

I also wanted your opinion on the pros and cons of using articles vs. solutions and which one is better.


Thanks
Abhishek

 

Hi,

 

I need to pull stage duration API name. I can see this field in report. But why can't pull the API from opportunity? Why it is invisible? Please any solutions?

 

Thanks

Abhi

Hi All,

 

Just a quick question. If I set a history tracker for one of the field now, will the history of that field prior the date I enabled showup in the history?

 

Thanks

Abhishek

This is apex trigger. I had error as I reached governor's limit. Somebody told me to get query outside for loop. How to do that? PLease help      

 

  membersToAdd.put(c.Id, new CaseTeamMember(ParentId = c.Id, MemberId = UserInfo.getUserId()));     

    }  

    if (!membersToAdd.isEmpty()) {

      try {

         for (CaseTeamMember ctm : membersToAdd.values()) {

          ctm.TeamRoleId = caseTeamRole.Id;

        }

    

       for (CaseTeamMember ctm : [SELECT Id, MemberId, ParentId

                       FROM CaseTeamMember

                       WHERE ParentId IN :membersToAdd.keySet()

                       AND MemberId = :UserInfo.getUserId()

                       ORDER BY ParentId])

 

                     

{

                   

          if (membersToAdd.containsKey(ctm.ParentId)) {

            membersToAdd.remove(ctm.ParentId);

          }

        }

      

        if (!membersToAdd.isEmpty()) {

          insert membersToAdd.values();

        }

      } catch (System.QueryException qe) {}

Hello,

 

I try to deploy a trigger and its test class in production but I have this error :

Failure Message: "System.LimitException: Too many SOQL queries: 101", Failure Stack Trace: "Trigger.CaseTeamTrigger: line 14, column 1"  ...

 

The code coverage of this trigger is 100%.

 

I think this is due to another test class for another trigger but the both (the 2 triggers and the 2 test classes) are on the same object (Case).

The other trigger is already deployed.

 

How can I solve this problem ?

 

Thank you.

 

Here is my code:

 

trigger CaseTeamTrigger on Case (after insert, after update) {

    Map<Id, CaseTeamMember> membersToAdd = new Map<Id, CaseTeamMember>();

    List<Case> cases = [Select Id,OwnerId,RecordTypeId,RecordType.Name

                  from Case where id IN :Trigger.newMap.keySet()];

                 

      for (Case c : cases)

    {

      if(c.RecordType.Name =='Legal' || c.RecordType.Name =='Security/Quality Request'){     

 

        membersToAdd.put(c.Id, new CaseTeamMember(ParentId = c.Id, MemberId = UserInfo.getUserId()));      

    }   

    if (!membersToAdd.isEmpty()) {

      try {

        CaseTeamRole caseTeamRole = [SELECT Id FROM CaseTeamRole WHERE Name = 'Creator' LIMIT 100];

        for (CaseTeamMember ctm : membersToAdd.values()) {

          ctm.TeamRoleId = caseTeamRole.Id;

        }

     

        for (CaseTeamMember ctm : [SELECT Id, MemberId, ParentId

                       FROM CaseTeamMember

                       WHERE ParentId IN :membersToAdd.keySet()

                       AND MemberId = :UserInfo.getUserId()

                       ORDER BY ParentId])

 

                      

 {

                    

          if (membersToAdd.containsKey(ctm.ParentId)) {

            membersToAdd.remove(ctm.ParentId);

          }

        }

       

        if (!membersToAdd.isEmpty()) {

          insert membersToAdd.values();

        }

      } catch (System.QueryException qe) {}

    }

  }

}

 

 

Trigger:  I have to create a workaround which salesforce recommended me to use trigger. I need to create a visiblity to case. User A creates a ticket and the owner of ticket is assigned. The ticket is visible to owner and his/her group through case sharing rules. But the case is not visible to the actual person who created the ticket and the contact owner. The scenerio is I don't want anybody to view this ticket except Owner, the owner group and the creator. I tried using sharing setting but in that scenrio either all users are able to see or none of the users cannot see except owner and their group. Salesforce recommended me to use this sample trigger. Since I dont have much idea in trigger, this code is not working. Please help.

 

trigger CaseTeamTrigger on Case (after insert, after update) {

    Map<Id, CaseTeamMember> membersToAdd = new Map<Id, CaseTeamMember>();

    List<Case> cases = [Select Id,OwnerId,RecordTypeId,RecordType.Name

                  from Case where id IN :Trigger.newMap.keySet()];

                 

      for (Case c : cases)

    {

        membersToAdd.put(c.Id, new CaseTeamMember(ParentId = c.Id, MemberId = UserInfo.getUserId()));      

    }   

    if (!membersToAdd.isEmpty()) {

      try {

        CaseTeamRole caseTeamRole = [SELECT Id FROM CaseTeamRole WHERE Name = 'Creator' LIMIT 1];

        for (CaseTeamMember ctm : membersToAdd.values()) {

          ctm.TeamRoleId = caseTeamRole.Id;

        }

     

        for (CaseTeamMember ctm : [SELECT Id, MemberId, ParentId

                       FROM CaseTeamMember

                       WHERE ParentId IN :membersToAdd.keySet()

                       AND MemberId = :UserInfo.getUserId()

                       ORDER BY ParentId])

 {

                    

          if (membersToAdd.containsKey(ctm.ParentId)) {

            membersToAdd.remove(ctm.ParentId);

          }

        }

       

        if (!membersToAdd.isEmpty()) {

          insert membersToAdd.values();

        }

      } catch (System.QueryException qe) {}

    }

 

}

 

 

Please help.

Hi,

 

I have a case ticketing system in place. When a user creates a case using ticket system in salesforce I have  an assignment rule that assigns the case to a user in a group -  Group A.  But once the ownership of the case changes from that person based on the rule, the case cannot be reviewed by the user who created the case and the following message is displayed. "Insufficient Privileges. Although the contact name of the ticket exist in the name of the person who created the ticket.  

 

How can i overwrite it to make cases created by the user visible even the ownership of case has been changed to a some other user ??

 

Thanks!

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 need help in case management,
 

 

We need to implement security around tickets. Basically the following will happen:

 

We have 2 record type Legal and Security and 2 groups same as record type. So the condition is

 

1. The group Legal will share tickets with Legal

 

2. The group Security will share ticket with Security

 

3. Because the users who are creating these tickets will not be a part of either of these groups, we need to figure out a way that the end user will always maintain visibility to their tickets.

 

 

Please let me know how I can achieve it?

 

Hi, I need help. I have a picklist field in Opptunity object called 'Template" = Connect. So, whenever a user selects this picklist, a section called ="Proposal for Connect" will be visible other it will be hidden. How I can achieve it. Please help. I started with something but I am not going anywhere with it. Please help.

 

<apex:page standard controller="Opportunity" > <script> function doChange({!Opportunity.Template__c})

{     if({!Opportunity.Template__c} == 'Connect')

    {         document.getElementById('chk').style.visibility='Proposal Language for Intralinks Connect';     }     else     {         document.getElementById('chk').style.visibility="hidden"​';     }

}

</script>

       <apex:selectList value="#F3F3EC"  onchange="displaydiv(this.value)" size="1">

            <apex:selectOption itemValue="value1" itemLabel="value 1"/>

            <apex:selectOption itemValue="value2" itemLabel="value 2"/>

            <apex:selectOption itemValue="value3" itemLabel="value 3"/>

        </apex:selectList>

    </apex:form>

    <div id="chk" style="display:none;">

    hello

    </div>

</apex:page>

 

Hi All, Need help.

 

I have a picklist field.  I need to change the picklist values and rename into new one. Thats easy. You can do that with the replace functionality in the field itself.

 

But Now I need to rename the field itself. Is is psossible to do?  What are the effects:

 

a. this field has 1-2 dependency. Also the value of these field is used ina formula. (Again formula can be changed easily).

 

Please explain me the downstream effects.

Please help. Trigger I am getting only of 36%. Please help.

 

trigger BusinessSegment on Opportunity (before insert) {

    for(Opportunity op: Trigger.new){

        if(op.Solution_Offering__c=='Audit/Compliance'&& (op.Business_Application__c=='Audit Management' ||op.Business_Application__c=='Financial Audit Management'||op.Business_Application__c=='Regulato​ry Audit Management') ){

            op.Use_Type_Class__c='Audit/Compliance' ;

            op.Use_Type__c='Financial Audit';

            op.Solution__c='IL Exchange' ;             

        }

    }

  

{

for(Opportunity opp: Trigger.new){

        if(opp.Solution_Offering__c=='Audit/Compliance'&& opp.Business_Application__c=='Compliance Management' ){

            opp.Use_Type_Class__c='Audit/Compliance' ;

            opp.Use_Type__c='Other Audit/Compliance';

            opp.Solution__c='Compliance Link';

          

        }  

}

}

 

{

for(Opportunity opp1: Trigger.new){

        if(opp1.Solution_Offering__c=='Fund Management'&&

        (opp1.Business_Application__c=='Investor Reporting'

         || opp1.Business_Application__c=='Portfolio Company Reporting'

           || opp1.Business_Application__c=='AI Fundraising'  )){

            opp1.Use_Type_Class__c='Financing/Capital Financing' ;

            opp1.Use_Type__c='AI Fundraising';

            opp1.Solution__c='IL Exchange';

          

        }  

}

}

 

{

for(Opportunity opp2: Trigger.new){

        if(opp2.Business_Application__c=='None' ){

            opp2.Use_Type_Class__c='General' ;

            opp2.Use_Type__c='Other (Specify in Description box)';

            opp2.Solution__c='IL Exchange';

          

        }  

}

}

 

{

for(Opportunity opp3: Trigger.new){

        if(opp3.Solution_Offering__c=='Corporate Services'&&

        (opp3.Business_Application__c=='Contract Management'

        || opp3.Business_Application__c=='Vendor Management'

         || opp3.Business_Application__c=='Investor Reporting'

          || opp3.Business_Application__c=='Regulatory Reporting') ){

            opp3.Use_Type_Class__c='General' ;

            opp3.Use_Type__c='Contract Management';

            opp3.Solution__c='IL Exchange';

          

        }  

}

}

 

{

for(Opportunity opp4: Trigger.new){

        if(opp4.Solution_Offering__c=='Strategic Transactions'&&

        (opp4.Business_Application__c=='Financing/Capital Raising'

        || opp4.Business_Application__c=='IPO'

         || opp4.Business_Application__c=='JV/Alliance Management'

          || opp4.Business_Application__c=='Acquisition Mgmt (Buy-side)'

           || opp4.Business_Application__c=='Bankruptcy/Restruct​uring'  ) ){

            opp4.Use_Type_Class__c='Financing/Capital Financing' ;

            opp4.Use_Type__c='IPO';

            opp4.Solution__c='IL Exchange';

 

          

        }  

}

}

 

{

for(Opportunity opp5: Trigger.new){

        if(opp5.Solution_Offering__c=='Strategic Transactions'&& opp5.Business_Application__c=='Licensing' ){

            opp5.Use_Type_Class__c='Licensing & Strategic Alliances' ;

            opp5.Use_Type__c='Licensing';

            opp5.Solution__c='Compliance Link';

          

        }  

}

}

 

 

}

 

 

Apex Class:

@isTest

private class testMyBusinessSegment {

Public static testMethod void testTBusinessSegment ()

{

 

Opportunity opp = new Opportunity();

 

opp.name = 'Test - New Mapping';

opp.Type = 'Transaction - New';

opp.Region__c = 'Americas';

opp.Template__c='Blocks';

opp.StageName = 'Propose';

opp.dlDealType__c = 'Micro Deal';

opp.Solution_Offering__c= 'Audit/Compliance';

opp.Business_Application__c= 'Audit Management';

 

insert opp;

 

}

{

 

Opportunity oppp = new Opportunity();

 

oppp.name = 'Test - Trigger 1';

oppp.Type = 'Transaction - New';

oppp.Region__c = 'Americas';

oppp.Template__c='Blocks';

oppp.StageName = 'Propose';

oppp.dlDealType__c = 'Small Deal';

oppp.Solution_Offering__c= 'Audit/Compliance';

oppp.Business_Application__c= 'Compliance Management';

 

 

 

insert oppp;

}

 

{

 

Opportunity oppp1 = new Opportunity();

 

oppp1.name = 'Test - Trigger 21';

oppp1.Type = 'Transaction - New';

oppp1.Region__c = 'Americas';

oppp1.Template__c='Blocks';

oppp1.StageName = 'Propose';

oppp1.dlDealType__c = 'Small Deal';

oppp1.Solution_Offering__c= 'Fund Management';

oppp1.Business_Application__c= 'AI Fundraising';

 

 

 

insert oppp1;

}

 

 

}

Here is my code where I am updating one picklist field to another picklist field but I am only achieving 50% code coverage. Please help.

 

Apex trigger:

 

trigger BusinessSegment on Opportunity (before insert) {  

   for(Opportunity op: Trigger.new){      

   if(op.Solution_Offering__c=='Debt Financing'||op.Business_Application__c=='Equipment Finance' ){       

      op.Use_Type_Class__c='Financing/Capital Raising';             

  op.Use_Type__c='Equipment Finance';      

   }     } } 

 

Apex class:

 

@isTest private class testMyBusinessSegment { Public static testMethod void testTBusinessSegment () {
Opportunity opp = new Opportunity();
opp.name = 'Test - New Mapping';

opp.Type = 'Transaction - New';

opp.Region__c = 'Americas';

opp.Template__c='Blocks';

opp.StageName = 'Propose';

opp.dlDealType__c = 'Micro Deal';
insert opp;
} }

HI, I want to create a trigger to update a picklist field from another picklist field in same object. I am new to trigger. Please help me with a sample code.

 

Thanks

Abhishek

 

 

Hi, Need help in trigger.

 

Whenver a ticket is created through email to case, the ticket is created in the name of my company's administrator and contact name and email shows up as her instead of who actually create the ticket. Although the actual contact who emailed for that ticket exist in our salesforce account.

 

How I can create a trigger to assign the contact name and email for that particular person who created the ticket through email to case instead of my company's administrator? Please help.

Here is the batch apex I wrote to populate owner name for Task into a field. I am not sure how to write a batch apex for this code:

 

 global class updateTask implements Database.Batchable <SObject>

{

global final String Query; String email;

global updateTask(String q) {

Query=q; }   

global Database.QueryLocator start(Database.BatchableContext BC)  {   

  return Database.getQueryLocator(query);   

  }   

global void execute(Database.BatchableContext BC, List<Task> scope)

 {   

List<Task> myTask = new list<Task>();

     for (Task s : scope)         

  {                         

 Task a = (Task)s;                

  for(Integer i = 0; i < 200; i++)                                              

  {                                        a.Current_Owner__c= [select name from User where ID = : a.OwnerId limit 1].name;                                              }                         myTask.add(s);                            

} update myTask; }   

 

 global void finish(Database.BatchableContext BC) { Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

mail.setToAddresses(new String[] {email}); mail.setReplyTo('aray@intralinks.com'); mail.setSenderDisplayName('Batch Processing'); mail.setSubject('Batch Process Completed'); mail.setPlainTextBody('Batch Process has completed');

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

}

 

Please help......

 

 

Hi All,

 

I am creating a trigger to pull the owner name instead of id to a new field called "Current Owner" in the activity object in Task. I created a trigger but it is showing me id again. Please help me. Is there any way other to achieve it. What I am doing wrong. Please help with code and test class as I am new to trigger. Any help will be appreciated.

 

The problem here is I can't write in code: o.Current_Owner__c = o.Owner which is owner name but is is not allowing me save and giving some error.

 

Trigger:

trigger CurrentOwner on Task (before insert, before update) {

for(Task o:Trigger.new)

{o.Current_Owner__c = o.OwnerId;

}

}

 

Test Class:

public class CurrentOwner {

Public static void addCurrentOwner(Task[] acts) {

for(Task a:acts)

 {String Name = [Select id from User where ID = :a.ownerID].Name;a.Current_Owner__c = Name;

}}}

Hi,

 

I have created a trigger tfor custom object to auto populate the owner name (lookup) in another field under same object,

 

Here is the code:

 

trigger setOwnerName on Partnership__c (before insert) {
Map<Id,String> userMap = new Map<Id, String>();     
for (User u : [Select Id, Name From User]) 
{        
userMap.put(u.Id, u.Name);  
}   
for (Partnership__c a : Trigger.New)
 {     
 if(a.Account__c == 'AAA Drawloop Testing')
 {
 a.Owner_Name__c = userMap.get(a.OwnerId);   
}
}

 

 

I created a test trigger but I am getting error : System.StringException: Invalid id: AAA Drawloop Testing

 

private class setOwnerNameTest{
    public static TestMethod void OwnerNameinsert(){
           Partnership__c acc = new Partnership__c();
           acc.Account__c = 'AAA Drawloop Testing';
           insert acc;
           test.startTest();
           Partnership__c accNew = new Partnership__c(); 
           accNew.Account__c = 'AAA Drawloop Testing';
           insert accNew; 
           system.assert(accNew.id == null); 
        test.stopTest();
    }
}

 

What I am doing wrong. Please help?

Hi,

 

I have a problem in approval process. The problem, I have a approval process which works like this (1)SM->(2)VP->(3)SVP->(4)SO (These r the hierarchy). Now this is a regular process. But sometimes it happens that SVP become SM for some user i.e. Suppose A= Sales Rep (who creates opportunity), B = SM, C = VP , D = SVP E=SO, so it follows noraml process but sometimes B creates the opportunity, now B = Sales Rep, C=SM, D = VP, so I created a bypass rule when SVP becomes VP in approval process, it can bypass SVP level becaz actually SVP is now approving in VP.

 

OK now I have created this bypass rule based on workflow field update on Createdby. Approver, Createdby.Approver's Approver and so on for different level. Now I have another field Oppo Owner which is changeble field. So one is actually creator pf oppor but the the Oppor Owner can be different. Here where the approval process bypass rule messed up. Now when Oppor Owner is changed, my bypass rule doesn't give an option to select the formula based on Oppor Owner Approver i.e OpptyOwner. Approver instead of Createdby.Approver. Any solution for this problem? The oppty owner is a lookup field.

 

Thanks

Hi,

 

I need to pull stage duration API name. I can see this field in report. But why can't pull the API from opportunity? Why it is invisible? Please any solutions?

 

Thanks

Abhi

This is apex trigger. I had error as I reached governor's limit. Somebody told me to get query outside for loop. How to do that? PLease help      

 

  membersToAdd.put(c.Id, new CaseTeamMember(ParentId = c.Id, MemberId = UserInfo.getUserId()));     

    }  

    if (!membersToAdd.isEmpty()) {

      try {

         for (CaseTeamMember ctm : membersToAdd.values()) {

          ctm.TeamRoleId = caseTeamRole.Id;

        }

    

       for (CaseTeamMember ctm : [SELECT Id, MemberId, ParentId

                       FROM CaseTeamMember

                       WHERE ParentId IN :membersToAdd.keySet()

                       AND MemberId = :UserInfo.getUserId()

                       ORDER BY ParentId])

 

                     

{

                   

          if (membersToAdd.containsKey(ctm.ParentId)) {

            membersToAdd.remove(ctm.ParentId);

          }

        }

      

        if (!membersToAdd.isEmpty()) {

          insert membersToAdd.values();

        }

      } catch (System.QueryException qe) {}

Hello,

 

I try to deploy a trigger and its test class in production but I have this error :

Failure Message: "System.LimitException: Too many SOQL queries: 101", Failure Stack Trace: "Trigger.CaseTeamTrigger: line 14, column 1"  ...

 

The code coverage of this trigger is 100%.

 

I think this is due to another test class for another trigger but the both (the 2 triggers and the 2 test classes) are on the same object (Case).

The other trigger is already deployed.

 

How can I solve this problem ?

 

Thank you.

 

Here is my code:

 

trigger CaseTeamTrigger on Case (after insert, after update) {

    Map<Id, CaseTeamMember> membersToAdd = new Map<Id, CaseTeamMember>();

    List<Case> cases = [Select Id,OwnerId,RecordTypeId,RecordType.Name

                  from Case where id IN :Trigger.newMap.keySet()];

                 

      for (Case c : cases)

    {

      if(c.RecordType.Name =='Legal' || c.RecordType.Name =='Security/Quality Request'){     

 

        membersToAdd.put(c.Id, new CaseTeamMember(ParentId = c.Id, MemberId = UserInfo.getUserId()));      

    }   

    if (!membersToAdd.isEmpty()) {

      try {

        CaseTeamRole caseTeamRole = [SELECT Id FROM CaseTeamRole WHERE Name = 'Creator' LIMIT 100];

        for (CaseTeamMember ctm : membersToAdd.values()) {

          ctm.TeamRoleId = caseTeamRole.Id;

        }

     

        for (CaseTeamMember ctm : [SELECT Id, MemberId, ParentId

                       FROM CaseTeamMember

                       WHERE ParentId IN :membersToAdd.keySet()

                       AND MemberId = :UserInfo.getUserId()

                       ORDER BY ParentId])

 

                      

 {

                    

          if (membersToAdd.containsKey(ctm.ParentId)) {

            membersToAdd.remove(ctm.ParentId);

          }

        }

       

        if (!membersToAdd.isEmpty()) {

          insert membersToAdd.values();

        }

      } catch (System.QueryException qe) {}

    }

  }

}

 

 

Trigger:  I have to create a workaround which salesforce recommended me to use trigger. I need to create a visiblity to case. User A creates a ticket and the owner of ticket is assigned. The ticket is visible to owner and his/her group through case sharing rules. But the case is not visible to the actual person who created the ticket and the contact owner. The scenerio is I don't want anybody to view this ticket except Owner, the owner group and the creator. I tried using sharing setting but in that scenrio either all users are able to see or none of the users cannot see except owner and their group. Salesforce recommended me to use this sample trigger. Since I dont have much idea in trigger, this code is not working. Please help.

 

trigger CaseTeamTrigger on Case (after insert, after update) {

    Map<Id, CaseTeamMember> membersToAdd = new Map<Id, CaseTeamMember>();

    List<Case> cases = [Select Id,OwnerId,RecordTypeId,RecordType.Name

                  from Case where id IN :Trigger.newMap.keySet()];

                 

      for (Case c : cases)

    {

        membersToAdd.put(c.Id, new CaseTeamMember(ParentId = c.Id, MemberId = UserInfo.getUserId()));      

    }   

    if (!membersToAdd.isEmpty()) {

      try {

        CaseTeamRole caseTeamRole = [SELECT Id FROM CaseTeamRole WHERE Name = 'Creator' LIMIT 1];

        for (CaseTeamMember ctm : membersToAdd.values()) {

          ctm.TeamRoleId = caseTeamRole.Id;

        }

     

        for (CaseTeamMember ctm : [SELECT Id, MemberId, ParentId

                       FROM CaseTeamMember

                       WHERE ParentId IN :membersToAdd.keySet()

                       AND MemberId = :UserInfo.getUserId()

                       ORDER BY ParentId])

 {

                    

          if (membersToAdd.containsKey(ctm.ParentId)) {

            membersToAdd.remove(ctm.ParentId);

          }

        }

       

        if (!membersToAdd.isEmpty()) {

          insert membersToAdd.values();

        }

      } catch (System.QueryException qe) {}

    }

 

}

 

 

Please help.

Hi,

 

I have a case ticketing system in place. When a user creates a case using ticket system in salesforce I have  an assignment rule that assigns the case to a user in a group -  Group A.  But once the ownership of the case changes from that person based on the rule, the case cannot be reviewed by the user who created the case and the following message is displayed. "Insufficient Privileges. Although the contact name of the ticket exist in the name of the person who created the ticket.  

 

How can i overwrite it to make cases created by the user visible even the ownership of case has been changed to a some other user ??

 

Thanks!

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 need help in case management,
 

 

We need to implement security around tickets. Basically the following will happen:

 

We have 2 record type Legal and Security and 2 groups same as record type. So the condition is

 

1. The group Legal will share tickets with Legal

 

2. The group Security will share ticket with Security

 

3. Because the users who are creating these tickets will not be a part of either of these groups, we need to figure out a way that the end user will always maintain visibility to their tickets.

 

 

Please let me know how I can achieve it?

 

Hi All, Need help.

 

I have a picklist field.  I need to change the picklist values and rename into new one. Thats easy. You can do that with the replace functionality in the field itself.

 

But Now I need to rename the field itself. Is is psossible to do?  What are the effects:

 

a. this field has 1-2 dependency. Also the value of these field is used ina formula. (Again formula can be changed easily).

 

Please explain me the downstream effects.

Please help. Trigger I am getting only of 36%. Please help.

 

trigger BusinessSegment on Opportunity (before insert) {

    for(Opportunity op: Trigger.new){

        if(op.Solution_Offering__c=='Audit/Compliance'&& (op.Business_Application__c=='Audit Management' ||op.Business_Application__c=='Financial Audit Management'||op.Business_Application__c=='Regulato​ry Audit Management') ){

            op.Use_Type_Class__c='Audit/Compliance' ;

            op.Use_Type__c='Financial Audit';

            op.Solution__c='IL Exchange' ;             

        }

    }

  

{

for(Opportunity opp: Trigger.new){

        if(opp.Solution_Offering__c=='Audit/Compliance'&& opp.Business_Application__c=='Compliance Management' ){

            opp.Use_Type_Class__c='Audit/Compliance' ;

            opp.Use_Type__c='Other Audit/Compliance';

            opp.Solution__c='Compliance Link';

          

        }  

}

}

 

{

for(Opportunity opp1: Trigger.new){

        if(opp1.Solution_Offering__c=='Fund Management'&&

        (opp1.Business_Application__c=='Investor Reporting'

         || opp1.Business_Application__c=='Portfolio Company Reporting'

           || opp1.Business_Application__c=='AI Fundraising'  )){

            opp1.Use_Type_Class__c='Financing/Capital Financing' ;

            opp1.Use_Type__c='AI Fundraising';

            opp1.Solution__c='IL Exchange';

          

        }  

}

}

 

{

for(Opportunity opp2: Trigger.new){

        if(opp2.Business_Application__c=='None' ){

            opp2.Use_Type_Class__c='General' ;

            opp2.Use_Type__c='Other (Specify in Description box)';

            opp2.Solution__c='IL Exchange';

          

        }  

}

}

 

{

for(Opportunity opp3: Trigger.new){

        if(opp3.Solution_Offering__c=='Corporate Services'&&

        (opp3.Business_Application__c=='Contract Management'

        || opp3.Business_Application__c=='Vendor Management'

         || opp3.Business_Application__c=='Investor Reporting'

          || opp3.Business_Application__c=='Regulatory Reporting') ){

            opp3.Use_Type_Class__c='General' ;

            opp3.Use_Type__c='Contract Management';

            opp3.Solution__c='IL Exchange';

          

        }  

}

}

 

{

for(Opportunity opp4: Trigger.new){

        if(opp4.Solution_Offering__c=='Strategic Transactions'&&

        (opp4.Business_Application__c=='Financing/Capital Raising'

        || opp4.Business_Application__c=='IPO'

         || opp4.Business_Application__c=='JV/Alliance Management'

          || opp4.Business_Application__c=='Acquisition Mgmt (Buy-side)'

           || opp4.Business_Application__c=='Bankruptcy/Restruct​uring'  ) ){

            opp4.Use_Type_Class__c='Financing/Capital Financing' ;

            opp4.Use_Type__c='IPO';

            opp4.Solution__c='IL Exchange';

 

          

        }  

}

}

 

{

for(Opportunity opp5: Trigger.new){

        if(opp5.Solution_Offering__c=='Strategic Transactions'&& opp5.Business_Application__c=='Licensing' ){

            opp5.Use_Type_Class__c='Licensing & Strategic Alliances' ;

            opp5.Use_Type__c='Licensing';

            opp5.Solution__c='Compliance Link';

          

        }  

}

}

 

 

}

 

 

Apex Class:

@isTest

private class testMyBusinessSegment {

Public static testMethod void testTBusinessSegment ()

{

 

Opportunity opp = new Opportunity();

 

opp.name = 'Test - New Mapping';

opp.Type = 'Transaction - New';

opp.Region__c = 'Americas';

opp.Template__c='Blocks';

opp.StageName = 'Propose';

opp.dlDealType__c = 'Micro Deal';

opp.Solution_Offering__c= 'Audit/Compliance';

opp.Business_Application__c= 'Audit Management';

 

insert opp;

 

}

{

 

Opportunity oppp = new Opportunity();

 

oppp.name = 'Test - Trigger 1';

oppp.Type = 'Transaction - New';

oppp.Region__c = 'Americas';

oppp.Template__c='Blocks';

oppp.StageName = 'Propose';

oppp.dlDealType__c = 'Small Deal';

oppp.Solution_Offering__c= 'Audit/Compliance';

oppp.Business_Application__c= 'Compliance Management';

 

 

 

insert oppp;

}

 

{

 

Opportunity oppp1 = new Opportunity();

 

oppp1.name = 'Test - Trigger 21';

oppp1.Type = 'Transaction - New';

oppp1.Region__c = 'Americas';

oppp1.Template__c='Blocks';

oppp1.StageName = 'Propose';

oppp1.dlDealType__c = 'Small Deal';

oppp1.Solution_Offering__c= 'Fund Management';

oppp1.Business_Application__c= 'AI Fundraising';

 

 

 

insert oppp1;

}

 

 

}

Here is my code where I am updating one picklist field to another picklist field but I am only achieving 50% code coverage. Please help.

 

Apex trigger:

 

trigger BusinessSegment on Opportunity (before insert) {  

   for(Opportunity op: Trigger.new){      

   if(op.Solution_Offering__c=='Debt Financing'||op.Business_Application__c=='Equipment Finance' ){       

      op.Use_Type_Class__c='Financing/Capital Raising';             

  op.Use_Type__c='Equipment Finance';      

   }     } } 

 

Apex class:

 

@isTest private class testMyBusinessSegment { Public static testMethod void testTBusinessSegment () {
Opportunity opp = new Opportunity();
opp.name = 'Test - New Mapping';

opp.Type = 'Transaction - New';

opp.Region__c = 'Americas';

opp.Template__c='Blocks';

opp.StageName = 'Propose';

opp.dlDealType__c = 'Micro Deal';
insert opp;
} }

Hi, Need help in trigger.

 

Whenver a ticket is created through email to case, the ticket is created in the name of my company's administrator and contact name and email shows up as her instead of who actually create the ticket. Although the actual contact who emailed for that ticket exist in our salesforce account.

 

How I can create a trigger to assign the contact name and email for that particular person who created the ticket through email to case instead of my company's administrator? Please help.

Hi All,

 

I have written a bulkified trigger and a test class for the same with 100% test coverage in sandbox. When I try to move it to Production, I get this error.

 

TestBC_AverageAmountNew.ideaBatchTest()Class291Failure Message: "System.LimitException: Too many SOQL queries: 101", Failure Stack Trace: "Trigger.BookingQuota: line 29, column 1"

 

The above class "TestBC_AverageAmountNew" has been written for a batch class. I am unable to move trigger from sandbox to production.

 

How can I rectify the problem? Please help.


 

Thanks,

Alok