• sfdc newbie
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 16
    Replies
Hi, i need help creating a custom detail button on the case object. It need to only be clickable ar funcational when Case.Status = Assigned. If the user clicks on it and case status does not equal assigned, then it needs a pop up or something saying just that. If case status equals assigned, then would like the button to direct to another page "www.salesforce.com" (example)  and also a pop up that says, case has been processed.

If something like this doable?

Thanks, CJ
  • September 29, 2015
  • Like
  • 0
Can anyone tell me where is this error occuring as Everytime a user edits their opportunity value after they set their deal to Award Close 100% according to the opportunity history, a new asset is created for each value edit that is shown in the opportunity history section.

By this Assets are creating multiple times at account object.

trigger CreateAssetonClosedWon on Opportunity (after insert, after update) {
     for(Opportunity o: trigger.new){
      if(o.isWon == true && o.HasOpportunityLineItem == true){
         String opptyId = o.Id;
         OpportunityLineItem[] OLI = [Select UnitPrice, Quantity, PricebookEntry.Product2Id, PricebookEntry.Product2.Name, Description, Converted_to_Asset__c 
                                      From OpportunityLineItem
                                      where OpportunityId = :opptyId  and Converted_to_Asset__c = false];
       List<Asset> ast = new List<Asset>();
      /*  Asset[] ast = new Asset[]{}; */
     
         Asset a = new Asset();
         for(OpportunityLineItem ol: OLI){
            a = new Asset();
        a.AccountId = o.AccountId;
            a.Product2Id = ol.PricebookEntry.Product2Id;
            a.Quantity = ol.Quantity;
            a.Price =  ol.UnitPrice;
            a.PurchaseDate = o.CloseDate;
            a.Status = 'Purchased';
            a.Description = ol.Description;
            a.Name = ol.PricebookEntry.Product2.Name;
            ast.add(a);
            ol.Converted_to_Asset__c = true;
       }
      update OLI;
      insert ast;
     }
    }
}
Could anyone help me as i have created Test class:

@isTest
private class ChatterAnswersCreateAccountTest {
    static testMethod void validateAccountCreation() {
        Profile[] p = [SELECT Id FROM Profile WHERE UserType = 'Standard'];
        User[] user = [SELECT Id, Firstname, Lastname FROM User WHERE IsActive = true and ProfileId =: p[0].Id];
        // We cannot create account without a user.
        if (user.size() == 0) { return; }
         String firstName = user[0].FirstName;
        String lastName = user[0].LastName;
        String userId = user[0].Id;
        Account oAccount = new Account();
        oAccount.name = 'TestAccc';
        oAccount.Industry = 'Other';
        oAccount.Type = 'Previous Customer';
        oAccount.Account_Intergraph_Line_of_Business__c = 'MPM';
        oAccount.Street_Address__c = 'ABC';
        oAccount.City__c = 'CA';
        insert oAccount;
       List <Account> account = [SELECT name, Industry, ownerId from Account where Id =: oAccount.Id];
      System.assertEquals(firstName + ' ' + lastName, oAccount.name);
        System.assertEquals(userId, oAccount.ownerId);

    }
}

and getting errors like

Error Message System.AssertException: Assertion Failed: Expected: Jhon Tony, Actual: TestAccc
Stack Trace Class.ChatterAnswersCreateAccountTest.validateAccountCreation: line 20, column 1
Could any one help y iam getting error in my test class

@isTest
private class ChatterAnswersCreateAccountTest {
    static testMethod void validateAccountCreation() {
        Profile[] p = [SELECT Id FROM Profile WHERE UserType = 'Standard'];
        User[] user = [SELECT Id, Firstname, Lastname FROM User WHERE IsActive = true and ProfileId =: p[0].Id];
        // We cannot create account without a user.
        if (user.size() == 0) { return; }
        String firstName = user[0].FirstName;
        String lastName = user[0].LastName;
        String userId = user[0].Id;
        String accountId = new ChatterAnswersRegistration().createAccount(firstName, lastName, Industry, userId);
        Account account = [SELECT name, Industry, ownerId from Account where Id =: accountId];
        System.assertEquals(firstName + ' ' + lastName, account.name, account.Industry);
        System.assertEquals(userId, account.ownerId);
    }
}
how to get close date in convert lead page?

here i have created a custom conert lead page.
in that i have applied the code for close date in opportunity section in vf:

<apex:pageBlockSectionItem id="oppCloseDateSection" rendered="true">
                        <apex:outputlabel for="opportunityCloseDate" value="Close Date" />
                        <apex:outputPanel styleClass="requiredInput" layout="block">
                           <apex:outputPanel styleClass="requiredBlock" layout="block" />
                            <apex:inputField id="oppCloseDate" value="{!opportunity.CloseDate}" />
                      </apex:outputPanel>
                    </apex:pageBlockSectionItem>

and in Apex class:

//If user decides to create Opportunity, insert new Opportunity
                if (!doNotCreateOpportunity) {
                    try {
                        if (opportunity.Opportunity_XXX__c == 'XXX') opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'XXX'].Id;
                        else if (opportunity.Opportunity_Intergaph_XXX__c == 'YYYY) opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'YYYY'].Id;
                        else if (opportunity.Opportunity_XXX__c == 'zzzz') opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'zzzz'].Id;
                        else opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'PPP'].Id;
                        opportunity.AccountId = account.Id;
                        opportunity.Name = opportunityName;
                        opportunity.StageName = 'Lead 0%';
                       opportunity.CloseDate = lead.Close_date__c;
                        //opportunity.XXX__c = lead.XXX__c;
                      
                        insert opportunity;
I created some code like this. but i dont want to display type 2 field by default also. Could anyone please help out

