• Suneel B 9
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 3
    Replies
Hwy guys,  I created a visual force page for Opportunities which contains a custom button and when we press that button it should navigate to another visual force page.
Can anyone help me.

this is the initial VF page:

<apex:page standardController="Opportunity">
<apex:sectionHeader title="Edit Opportunity" subtitle="{!opportunity.name}"/>

<apex:form >
<apex:pageBlock title="Opportunity Edit" helpTitle="Opportunity" helpUrl="Opportunity">
<apex:pageBlockButtons >
<apex:commandButton value="Next" onclick="OpenPage('google'); return false;"/>
When we press the next button it should navigate to another visual force page



</apex:pageBlockButtons>
<apex:pageBlockSection title="Opportunity Information" collapsible="false" >

<apex:outputText value="{!Opportunity.Owner}" 
label="Opportunity Owner"/>

<apex:inputField value="{!Opportunity.Amount}"
label="Amount"/>

<apex:inputCheckbox value="{!Opportunity.IsPrivate}"
label="Private"/>

<apex:inputField value="{!Opportunity.CloseDate}" required="true"
label="CloseDate"/>

<apex:inputField value="{!Opportunity.Name}" required="true"
label="Opportunity Name"/>

<apex:inputText value="{!Opportunity.NextStep}"
label="NextStep"/>
<apex:inputText value="{!Opportunity.Account}" 
label="Account Name"/>

<apex:inputfield value="{!Opportunity.StageName}" 
                 required="true" 
                 id="stage" 
                 onclick="changeblock();"/>
<apex:inputField value="{!Opportunity.Type}"
label="Type"/> 
<apex:inputField value="{!Opportunity.LeadSource}"
label="LeadSource"/> 

<apex:inputText value="{!Opportunity.Campaign}"
label="Primary Campaign Source"/>

<apex:inputText value="{!Opportunity.Rating__c}"
label="Rating"/>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>
</Apex:page>
 
Hello Guys, i have created an Opportunity page. Problme is for a new record if i change the stageName the probability is not changing. But its changing when i Edit the record. Do i need to write an Apex class or assign field dependency, Can anyone help me out please Below is the VF Page

<apex:page standardController="Opportunity">
<apex:sectionHeader title="Edit Opportunity" subtitle="{!opportunity.name}"/>

<apex:form >
<apex:pageBlock title="Opportunity Edit" helpTitle="Opportunity" helpUrl="Opportunity">


<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save" />
<apex:commandButton action="{!QuickSave}" value="QuickSave"/>
<apex:commandButton action="{!Cancel}" value="Cancel"/>

</apex:pageBlockButtons>


<apex:pageBlockSection title="Opportunity Information" collapsible="false" >

<apex:outputText value="{!Opportunity.Owner}" 
label="Opportunity Owner"/>

<apex:inputField value="{!Opportunity.Amount}"
label="Amount"/>

<apex:inputCheckbox value="{!Opportunity.IsPrivate}"
label="Private"/>

<apex:inputField value="{!Opportunity.CloseDate}" required="true"
label="CloseDate"/>

<apex:inputField value="{!Opportunity.Name}" required="true"
label="Opportunity Name"/>

<apex:inputText value="{!Opportunity.NextStep}"
label="NextStep"/>

<apex:inputText value="{!Opportunity.Account}" 
label="Account Name"/>

<apex:inputField value="{!Opportunity.StageName}"/>


<apex:inputField value="{!Opportunity.Type}"
label="Type"/> 

<apex:inputField value="{!Opportunity.Probability}"
label="Probability(%)"/>

<apex:inputField value="{!Opportunity.LeadSource}"
label="LeadSource"/> 

<apex:inputText value="{!Opportunity.Campaign}"
label="Primary Campaign Source"/>

<apex:inputText value="{!Opportunity.Rating__c}"
label="Rating"/>

</apex:pageBlockSection>

<apex:pageBlockSection title="Additional Information" collapsible="false">

<apex:inputfield value="{!Opportunity.OrderNumber__c}"
label="Order Number"/>

<apex:inputfield value="{!Opportunity.MainCompetitors__c}"
label="Main Competitor(s)"/>

<apex:inputField value="{!Opportunity.CurrentGenerators__c}"
label="CurrentGenerator(s)"/>

<apex:inputfield value="{!Opportunity.DeliveryInstallationStatus__c}"
label="Delivery Installation Status"/> 

<apex:inputField value="{!Opportunity.TrackingNumber__c}"
label="Tracking Number"/>

</apex:pageBlockSection>


<apex:pageBlockSection title="Description Information" collapsible="false">

<apex:inputField value="{!Opportunity.Description}" 
label="Description" />


</apex:pageBlockSection>

</apex:pageBlock>

</apex:form>
</Apex:page>
Hello guys, i am trying to create an opportunity for an account record only if the acoount record active is YES  and if active is no or the field is blank it has to throw an error. Below is the code, can you pelase help me out,

