• Lam Corporation
  • NEWBIE
  • 50 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 9
    Replies
HI All,

I want to craete report and dashboard for target values versus actual values. I have created custom object to maintain target values.

Now my goal is to create dashboard(barchart)  for target value versus actual value for every quarterwise.
for this i have tried to create two record type in opportunity and achieve in that way but i don't want to create record type typre for that.

Can any one hlp me out for thi.
Regards,
Sarvesh.
Hi all,

I am trying to prevent the deletion with a trigger for Chatter Files from the "Files" related list on Account. 
It seems to work on the Files tab but not the related list on the Account.
I have tried using the ContentVersion object, also the ContentDocument. Nothing is working.
Can anyone help? Many thanks

trigger FilePreventDelete on ContentDocument (after delete) {

    for (ContentDocument record : trigger.old)
    {
        if (record.Id != '')
        {
            record.addError('You can not delete a File once uploaded');
        }
    }
}
Dear all,

I have a Apex Controller Extension and a Test Class all for a Visualforce Page. I am able to get 80% code coverage. I just can't seem to cover 3 lines to do with the page redirect (highlighted in Bold and Italic).

Apex Controller Extension 

public with sharing class MYExtensionController {
 
   private ApexPages.StandardController sc;
    public MYExtensionController(ApexPages.StandardController sc) {
        this.sc = sc;
    }
   
    public PageReference save() {
    
    My_Object__c s = (My_Object__c) sc.getRecord();
    
    try{
 
        My_Object__c so = new My_Object__c();
        so = (My_Object__c)sc.getRecord();
        so.My_Picklist__c = 'My Picklist Value';
    insert s; 
    
    pagereference ref = new pageReference('/apex/ThankYou');
    ref.setRedirect(true);
    return ref;

    
    }
    catch(Exception ex){
    ApexPages.addMessages(ex);
    }
    return null;
    
    }
}

Apex Test Class

@isTest
public class MYExtensionControllerTest {

    public static testMethod void testMyController() {
    PageReference pageRef = Page.ThankYou;
    Test.setCurrentPage(pageRef); 

      // Instanstiate new sObject record  
      My_Object__c wo = new My_Object__c();       
          // Populate the required values 
          wo.Location__c = 'My House';
          wo.Date__c = Date.today();
          wo.Observation__c = 'Breakdown;
          wo.Action__c = 'Did Something';
          wo.Location_Description__c = 'Location22';
          wo.My_Picklist__c = 'My Picklist Value';
          insert wo;
    
          ApexPages.StandardController sc = new ApexPages.StandardController(wo);
          MYExtensionController a = new MYExtensionController(sc);

          Test.startTest();
          a.save();
          
          System.assertEquals(pageRef.getUrl(),'/apex/thankyou');
          My_Object__c[] wo1 = [select id, name, My_Picklist__c from My_Object__c where Location_Description__c = 'Location22'];
          System.assertEquals('My Picklist Value', wo1[0].My_Picklist__c);

          Test.stopTest();
      
    }
}
 
Hi all,

I am working on building a Trigger on a child object that has a lookup field on it to the parent Contact object. 
I have a date field on both the child object and on the Contact. 

I would like to design a bulk trigger that performs a query of all the children of the child object and returns the latest date from all the children that are related to the Contact parent. Then take the latest date and update the Contact parent with the latest date. Creating this for one record would be quite simple. 

Single Query
Child_Object__c a = [SELECT Id, End_Date__c FROM Child_Object__c WHERE Contact__c = contactParentId ORDER BY End_date__c ASC LIMIT 1];

I can't picture how to build this query for all records in Trigger.new. If I return a list of all records and then optimise is and LIMIT 1 I am only going to get one result. I would like to have a query that performs the single query but for all affected records in Trigger.new. 

Can anyone help please? Many thanks for your time.  
Hi all,

I am trying to prevent the deletion with a trigger for Chatter Files from the "Files" related list on Account. 
It seems to work on the Files tab but not the related list on the Account.
I have tried using the ContentVersion object, also the ContentDocument. Nothing is working.
Can anyone help? Many thanks

trigger FilePreventDelete on ContentDocument (after delete) {

    for (ContentDocument record : trigger.old)
    {
        if (record.Id != '')
        {
            record.addError('You can not delete a File once uploaded');
        }
    }
}
Dear all,

I have a Apex Controller Extension and a Test Class all for a Visualforce Page. I am able to get 80% code coverage. I just can't seem to cover 3 lines to do with the page redirect (highlighted in Bold and Italic).

