• Akshay Koparde
  • NEWBIE
  • 99 Points
  • Member since 2016


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 11
    Replies
I have  written a practice trigger Which populates the Description feild on Account object If the Industry = Banking. From the UI it works good. Also get 100 Test coverage. I feel the trigger is not firing from Test class because my System.debug are not logging the fields I need. I would be very thankful if anyone can point out my mistake. I would like to add my System.assertEquals are failing. Please help me learn


/*Trigger*/

trigger UpdateDescriptionOnAccount on Account (before insert) {
    list<Account> ActList=new list<Account>();
    for(Account a :Trigger.new)
    {
        if(a.Industry=='Banking' && a.Description == Null)
        {
            a.Description='This is a Banking Account';
            ActList.add(a);
        }
       
    }
    //insert ActList;

}

This is my test Class
/*Test Class*/

@isTest
public class TestUpdateDescriptionOnAccount {
    static testmethod void TestUpdate()
    {
       Account a = New Account(Name='Test Account 1',Industry='Banking');
       insert a;
      System.debug('Account Inserted '+a.Name + 'Description ='+a.Description +a.Industry);
       //system.assertEquals('This is a Banking Account',a.Description);
       
        
       Account b = New Account(Name='Test Account 2',Industry='Agriculture');
       insert b;
       //System.assertEquals(Null, b.Description);
        
       list<Account>testAccount = new List<Account>();
        for(integer i=0;i<200;i++)
        {
            Account c = new Account(Name='Account '+i, Industry='Banking');
            testAccount.add(c);
        }
        test.startTest();
        	insert testAccount;
        test.stopTest();
      for(Account d : TestAccount)
       {
            //system.assertEquals('This is a Banking Account',d.Description);
           System.debug('Account Inserted '+d.Name + 'Description ='+d.Description);
       }
        
    }

}


 
Hi,
I am working on Trailhead -Process Automation. I am facing a problem where in my visual flow design tool is not loading. Whenever I try creating a new flow from setup I get a Blank page. Please help

ThanksScreenshot
This is a standard code from trailhead module when  I copy paste on developer console i get an error.

Trailhead Code
public static void updateOlderAccounts() {
    // Get the 5 oldest accounts
    Account[] oldAccounts = [SELECT Id, Description FROM Account ORDER BY CreatedDate ASC LIMIT 5];
    // loop through them and update the Description field
    for (Account acct : oldAccounts) {
        acct.Description = 'Heritage Account';
   }
   // save the change you made
   update oldAccounts;
}
I have manipulated the above code to debug the errors with below code statements
User-added image
Still not able to resolve the problem. Kindly requesting to please help me identifying the mistake and propbable solution.
Thanks!
Hi All,

I am pretty new to salesforce. I have written a custom apex class to get the string data from visualforce page. This string is compared with records in database and displays on the screen. In my case I am performing this operation on Account object. I dont know why when I type input string(say industry type) in the input box created using Visualforce page and hit "Go!" button  the list of records dont populate in the table declared in visualforce code. Kindly suggest the changes needed.

VisualForce Code
<apex:page controller="search_accounts" >
<apex:form >
    <apex:pageBlock title="Account Search">
    <apex:inputText value="{!input_text}" />
    <apex:commandButton value="Go!"/>
    <apex:pageBlockTable value="{!search_result}" var="a">
        <apex:column value="{!a.Name}"/>
        <apex:column value="{!a.Type}"/>
        <apex:column value="{!a.Industry}"/>
        <apex:column value="{!a.Phone}"/>
    </apex:pageBlockTable>  
    </apex:pageBlock>
</apex:form>  
</apex:page>

Custom controller
public class search_accounts
{
    public string input_text;
    public list<Account> search_result;
    
    public string getinput_text()
    {
        return input_text;
    }
    public list<Account> getsearch_result()
    {
        return search_result;
    }
    
