• Vishal (Sops)
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Guys - I have a trigger deployed to retrieve owner role of an opportunity. It's working fine but fails while mass updating opportunity. Can anyone help to make it a bulk trigger.

 

trigger OwnerRoleTrigger on Opportunity (before insert, before update) {

List<Opportunity> oppList = new List<Opportunity>();
 List<string> ownerId = new list<string>();
 list<String> userRole = new list<string>() ;
 
 for(Opportunity opp1 : Trigger.New) {
    ownerId.add(opp1.ownerId);
 }
 
 List<User> users = [select UserRoleId from User where Id in: ownerId];
 
 for(User u : users){
    userRole.add(u.UserRoleId);
 }
 List<UserRole> userRoles = [select Name from UserRole where Id in: UserRole];
 
  for(Opportunity opp : Trigger.New) {
   for(User u : users){
       for(UserRole ur : userRoles){
           opp.opp_owner_role__c = ur.Name;
       }
   }


}
}

 

Thanks a lot

 

Best Regards,

Vishal Sharma

This is my code to simpy update a field on custom object from the task. I have never written a test class so please help me out to compose it.

 

trigger SandboxCC on Task (before update,after update) {

if(Trigger.isUpdate){

for(Task t : Trigger.new)
{

if(t.IsClosed == True && t.subject.contains('App Preview Sent to Customer'))
{
for(CC_Card__c c : [Select c.Id, c.stage__c From CC_Card__c c ])
{
c.stage__c = 'Preview & Iterate';
c.a_Preview_Date__c = system.today();
update c;
}

}

}
}
}

Guys - Can you help me out. I have a custom object CC Card. I need to update a picklist value field on this object depending on the task logged under this CC Card object. My requirement are:-

 

Trigger should fire only when task gets closed.

If task subject contains "Kick-Off" and is being closed, it should update the picklist field, say stage as Kick-Off .

 

I am new to triggers, see if you experts can help me out. Here is my try at it.

 

trigger TestVishal on Task (before update) {

//Preparting CCCards to Update
public list<CC_Card__c> CardsToUpdate = new List<CC_Card__c>();
public set<Id> CCCardIDs = new Set<Id>();

 if(Trigger.isUpdate){

 for(Task t : Trigger.new)
 {
      if(t.WhoId<>null)
      {
      
               if(string.valueOf(t.WhoId).startsWith('a0P') && t.IsClosed == True)
               CCCardIDs.add(t.whoId);
               
       }
               
 }
 }
 if(CCCardIDs.size()<>0){
  for(CC_Card__c c : [Select c.Id, c.stage__c,(Select Id, Ownerid From Tasks where IsClosed = True AND subject like '%Kick-Off%')From CC_Card__c c where Id in :CCCardIDs])
             
             CardsToUpdate.add(new CC_Card__c(Id=c.Id, stage__c = 'Kick-Off'));                
                                       
        }     
        
        update CardsToUpdate;                     
     
  }

 