Apex Controller Extension 

public with sharing class MYExtensionController {
 
   private ApexPages.StandardController sc;
    public MYExtensionController(ApexPages.StandardController sc) {
        this.sc = sc;
    }
   
    public PageReference save() {
    
    My_Object__c s = (My_Object__c) sc.getRecord();
    
    try{
 
        My_Object__c so = new My_Object__c();
        so = (My_Object__c)sc.getRecord();
        so.My_Picklist__c = 'My Picklist Value';
    insert s; 
    
    pagereference ref = new pageReference('/apex/ThankYou');
    ref.setRedirect(true);
    return ref;

    
    }
    catch(Exception ex){
    ApexPages.addMessages(ex);
    }
    return null;
    
    }
}

Apex Test Class

@isTest
public class MYExtensionControllerTest {

    public static testMethod void testMyController() {
    PageReference pageRef = Page.ThankYou;
    Test.setCurrentPage(pageRef); 

      // Instanstiate new sObject record  
      My_Object__c wo = new My_Object__c();       
          // Populate the required values 
          wo.Location__c = 'My House';
          wo.Date__c = Date.today();
          wo.Observation__c = 'Breakdown;
          wo.Action__c = 'Did Something';
          wo.Location_Description__c = 'Location22';
          wo.My_Picklist__c = 'My Picklist Value';
          insert wo;
    
          ApexPages.StandardController sc = new ApexPages.StandardController(wo);
          MYExtensionController a = new MYExtensionController(sc);

          Test.startTest();
          a.save();
          
          System.assertEquals(pageRef.getUrl(),'/apex/thankyou');
          My_Object__c[] wo1 = [select id, name, My_Picklist__c from My_Object__c where Location_Description__c = 'Location22'];
          System.assertEquals('My Picklist Value', wo1[0].My_Picklist__c);

          Test.stopTest();
      
    }
}
 
I've spend days searching and made countless attempts and still cannot get this to work. please help.

I simply want to access parent object fields, in this case the parent account record, in a formula in a custom object that has Account as its parent.   From what I read, I should be able to simply state account.name in a formula but I get " Error: Field account does not exist. Check spelling."

I then attempted to duplicate what's in the Salesforce docs https://developer.salesforce.com/page/An_Introduction_to_Formulas which states, "For example, enter Contact.Account.Name to reference the Account Name for a contact associated with a case in a formula field on the Case object."

So I created a custom field in the Case object, then copy/pasted Contact.Account.Name from above. Error message was " Error: Field Contact does not exist. Check spelling.".  So apparently the salesforce documented expression doesn't work. 

I'm at my wits end, taking 2 days and many hours of attempts, getting nowhere. 

It seems something is not right as the field dropdown only shows this in the formula editor in both the Case field test and my own custom object

User-added image


Please help.  If I want to access the account name (or any other account field) in my custom object text field formula.  The object is a child of the Account record. 

Thank you!
Hi,

How to pull a report that shows list of all accounts that does not have any  Opportunities, Contacts , activities?

Thanks!
I have a trigger on custom objectA that updates custom Object B but I have another trigger on Custom Object B on update Event but when I run trigger 1 the trigger 2 is being automatically called due to the object B being same. Can some one guide how to prevent this.
HI All,

I want to craete report and dashboard for target values versus actual values. I have created custom object to maintain target values.

Now my goal is to create dashboard(barchart)  for target value versus actual value for every quarterwise.
for this i have tried to create two record type in opportunity and achieve in that way but i don't want to create record type typre for that.

Can any one hlp me out for thi.
Regards,
Sarvesh.
Hi all,

I am working on building a Trigger on a child object that has a lookup field on it to the parent Contact object. 
I have a date field on both the child object and on the Contact. 

I would like to design a bulk trigger that performs a query of all the children of the child object and returns the latest date from all the children that are related to the Contact parent. Then take the latest date and update the Contact parent with the latest date. Creating this for one record would be quite simple. 

Single Query
Child_Object__c a = [SELECT Id, End_Date__c FROM Child_Object__c WHERE Contact__c = contactParentId ORDER BY End_date__c ASC LIMIT 1];

I can't picture how to build this query for all records in Trigger.new. If I return a list of all records and then optimise is and LIMIT 1 I am only going to get one result. I would like to have a query that performs the single query but for all affected records in Trigger.new. 

Can anyone help please? Many thanks for your time.  

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.

 

We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.

 

The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

 

We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.

 

The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.

 

So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.