    public void setinput_text(string s)
    {
        input_text=s;
    }
    public PageReference Go()
    {
        search_result=[select Name, Type, Industry, Phone from Account Where Industry=:input_text];
        return NULL;
    }
}

 
I have  written a practice trigger Which populates the Description feild on Account object If the Industry = Banking. From the UI it works good. Also get 100 Test coverage. I feel the trigger is not firing from Test class because my System.debug are not logging the fields I need. I would be very thankful if anyone can point out my mistake. I would like to add my System.assertEquals are failing. Please help me learn


/*Trigger*/

trigger UpdateDescriptionOnAccount on Account (before insert) {
    list<Account> ActList=new list<Account>();
    for(Account a :Trigger.new)
    {
        if(a.Industry=='Banking' && a.Description == Null)
        {
            a.Description='This is a Banking Account';
            ActList.add(a);
        }
       
    }
    //insert ActList;

}

This is my test Class
/*Test Class*/

@isTest
public class TestUpdateDescriptionOnAccount {
    static testmethod void TestUpdate()
    {
       Account a = New Account(Name='Test Account 1',Industry='Banking');
       insert a;
      System.debug('Account Inserted '+a.Name + 'Description ='+a.Description +a.Industry);
       //system.assertEquals('This is a Banking Account',a.Description);
       
        
       Account b = New Account(Name='Test Account 2',Industry='Agriculture');
       insert b;
       //System.assertEquals(Null, b.Description);
        
       list<Account>testAccount = new List<Account>();
        for(integer i=0;i<200;i++)
        {
            Account c = new Account(Name='Account '+i, Industry='Banking');
            testAccount.add(c);
        }
        test.startTest();
        	insert testAccount;
        test.stopTest();
      for(Account d : TestAccount)
       {
            //system.assertEquals('This is a Banking Account',d.Description);
           System.debug('Account Inserted '+d.Name + 'Description ='+d.Description);
       }
        
    }

}


 
Hi,
I am working on Trailhead -Process Automation. I am facing a problem where in my visual flow design tool is not loading. Whenever I try creating a new flow from setup I get a Blank page. Please help

ThanksScreenshot
Hi All,

I am pretty new to salesforce. I have written a custom apex class to get the string data from visualforce page. This string is compared with records in database and displays on the screen. In my case I am performing this operation on Account object. I dont know why when I type input string(say industry type) in the input box created using Visualforce page and hit "Go!" button  the list of records dont populate in the table declared in visualforce code. Kindly suggest the changes needed.

VisualForce Code
<apex:page controller="search_accounts" >
<apex:form >
    <apex:pageBlock title="Account Search">
    <apex:inputText value="{!input_text}" />
    <apex:commandButton value="Go!"/>
    <apex:pageBlockTable value="{!search_result}" var="a">
        <apex:column value="{!a.Name}"/>
        <apex:column value="{!a.Type}"/>
        <apex:column value="{!a.Industry}"/>
        <apex:column value="{!a.Phone}"/>
    </apex:pageBlockTable>  
    </apex:pageBlock>
</apex:form>  
</apex:page>

Custom controller
public class search_accounts
{
    public string input_text;
    public list<Account> search_result;
    
    public string getinput_text()
    {
        return input_text;
    }
    public list<Account> getsearch_result()
    {
        return search_result;
    }
    
    public void setinput_text(string s)
    {
        input_text=s;
    }
    public PageReference Go()
    {
        search_result=[select Name, Type, Industry, Phone from Account Where Industry=:input_text];
        return NULL;
    }
}

 
When I load any visual flows in my org I get a load error. Most of the time it won't open the flow though sometimes it does get through on the oldest version I have available.

I tried opening a case per the instructions on the error but was bounced to this forum as it's out of scope for standard support. I'm not sure where to look to modify/deactivate/delete the invocable actions that might cause the failure.

Total failure to open

Load failure though successfully opened flow
 
Please help!  I am stuck on creating flows.  Can't seem to work.  I keep on re-doing my work and not sure if I am doing it right.  The challlenge as follows:

