• nmnbawa
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 8
    Replies

I am trying to display the image on my custom VF page from an external website based on unique field called property_id__c on my custom object called property__c but the image is not being displayed. Can some one please help.

 

<apex:page standardController="Property__c">
<apex:image url="https://division.abc.com/osis/map.cfm?&mapid=LM-002&prid=property_id__c">
</apex:image>
</apex:page>

 

 

If I open the Url alone appended with ID it works. Please help.

I have a following business requirement.

We are using products to capture different products that our company offers.

On an opportunity we use a lookup to product to select the product that is bought.

My challege is that there is a total amount on the product that can be sold (total_amount__c), whenever an opportunity is created against a product I want the total amount to reflect 

Total amount - Oppty amount

and show the message to the user if the total product amount is less than 0

Can someone point me in right direction please. If someone can provide trigger code and the test class I would greatly appreciate.

Thanks

I have two objects Distributions and distributions used. there is a lookup from distribution to the distribution used object.

 

I have a field named Distribution amount left on the Distribution object which I want to update everytime distribution used object's field amount Reinvested is populated

 

So the formula would be 

 

Distribution amount left (distribution field)= Distrbution Amount(Distribution field) -  Amount Reinvested(Distribution used field)

 

Can someone please help with the below trgger. Also I want the error message if the amount left is negative. I know my trigger is totally screwed up.

 

Many thanks

 