<apex:page controller="ShowSectionController" tabStyle="Account">
  <apex:form >
  <Apex:actionFunction name="hideSection" action="{!hideSectionOnChange}" rerender="pg"/>

      <apex:pageBlock id="pg">
   <apex:pageBlockSection >
              <apex:inputField value="{!acc.Type}" onchange="hideSection('{!acc.Type}')"/>
         </apex:pageBlockSection>
             <apex:pageBlockSection rendered="{!(!flag)}">
             <apex:inputField value="{!acc.Type_2__c}"/>
          </apex:pageBlockSection>
      </apex:pageBlock>
  </apex:form>
</apex:page>

public class ShowSectionController
{
    public Account acc{get;set;}
    public boolean flag{get;set;}
    public ShowSectionController()
    {
        acc = new Account();
        flag = false;
      
    }
    public void hideSectionOnChange()
    {
        if(acc.Type == 'Value 1')                        
            flag = false;
        if(acc.Type != 'Value 1')
            flag = true;
    }
}

How to get email field from Account or Lead to opportunity object in salesforce as iam using Person accounts?? Please reply soon as iam having very much urgency.

Cannot complete the install because one or more required items could not be found.
  Software being installed: Force.com IDE 24.0.0.201202291629 (com.salesforce.ide.feature.feature.group 24.0.0.201202291629)

Is there any way to create a custom report on a custom object in group edition.

As I'm working in an Organization facing some problem, can any one guide me - As i want to generate Reports for Accounts owned and shared within Roles Hierarchy
Hi, i need help creating a custom detail button on the case object. It need to only be clickable ar funcational when Case.Status = Assigned. If the user clicks on it and case status does not equal assigned, then it needs a pop up or something saying just that. If case status equals assigned, then would like the button to direct to another page "www.salesforce.com" (example)  and also a pop up that says, case has been processed.

If something like this doable?

Thanks, CJ
  • September 29, 2015
  • Like
  • 0
Could any one help y iam getting error in my test class

@isTest
private class ChatterAnswersCreateAccountTest {
    static testMethod void validateAccountCreation() {
        Profile[] p = [SELECT Id FROM Profile WHERE UserType = 'Standard'];
        User[] user = [SELECT Id, Firstname, Lastname FROM User WHERE IsActive = true and ProfileId =: p[0].Id];
        // We cannot create account without a user.
        if (user.size() == 0) { return; }
        String firstName = user[0].FirstName;
        String lastName = user[0].LastName;
        String userId = user[0].Id;
        String accountId = new ChatterAnswersRegistration().createAccount(firstName, lastName, Industry, userId);
        Account account = [SELECT name, Industry, ownerId from Account where Id =: accountId];
        System.assertEquals(firstName + ' ' + lastName, account.name, account.Industry);
        System.assertEquals(userId, account.ownerId);
    }
}
how to get close date in convert lead page?

here i have created a custom conert lead page.
in that i have applied the code for close date in opportunity section in vf:

<apex:pageBlockSectionItem id="oppCloseDateSection" rendered="true">
                        <apex:outputlabel for="opportunityCloseDate" value="Close Date" />
                        <apex:outputPanel styleClass="requiredInput" layout="block">
                           <apex:outputPanel styleClass="requiredBlock" layout="block" />
                            <apex:inputField id="oppCloseDate" value="{!opportunity.CloseDate}" />
                      </apex:outputPanel>
                    </apex:pageBlockSectionItem>

and in Apex class:

//If user decides to create Opportunity, insert new Opportunity
                if (!doNotCreateOpportunity) {
                    try {
                        if (opportunity.Opportunity_XXX__c == 'XXX') opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'XXX'].Id;
                        else if (opportunity.Opportunity_Intergaph_XXX__c == 'YYYY) opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'YYYY'].Id;
                        else if (opportunity.Opportunity_XXX__c == 'zzzz') opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'zzzz'].Id;
                        else opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'PPP'].Id;
                        opportunity.AccountId = account.Id;
                        opportunity.Name = opportunityName;
                        opportunity.StageName = 'Lead 0%';
                       opportunity.CloseDate = lead.Close_date__c;
                        //opportunity.XXX__c = lead.XXX__c;
                      
                        insert opportunity;
I created some code like this. but i dont want to display type 2 field by default also. Could anyone please help out

<apex:page controller="ShowSectionController" tabStyle="Account">
  <apex:form >
  <Apex:actionFunction name="hideSection" action="{!hideSectionOnChange}" rerender="pg"/>

      <apex:pageBlock id="pg">
   <apex:pageBlockSection >
              <apex:inputField value="{!acc.Type}" onchange="hideSection('{!acc.Type}')"/>
         </apex:pageBlockSection>
             <apex:pageBlockSection rendered="{!(!flag)}">
             <apex:inputField value="{!acc.Type_2__c}"/>
          </apex:pageBlockSection>
      </apex:pageBlock>
  </apex:form>
</apex:page>

public class ShowSectionController
{
    public Account acc{get;set;}
    public boolean flag{get;set;}
    public ShowSectionController()
    {
        acc = new Account();
        flag = false;
      
    }
    public void hideSectionOnChange()
    {
        if(acc.Type == 'Value 1')                        
            flag = false;
        if(acc.Type != 'Value 1')
            flag = true;
    }
}

I would like to copy the email address I have in the account to a custom email field I created in the opportunity associated with that account. I need a email field in the opportunity in order to notify via email after an approval proces has been approved. If this email field doesn´t exist I can´t send an email to the account. Is there a way with appex code to automate this copying and pasting??

 

Thanks!

  • September 23, 2010
  • Like
  • 0