To pass this challenge you will need to create a flow that implements the business process of Account, Contact, and Opportunity data entry and place it on a Visualforce page.The Flow will need to be called 'New Customer Flow'.
The Flow should have a screen with fields for First Name, Last Name, Company Name, Opportunity Amount, and Opportunity Stage.
The Flow needs to have steps to create an account, a contact, and an opportunity from the data entered.
Opportunity name, close date and stage are required fields. Name the Opportunity '{Company Name} - {Last Name}', set the close date to one month from today and set the stage to 'Prospecting'.
The Flow should be invoked from a Visualforce page.
The Visualforce page should be called FlowPage.
The Visualforce page will need a component to reference the 'New Customer Flow' process.

If possible, if you can provide a snapshot.

Thank you.
I have been able to get similar ones to work (based on prior challenges) but I am struggling here.  Probably a newbie mistake somewhere.  Any help would be appreciated!  Thanks, Aron

-> Page (Gives Error: Unknown property 'String.Id error)

<apex:page controller="NewCaseListController">
    <apex:form >
        <apex:pageBlock title="Case List" id="Case_list">
            <!-- Case_list -->
         <apex:repeat value="{!Case}" var="case">
            <apex:outputLink value="{!Case.Id}">{!Case.Id}</apex:outputLink>
            <apex:outputLink value="{!case.CaseNumber}">{!case.CaseNumber}</apex:outputLink>
        </apex:repeat>      
        </apex:pageBlock>
    </apex:form>
</apex:page>

-> Class

ublic class NewCaseListController {

    public String getCase() {
        return null;
    }


    public String getCases() {
        return null;
    }

private String sortOrder = 'CaseNumber';
public List<Case> getNewCases() {
    List<Case> results = Database.query(
        'SELECT Id, CaseNumber ' +
        'FROM Case ' +
        'WHERE Status = New ' +
        'ORDER BY ' + sortOrder + ' ASC ' +
    );
    return results;
    }
}

This is the trigger erroHI  this code makes me hell..
This is the trigger code on my opportunity but throwing above exception can you please help me... Let me give you detail explination.

I am new to triggers..the trigger is when I insert an opportunity a new opportunity should be created automatically on the opportunity  I write the trigger is below..but it is throwing exception as screen shot..

 

trigger new_oppy on Opportunity (after insert)
{  
    
    if(Trigger.isinsert)
    {
        opportunity o=new opportunity();
        o.name = 'vamshi opportunity';
        o.closedate = date.today();
        o.StageName='closedwon';
        insert o;
    }

 

 

ERROR:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger wrehoue.new_oppy caused an unexpected exception, contact your administrator: wrehoue.new_oppy: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, wrehoue.new_oppy: maximum trigger depth exceeded Opportunity trigger event AfterInsert for [0069000000LVsuf] Opportunity trigger event AfterInsert for [0069000000LVsug] Opportunity trigger event AfterInsert for [0069000000LVsuh] Opportunity trigger event AfterInsert for [0069000000LVsui] Opportunity trigger event AfterInsert for [0069000000LVsuj] Opportunity trigger event AfterInsert for [0069000000LVsuk] Opportunity trigger event AfterInsert for [0069000000LVsul] Opportunity trigger event AfterInsert for [0069000000LVsum] Opportunity trigger event AfterInsert for [0069000000LVsun] Opportunity trigger event AfterInsert for [0069000000LVsuo] Opportunity trigger event AfterInsert for [0069000000LVsup] Opportunity trigger event AfterInsert for [0069000000LVsuq] Opportunity trigger event AfterInsert for [0069000000LVsur] Opportunity trigger event AfterInsert for [0069000000LVsus] Opportunity trigger event AfterInsert for [0069000000LVsut] Opportunity trigger event AfterInsert for [0069000000LVsuu]: []: Trigger.wrehoue.new_oppy: line 11, column 1