trigger dda on Distribution__c  (before insert, before update)  {
 Map<Id,Id> userMap = new Map<Id,Id>();
    for (Distribution__c item : Trigger.new)
    {
        
        userMap.put(item.Distribution_Amount_Left__c, null);
        userMap.put(item.Distribution_Amount__c, null);
}

for (distribution_used__c item : [SELECT Id, Amount_Re_Invested__c FROM distribution_used__c WHERE Id IN :userMap.keySet()])
    {
        userMap.put(item.Id, item.Amount_Re_Invested__c);
    }
    
    for (Distribution__c item : Trigger.new)
    {
        item.Distribution_Amount_Left__c = userMap.get(item.Distribution_Amount__c)- (userMap.get(item.Amount_Re_Invested__c));
                              
    }

 

Please help.

 

I have a custom object on which I have two record types A and B. I have two triggers to populate the Contact Owner or the Lead owner automatically in the two text fields Contact Account Manager and Lead Account Manager respectively. The problem is that I get the null reference error when I only try  to select a lead or a contact as on the record type page assignment I am either showing lead or contact. 

 

Here are two triggers. IF someone can provide test class as well it would be great. Thanks a ton in advance.

rigger LeadOwner on DD_Master_List__c (before insert, before update) {
    Map<Id, User> ownerMap = new Map<Id, User>{};
    
    for(DD_Master_List__c tt: Trigger.new)
    {   
        ownerMap.put(tt.LeadAMID__c, null);       
    }
    
    ownerMap.putAll([SELECT Id, Name FROM User WHERE Id IN :ownerMap.keySet()]);
    
    for(DD_Master_List__c tt: Trigger.new)
    {
       
        User u = ownerMap.get(tt.LeadAMID__c);
        tt.Lead_Account_Manager__c= u.name;
    }
    }

 

trigger ContactOwner on DD_Master_List__c (before insert, before update) {
    Map<Id, User> ownerMap = new Map<Id, User>{};
    for(DD_Master_List__c tt: Trigger.new)
    {        
        ownerMap.put(tt.ClientAMID__c, null);        
    }
    
    ownerMap.putAll([SELECT Id, Name FROM User WHERE Id IN :ownerMap.keySet()]);
    
    for(DD_Master_List__c tt: Trigger.new)
    {
       
        User u = ownerMap.get(tt.clientAMID__c);
        tt.Client_Account_Manager__c= u.name;
    }
    }

 

I have a trigger question.

 

I have a custom object named employee with a lookup field to the user record called Salesforce_user__c

 

I have another custom object called DD master list in which there is a field called Account_Manager__c that is a lookup to employee object.

 

 

Mt requirement is to populate the Account manager Salesforce User id in the new AM__c field. Below is the trigger i wrote(that does not work at all), if someone can help me with the test class and refinining the trigger I would be very grateful to you.

Please help

trigger SetDDmasterFields on DD_master_list__c (before insert, before update) {
    Map<Id,User> userMap = new Map<Id,User>();
    
    for (dd_master_list__c dd : Trigger.new) {
        userMap.put(dd.account_manager__r.Salesforce_User__c, null);
    }
    userMap.remove(null);
    
    if (!userMap.keyset().isEmpty()) {
        for (User u : [SELECT Id FROM User WHERE Id IN :userMap.keyset()]) {
            userMap.put(u.Id,u);
        }
        
        for (dd_master_list__c dd : Trigger.new) {
            if (userMap.get(dd.account_manager__r.Salesforce_User__c) != null) {
              dd.AM__c = userMap.get(dd.account_manager__r.Salesforce_User__c).Id;
          }
        }
    }
}

 

I have following trigger which creates a log in  the custom object whenever a task is modified.

 

There are two problems the trigger is creating a log record even when the new task is created. It should only created the record when the task is modified.

Also it is creating a log for all the objects. I only want the log to be captured for Accounts/Contacts i.e whatid should only be account/contact record.

 

Can someone please help in refining the trigger.

 

Thanks in advance.

 

trigger CommentLog on Task (before update) {
    List<CommentLog__c> newcomments = new List<CommentLog__c> ();
    Map<Id, Task> mTask = new Map<Id, Task> ();
    
    //build the task map first
    for(Task t: [select Id, owner.name,LastModifiedBy.name,what.name from Task where Id in : Trigger.old]) {
        mTask.put(t.id,t);
    }
    
    //build comment log
    for(Task t: trigger.old) {
      CommentLog__c c = new CommentLog__c();
      Task tt = mTask.get(t.Id);
      c.Previous_Comment__c=t.Description;
      c.CommentDate__c=t.LastModifiedDate;
      c.Name= (tt!=null?tt.LastModifiedBy.name:null);
      c.Task_owner__c = (tt!=null? tt.owner.name:null);
      c.type__c='Task';
      c.Taskid__c=t.id;
      c.Link_to_Task__c=URL.getSalesforceBaseUrl().toExternalForm() + '/' + t.id;
      c.whatid__c=URL.getSalesforceBaseUrl().toExternalForm() + '/' +t.whatid;
      c.Account_Contact_Name__c=(tt!=null?tt.what.name:null);
      c.Account_Contact_ID__c = t.whatid;
      newcomments.add(c);
    }
    //insert comment log list
    insert newcomments;
}

 

I have a picklist on account object called "Status"and one of the values is "Duplicate"

I want to prevent the users from creating any tasks/events against an account when the status is duplicate.


Any ideas how to achieve it.


I cannot create a validation rule on the Activity object as it does not allow to reference custom account fields.

I have a picklist on account object called "Status"and one of the values is "Duplicate"

I want to prevent the users from creating any tasks/events against an account when the status is duplicate.


Any ideas how to achieve it.


I cannot create a validation rule on the Activity object as it does not allow to reference custom account fields.

Can someone please help me with custom code and apex class for tracking history on the user object by copying that to new custom object so that I can create report of this custom object.

 

Please help

I have an apex class which is scheduled  to run daily via apex job and I want to change the running user on it or the name of the user which gets stamped on the records. Please advise.

I am getting error message on hitting the governor limits due to the trigger below. What this trigger does is that whenever a task's description it copies over the data from the task object on to the custom object. Can someone please help so that my code does not hit the governor limits.

 

Many thanks in advance.

 

trigger CommentLog on Task (before update) {
for(Task t: trigger.old)
{
CommentLog__c c = new CommentLog__c();
c.Previous_Comment__c=t.Description;
c.CommentDate__c=t.LastModifiedDate;
task t1= [select owner.name,LastModifiedBy.name from task where id=:t.id];
c.Name=t1.LastModifiedBy.name;
c.Task_owner__c=t1.owner.name;
c.type__c='Task';
c.Link_to_Task__c='https://na1.salesforce.com/'+t.id;
insert c;

}

}

 

Hi Everyone,

 

Can someone please help.

 

I have a custom object called Student and has associated tasks with it. 

 

when a student is not active, I want all the tasks to be automatically marked as completed. can someone please help with the trigger and test class.

 

Many many thanks in advance.

I have two objects Distributions and distributions used. there is a lookup from distribution to the distribution used object.

 

I have a field named Distribution amount left on the Distribution object which I want to update everytime distribution used object's field amount Reinvested is populated

 

So the formula would be 

 

Distribution amount left (distribution field)= Distrbution Amount(Distribution field) -  Amount Reinvested(Distribution used field)

 

Can someone please help with the below trgger. Also I want the error message if the amount left is negative. I know my trigger is totally screwed up.

 

Many thanks

 

trigger dda on Distribution__c  (before insert, before update)  {
 Map<Id,Id> userMap = new Map<Id,Id>();
    for (Distribution__c item : Trigger.new)
    {
        
        userMap.put(item.Distribution_Amount_Left__c, null);
        userMap.put(item.Distribution_Amount__c, null);
}

for (distribution_used__c item : [SELECT Id, Amount_Re_Invested__c FROM distribution_used__c WHERE Id IN :userMap.keySet()])
    {
        userMap.put(item.Id, item.Amount_Re_Invested__c);
    }
    
    for (Distribution__c item : Trigger.new)
    {
        item.Distribution_Amount_Left__c = userMap.get(item.Distribution_Amount__c)- (userMap.get(item.Amount_Re_Invested__c));
                              
    }

 

Please help.

 

I have a custom object on which I have two record types A and B. I have two triggers to populate the Contact Owner or the Lead owner automatically in the two text fields Contact Account Manager and Lead Account Manager respectively. The problem is that I get the null reference error when I only try  to select a lead or a contact as on the record type page assignment I am either showing lead or contact. 

 

Here are two triggers. IF someone can provide test class as well it would be great. Thanks a ton in advance.

rigger LeadOwner on DD_Master_List__c (before insert, before update) {
    Map<Id, User> ownerMap = new Map<Id, User>{};
    
    for(DD_Master_List__c tt: Trigger.new)
    {   
        ownerMap.put(tt.LeadAMID__c, null);       
    }
    
    ownerMap.putAll([SELECT Id, Name FROM User WHERE Id IN :ownerMap.keySet()]);
    
    for(DD_Master_List__c tt: Trigger.new)
    {
       
        User u = ownerMap.get(tt.LeadAMID__c);
        tt.Lead_Account_Manager__c= u.name;
    }
    }

 

trigger ContactOwner on DD_Master_List__c (before insert, before update) {
    Map<Id, User> ownerMap = new Map<Id, User>{};
    for(DD_Master_List__c tt: Trigger.new)
    {        
        ownerMap.put(tt.ClientAMID__c, null);        
    }
    
    ownerMap.putAll([SELECT Id, Name FROM User WHERE Id IN :ownerMap.keySet()]);
    
    for(DD_Master_List__c tt: Trigger.new)
    {
       
        User u = ownerMap.get(tt.clientAMID__c);
        tt.Client_Account_Manager__c= u.name;
    }
    }

 

I have a trigger question.

 

I have a custom object named employee with a lookup field to the user record called Salesforce_user__c

 

I have another custom object called DD master list in which there is a field called Account_Manager__c that is a lookup to employee object.

 

 

Mt requirement is to populate the Account manager Salesforce User id in the new AM__c field. Below is the trigger i wrote(that does not work at all), if someone can help me with the test class and refinining the trigger I would be very grateful to you.

Please help

trigger SetDDmasterFields on DD_master_list__c (before insert, before update) {
    Map<Id,User> userMap = new Map<Id,User>();
    
    for (dd_master_list__c dd : Trigger.new) {
        userMap.put(dd.account_manager__r.Salesforce_User__c, null);
    }
    userMap.remove(null);
    
    if (!userMap.keyset().isEmpty()) {
        for (User u : [SELECT Id FROM User WHERE Id IN :userMap.keyset()]) {
            userMap.put(u.Id,u);
        }
        
        for (dd_master_list__c dd : Trigger.new) {
            if (userMap.get(dd.account_manager__r.Salesforce_User__c) != null) {
              dd.AM__c = userMap.get(dd.account_manager__r.Salesforce_User__c).Id;
          }
        }
    }
}

 

I have following trigger which creates a log in  the custom object whenever a task is modified.

 

There are two problems the trigger is creating a log record even when the new task is created. It should only created the record when the task is modified.

Also it is creating a log for all the objects. I only want the log to be captured for Accounts/Contacts i.e whatid should only be account/contact record.

 

Can someone please help in refining the trigger.

 

Thanks in advance.

 

trigger CommentLog on Task (before update) {
    List<CommentLog__c> newcomments = new List<CommentLog__c> ();
    Map<Id, Task> mTask = new Map<Id, Task> ();
    
    //build the task map first
    for(Task t: [select Id, owner.name,LastModifiedBy.name,what.name from Task where Id in : Trigger.old]) {
        mTask.put(t.id,t);
    }
    
    //build comment log
    for(Task t: trigger.old) {
      CommentLog__c c = new CommentLog__c();
      Task tt = mTask.get(t.Id);
      c.Previous_Comment__c=t.Description;
      c.CommentDate__c=t.LastModifiedDate;
      c.Name= (tt!=null?tt.LastModifiedBy.name:null);
      c.Task_owner__c = (tt!=null? tt.owner.name:null);
      c.type__c='Task';
      c.Taskid__c=t.id;
      c.Link_to_Task__c=URL.getSalesforceBaseUrl().toExternalForm() + '/' + t.id;
      c.whatid__c=URL.getSalesforceBaseUrl().toExternalForm() + '/' +t.whatid;
      c.Account_Contact_Name__c=(tt!=null?tt.what.name:null);
      c.Account_Contact_ID__c = t.whatid;
      newcomments.add(c);
    }
    //insert comment log list
    insert newcomments;
}

 

I have a picklist on account object called "Status"and one of the values is "Duplicate"

I want to prevent the users from creating any tasks/events against an account when the status is duplicate.


Any ideas how to achieve it.


I cannot create a validation rule on the Activity object as it does not allow to reference custom account fields.

Hi, I am getting an error while converting lead when I uncheck the box "do not create Opportunity upon convertion".

The following is the page displaying error while converting the lead.

Please help me out regarding this.

 

 

 

Hi Everyone,

 

Can someone please help.

 

I have a custom object called Student and has associated tasks with it. 

 

when a student is not active, I want all the tasks to be automatically marked as completed. can someone please help with the trigger and test class.

 

Many many thanks in advance.