trigger oppactive on Opportunity (before insert) 
{
   set<id> accid = new set<id>();
   List<Opportunity> opp = trigger.new;
   Integer i;
   for(opportunity opp1:opp)
   {
     accid.add(opp1.Accountid);
     system.debug('Test 1'+accid);
   }
   List<opportunity> opp3 =  [select id, Name, opportunity.Accountid, opportunity.Account.Active__c from Opportunity where Accountid in: accid];
     for(opportunity opp2:opp3)
   {
      system.debug('Enter loop'+opp2);
      if(opp2.Account.Active__c =='No')
      {
        Trigger.new[0].adderror('Account must be active before creating an account');
        system.debug('test3'+opp2);
      }    
    }  
}
Hai guys i have created a custom field in account which shows the latest created opportinity in it. Now if i created a record s1 first and s2 next where s2 is the latest created record and it will display s2 in the custom field. Now if i delete s2 the last created would be s1 and s1 has to be displayed.
Now below is the program with after insert and after update i need after delete.
Can anyone help me out with this,
trigger OppUp on Opportunity (after insert,after update, after delete) 
{
  Set<Id> SetId = new set<Id>();
  map<id, Account> acmap = new map<id, Account>();
  for(Opportunity Opp: trigger.new)
  {
  SetId.add(Opp.Accountid);
  }
  
  List<Account> opplist = [SELECT id, OptyName__c,(Select id,Opportunity.Name,Opportunity.CreatedDate,Opportunity.AccountId FROM Account.Opportunities order by createddate) FROM Account where Id IN :SetId];
  
  for(Account Acc: opplist)
  {
     for(Opportunity opp: acc.opportunities)
     {
        acc.OptyName__c = opp.name;
        acmap.put(acc.id, acc);
     }
  }
   for(Opportunity Opp: trigger.old)
    {
    
 }

  update acmap.values();
 }
Hai all,
I am trying ti change ownership field to public when type is prospect in the account fiels using trigger, below is my program can you please help me out:

trigger oppinsert on Account (After insert) 

{
   set<id> accid = new set<id>();      
   List<Account> acc = Trigger.new;  
    
    for(Account accset1:acc)
    {
    if( accset1.Type == 'Prospect'){
     // accset1.Ownership = 'Public';
      
      accset1.Ownership.addError('Please select');
      
   }

 } 
    
    for(Account accset:acc)        
    {
       accid.add(accset.id);       
    }
    
    List<Account> acclst = [Select name,id from Account where id In:accid];  
    
   
 

    
    List <Opportunity> opp = new List<Opportunity>();     
    
          for (Account ac:acclst)                           
    {
     Opportunity o =new Opportunity();                
     o.Name = ac.Name;
     o.CloseDate = system.today();
     o.StageName = 'prospecting';
     o.Accountid = ac.id;
     opp.add(o);   
     }
    insert opp;
}
Hai guys i have created a custom field in account which shows the latest created opportinity in it. Now if i created a record s1 first and s2 next where s2 is the latest created record and it will display s2 in the custom field. Now if i delete s2 the last created would be s1 and s1 has to be displayed.
Now below is the program with after insert and after update i need after delete.
Can anyone help me out with this,
trigger OppUp on Opportunity (after insert,after update, after delete) 
{
  Set<Id> SetId = new set<Id>();
  map<id, Account> acmap = new map<id, Account>();
  for(Opportunity Opp: trigger.new)
  {
  SetId.add(Opp.Accountid);
  }
  
  List<Account> opplist = [SELECT id, OptyName__c,(Select id,Opportunity.Name,Opportunity.CreatedDate,Opportunity.AccountId FROM Account.Opportunities order by createddate) FROM Account where Id IN :SetId];
  
  for(Account Acc: opplist)
  {
     for(Opportunity opp: acc.opportunities)
     {
        acc.OptyName__c = opp.name;
        acmap.put(acc.id, acc);
     }
  }
   for(Opportunity Opp: trigger.old)
    {
    
 }

  update acmap.values();
 }
Hai all,
I am trying ti change ownership field to public when type is prospect in the account fiels using trigger, below is my program can you please help me out:

trigger oppinsert on Account (After insert) 

{
   set<id> accid = new set<id>();      
   List<Account> acc = Trigger.new;  
    
    for(Account accset1:acc)
    {
    if( accset1.Type == 'Prospect'){
     // accset1.Ownership = 'Public';
      
      accset1.Ownership.addError('Please select');
      
   }

 } 
    
    for(Account accset:acc)        
    {
       accid.add(accset.id);       
    }
    
    List<Account> acclst = [Select name,id from Account where id In:accid];  
    
   
 

    
    List <Opportunity> opp = new List<Opportunity>();     
    
          for (Account ac:acclst)                           
    {
     Opportunity o =new Opportunity();                
     o.Name = ac.Name;
     o.CloseDate = system.today();
     o.StageName = 'prospecting';
     o.Accountid = ac.id;
     opp.add(o);   
     }
    insert opp;
}

Hi,

 

 I have a visualforce page created with some fields and a button basically a command button. Now I want to navigate to another page on click of the button i.e x page has button, on click of which i want to load the browser with page y. How do i do that?

 

 

Thanks in Advance,

Ravindra