It's not giving me any error message when I save it but it's not working either :(

Hi,

 

I want to use custom object field values in VF page ( I can do this by specifying the controller as my custom object and page loads in the custom tab).

Now the page created above I need to embed this in some other Tab say Account. I don't get an error when I use the above page on wellform page. But it shows an error:

Content cannot be displayed: Id value 001d000000Va7JT is not valid for the "mycustomobject"

I understand the error. But I really need to use this VF page in the standard tab.

 

Any pointers help is most appreciated.

 

Please ..

 

This is my code to simpy update a field on custom object from the task. I have never written a test class so please help me out to compose it.

 

trigger SandboxCC on Task (before update,after update) {

if(Trigger.isUpdate){

for(Task t : Trigger.new)
{

if(t.IsClosed == True && t.subject.contains('App Preview Sent to Customer'))
{
for(CC_Card__c c : [Select c.Id, c.stage__c From CC_Card__c c ])
{
c.stage__c = 'Preview & Iterate';
c.a_Preview_Date__c = system.today();
update c;
}

}

}
}
}

Guys - Can you help me out. I have a custom object CC Card. I need to update a picklist value field on this object depending on the task logged under this CC Card object. My requirement are:-

 

Trigger should fire only when task gets closed.

If task subject contains "Kick-Off" and is being closed, it should update the picklist field, say stage as Kick-Off .

 

I am new to triggers, see if you experts can help me out. Here is my try at it.

 

trigger TestVishal on Task (before update) {

//Preparting CCCards to Update
public list<CC_Card__c> CardsToUpdate = new List<CC_Card__c>();
public set<Id> CCCardIDs = new Set<Id>();

 if(Trigger.isUpdate){

 for(Task t : Trigger.new)
 {
      if(t.WhoId<>null)
      {
      
               if(string.valueOf(t.WhoId).startsWith('a0P') && t.IsClosed == True)
               CCCardIDs.add(t.whoId);
               
       }
               
 }
 }
 if(CCCardIDs.size()<>0){
  for(CC_Card__c c : [Select c.Id, c.stage__c,(Select Id, Ownerid From Tasks where IsClosed = True AND subject like '%Kick-Off%')From CC_Card__c c where Id in :CCCardIDs])
             
             CardsToUpdate.add(new CC_Card__c(Id=c.Id, stage__c = 'Kick-Off'));                
                                       
        }     
        
        update CardsToUpdate;                     
     
  }

 

It's not giving me any error message when I save it but it's not working either :(

Hello,

I would like to change the name of one of my triggers. Is there any way to do this in a Production org?

HI,

 

The documentation tells me that i can create a task object which is related to an custom object by using the WhatID field. Is i creat a task via DML and link it to my custom object ID the insert will fail because of 'Related To: Opportunity/Account ID: id value of incorrect type: a04A000000Bj8wJIAR'. 

 

Has someone experience with this and is there a way to do this without any custom objects...?

 

Thanks,

Sten

  • September 01, 2011
  • Like
  • 1

Does anyone know how? there is no standard controller for Tasks...

Hi.

I see that SF auto update the close date every time I change(not rename) the account of opportunity, why?? Does it normal for SF ?

 

For example:

I have opportunity with:

won = true

closedate = 01 jan 2010

stagename = close/won

 

today 21 may 2010 if I change(not rename) account of the opportunity , because I check that is wrong, and I save the opportunity the results will be:

 

won = true

closedate = 21 may 2010

stagename = close/won

 

I have no worfkflow or trigger active, that do this change of closedate.

 

I think it is a bug of salesforce.

 

Another bug is that in 21 may 2010, if I change account of the opportunity some workflow will be fired again. This workflow that will be fired doesn't have any criteria linked to the change of account!!

 

Hi All,

 

I have a requirement to show # of open Task on Lead Detailpage. Below is the logic that we are planning to implement. I would like tocheck with you if any one has implemented similar functionality handling BULK insert/update.If so could you please share the code?

 

Trigger on Task <after insert after update>

 

{

    for (Task thistask : Trigger.new)

      {

    // Get all leads assosited to Tasks

    if (WhoId.startsWith('00Q'))               

      leadIdToUpdateList.add(taskWhoId.WhoId);

     }

 

FOR each Lead

           SelectCount() from Task where whoId=LeadId and Status=Completed

           Updatecustom field “ Open Task” on  Lead object

End Loop   

 

}

 

Thank You . 

Hi,

 

I have a bunch of validation rules on the account object> have avisual force page that saves some changes into the  account Object. In sthis special case I do not want the validation rules to fire.

 

I tried implementing this by

1) checking a custom check box from the Apex code before making the special update from the controller.

2) unchecking the check box after i have made my special update;

 

I look for this flag in my validation rule to skip that rule if it is checked.

 

But ths does not seeme to work as it seems like there are some commit issues. I am unable to by pass the validation rule. Any ideas on how to solve this?

 

thanks,

Odie

 

 

 

 

Hello, I have installed Excel connector and have not yet been able to import a report. I have chosen a variety of report types and report locations and get the same error message each time. Is there a setting I need to adjust? Thanks!

 

Error: Unable to retrieve the requested report. Please log in to Salesforce using a web browser to confirm the report's availability.

We've setup a few custom fields in our Leads & Contacts objects... but I'm not able to see how to get these in from queries or how to update them. So far nothing in the SDK is jumping out or on the wiki. Tips/pointers?