• Anjuna
  • NEWBIE
  • 85 Points
  • Member since 2015

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 19
    Replies
Hey All, 

I am trying to get a visualforce page to reference the "My Opportunities" view in salesforce.  I am doing a list view on the left and a page view of the opportunity on the right.  But, I only want it to view the opportunities that are associated to the owner opening the visualforce page. 

The left, list of opportunities should only be those belonging to the logged in user

Here is my current code.





<apex:page standardController="Opportunity" recordSetVar="ops" sidebar="false">
<apex:form >
    <apex:pageBlock >
    <apex:pageBlockSection >
    <apex:pageBlock Title="List of Opportunities">
        <apex:pageblockTable value="{!ops}" var="o">
            <apex:column >
                <apex:commandLink value="{!o.Name}" reRender="refresharea">
                    <apex:param name="OpportunityID" value="{!o.ID}"/>
                    <apex:param name="OpportunityName"  value="{!o.Name}" />
                    </apex:commandLink>             
            </apex:column>
            <apex:column value="{!o.Amount}"/>
            <apex:inlineEditSupport />
            <apex:column value="{!o.StageName}"/>
            <apex:column value="{!o.Closedate}"/>

        </apex:pageBlockTable>
    </apex:PageBlock>
    
    <apex:pageBlock title="{!$CurrentPage.parameters.OpportunityName}" id="refresharea">
        <apex:detail subject="{!$CurrentPage.parameters.opportunityID}" relatedList="false"/>
    </apex:pageBlock>
    </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>


Any help would be appreciated.  I am fairly new at this.  Thanks
 
Hi,

What am I missing fro this test class to get the % code coverage up.

I am an admin and have the below trigger which after an opportunity is set to won will update the contact role.  Its a bit long winded but what it does is count the type of product thats selected on the opportunity and then update the corresponding checkbox on the contact role once the opportunity is set to won

TRIGGER
trigger UpdateContactProduct on Opportunity (after update) {

   Set<Id> st_OppId = new Set<Id>();
List<Contact> con_List;

for(Opportunity opp :Trigger.new)
  {
     if(opp.StageName=='Won' )
         st_OppId.add(opp.id);
 }

if(st_OppId!=null && !st_OppId.isEmpty())
    {

         for(OpportunityContactRole iterating_oppConRole : [SELECT Role, 
                                                                      OpportunityId, 
                                                                      IsPrimary, 
                                                                      Id, 
                                                                      ContactId,
                                                                      Contact.Lead_Lifecycle_Stage__c ,
                                                                      Contact.X1Edit_bought__c, 
                                                                      Contact.X1Exchange_bought__c,         
                                                                      Opportunity.Count_1Edit__c,
                                                                      Opportunity.Count_1Exchange__c,
                                                                   FROM OpportunityContactRole  where OpportunityId IN : st_OppId])
                               {

                    if(iterating_oppConRole.Opportunity.Count_1Edit__c > 0)
                        {
                              iterating_oppConRole.Contact.X1Edit_bought__c = true;
                        }
                                             
                    if(iterating_oppConRole.Opportunity.Count_1Exchange__c> 0)
                        {
                              iterating_oppConRole.Contact.X1Exchange_bought__c = true;
                        }
                                           if(con_List == null)
                                           con_List = new List<Contact>();

                                          con_List.add(iterating_oppConRole.Contact);
                                }

               
           }
        
        if(con_List!=null && !con_List.isEmpty())
            update con_List;
}

TEST CLASS
@IsTest

Public Class testAddProductsBought
 {
    static testMethod void ValidateContactProduct()
    {
    
    Account a = new Account();
    a.Name ='demo';
    a.Industry = 'Education';
    a.BillingCountry = 'United Kingdom';
    insert a;
    
    
    Contact c = new Contact();
    c.FirstName = 'Lord';
    c.LastName = 'Test2';
    c.Accountid = a.id; 
    c.RecordTypeid = '012w000000063q6AAA';
    insert c;
    
    
    Contact ci = new Contact();
    ci.FirstName = 'Bob';
    ci.LastName  = 'Test';
    ci.AccountId = a.id;
    ci.RecordTypeid = '012w000000063q6AAA';
    insert ci;
    
    
    Opportunity o = new Opportunity();
    o.AccountId = a.Id;
    o.StageName = 'Won';
    o.RecordTypeid = '012w0000000ic3mAAA';
    o.Final_Price_Number__c = 2000;
    o.Business_Unit__c = '1Spatial United Kingdom';
    o.Name = 'Test';
    o.Opportunity_Type__c = 'Contract Renewal';
    O.CurrencyIsoCode ='GBP';
    o.Contract_Type__c = 'Framework';
    o.Estimated_Value_Number__c = 10000;
    o.Opportunity_Submission_Date__c = Date.TODAY();
    o.CloseDate = Date.TODAY() +2;
    o.Probability__c = '80-99%';
    o.Purchase_Order__c = '2L3454';
    o.Solution_Summary__c = 'Hardware';
    o.Description = 'Update Contact role';
    o.Opportunity_Process_Stage__c= 'Opportunity Submitted to Customer: Approved`';
    o.Ownerid = '005w0000004ExSiAAK';
    insert o;
    
        
     OpportunityContactRole cr = new OpportunityContactRole();
     cr.Opportunityid = o.id;
     cr.Role = 'Administrator';
     cr.Contactid = c.id;
     cr.IsPrimary = true;
     insert cr;
     
     OpportunityContactRole ocr1 = new OpportunityContactRole();
     ocr1.ContactId = ci.Id;
     ocr1.OpportunityId = o.Id;
     ocr1.IsPrimary = FALSE;
     ocr1.Role = 'Decision Maker';
     insert ocr1;
     
    
     Id pricebookId = Test.getStandardPricebookId();
     Product2 prod = new Product2();
     prod.Name = 'Product 2';
     prod.ProductCode = 'Pro-2';
     prod.isActive = true;
     prod.Revenue_Type__c = 'Services';
     prod.Product_Heading__c = '1Edit';
     insert prod;

     PricebookEntry pbEntry = new PricebookEntry();
     pbEntry.Pricebook2Id = pricebookId;
     pbEntry.Product2Id = prod.Id;
     pbEntry.UnitPrice = 100.00;
     pbEntry.IsActive = true;
     insert pbEntry;

     OpportunityLineItem oli = new OpportunityLineItem();
     oli.OpportunityId = o.Id;
     oli.quantity = 1;
     oli.PricebookEntryId = pbEntry.Id;
     oli.TotalPrice = oli.quantity * pbEntry.UnitPrice;
     insert oli;

    o.StageName = 'Won';
    update o;
    update cr;

}
}
  • February 22, 2017
  • Like
  • 0
Hello,

I have a VF page which displayes date like below
2016/12/19 14:34:54 GMT
But i want to display like 2016/12/19

Thank you for suggestion !
I have samll clarifications how to use  Map<string,list<Date>> like that?
My scenario is :i have two fields Dealer number,Date from soql query i got the values below that.
Date ------     Dealer number
10/02/2017    10100
15/01/2017    10100
02/02/2017    10100

01/02/2017    10101
05/02/2017    10101
10/01/2017    10102
31/01/2017    10102

I want output based on Dealer number.see one Dealer having different dates.this Dealer 10100 having 3 different dates,Month of JAN(count is 1) and Month Feb(count is 2).count is calucuted based on same month based. 
output should be:

Dealer-----FebMonth(Count)-----JanMonth(Count)
10100 ----------------2-----------1

please guide me how to achive this scenario?

Advanced thanks
Hi Guys!

Can someone assist me on how can I get the contact record sorted (Descending -> Proficiency) and (Ascending -> Skill Type) based on my query below. 

Employee Skills, Training and Certifications has a lookup relationship with Contact (Employee).

SELECT Name, Email
, (SELECT Skill_ID__r.Name, Proficiency__c, Year_of_Experience__c, Skill_Type__c FROM Employee_Skills__r)
, (SELECT Training_ID__r.Name FROM Employee_Training__r)
, (SELECT Certification_ID_r.Name FROM Employee_Certifications__r)
FROM Contact

Thank you! 
Hi, 

Appreciate any help. We can't deploy our Apex class and trigger as some of the existing Apex test are failing. I believe it is required to run test on all classes. Any way around this? The failed test consists of both managed scripts and custom scripts created on our first implementation of Salesforce by a vendor. How can I find out if there's any impact if we remove these scripts?
Hi, Can anyone please let me know what will be the SOSL query for querying all email ids with gmail.com domain name.

Thanks.
Hey All, 

When using this apex class 
public class MyOpportunityController3{
    public List<Opportunity> oppList{get;set;}
    public MyOpportunityController3(ApexPages.StandardSetController controller) {
        oppList = new List<Opportunity>();
        for(Opportunity opp : [SELECT id,name,amount,stagename,closedate,ownerid FROM Opportunity
                                WHERE owner.id=:userinfo.getuserid() AND isClosed=False]) {
            oppList.add(opp );
        }
    }

}

It does not pull in the open opportunities when I tie it to an embedded VF page.  The VFP pulls in all opportunities.  I am not sure what I am missing here.  THe VF code is below.  Any assistance would be appreciated!
 
<apex:page standardController="Opportunity" recordSetVar="ops" sidebar="false" extensions="MyOpportunityController3">
<apex:form >
               
    <apex:pageBlock >
    <apex:pageBlockSection >
    <apex:pageBlock Title="List of Opportunities">
        <apex:pageblockTable value="{!ops}" var="o">
       
            <apex:column >
                <apex:commandLink value="{!o.Name}" reRender="refresharea">
                    <apex:param name="OpportunityID" value="{!o.ID}"/>
                    <apex:param name="OpportunityName"  value="{!o.Name}" />
                    </apex:commandLink>             
            </apex:column>
            <apex:column value="{!o.Amount}"/>
            <apex:column value="{!o.StageName}"/>
            <apex:column value="{!o.Closedate}"/>
        <apex:inlineEditSupport event="ondblClick"
            showOnEdit="saveButton,cancelButton" hideOnEdit="editButton"/>

        </apex:pageBlockTable>
      
        <apex:pageBlockButtons >
            <apex:commandButton value="Edit" action="{!save}" id="editButton"/>
            <apex:commandButton value="Save" action="{!save}" id="saveButton"/>
            <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton"/>
        </apex:pageBlockButtons>
        
    </apex:PageBlock>
    
    <apex:pageBlock title="{!$CurrentPage.parameters.OpportunityName}" id="refresharea">
        <apex:detail subject="{!$CurrentPage.parameters.opportunityID}" relatedList="false"/>
    </apex:pageBlock>
    </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

 
Hey All, 

I am trying to get a visualforce page to reference the "My Opportunities" view in salesforce.  I am doing a list view on the left and a page view of the opportunity on the right.  But, I only want it to view the opportunities that are associated to the owner opening the visualforce page. 

The left, list of opportunities should only be those belonging to the logged in user

Here is my current code.





<apex:page standardController="Opportunity" recordSetVar="ops" sidebar="false">
<apex:form >
    <apex:pageBlock >
    <apex:pageBlockSection >
    <apex:pageBlock Title="List of Opportunities">
        <apex:pageblockTable value="{!ops}" var="o">
            <apex:column >
                <apex:commandLink value="{!o.Name}" reRender="refresharea">
                    <apex:param name="OpportunityID" value="{!o.ID}"/>
                    <apex:param name="OpportunityName"  value="{!o.Name}" />
                    </apex:commandLink>             
            </apex:column>
            <apex:column value="{!o.Amount}"/>
            <apex:inlineEditSupport />
            <apex:column value="{!o.StageName}"/>
            <apex:column value="{!o.Closedate}"/>

        </apex:pageBlockTable>
    </apex:PageBlock>
    
    <apex:pageBlock title="{!$CurrentPage.parameters.OpportunityName}" id="refresharea">
        <apex:detail subject="{!$CurrentPage.parameters.opportunityID}" relatedList="false"/>
    </apex:pageBlock>
    </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>


Any help would be appreciated.  I am fairly new at this.  Thanks
 
Hi,

What am I missing fro this test class to get the % code coverage up.

I am an admin and have the below trigger which after an opportunity is set to won will update the contact role.  Its a bit long winded but what it does is count the type of product thats selected on the opportunity and then update the corresponding checkbox on the contact role once the opportunity is set to won

TRIGGER
trigger UpdateContactProduct on Opportunity (after update) {

   Set<Id> st_OppId = new Set<Id>();
List<Contact> con_List;

for(Opportunity opp :Trigger.new)
  {
     if(opp.StageName=='Won' )
         st_OppId.add(opp.id);
 }

if(st_OppId!=null && !st_OppId.isEmpty())
    {

         for(OpportunityContactRole iterating_oppConRole : [SELECT Role, 
                                                                      OpportunityId, 
                                                                      IsPrimary, 
                                                                      Id, 
                                                                      ContactId,
                                                                      Contact.Lead_Lifecycle_Stage__c ,
                                                                      Contact.X1Edit_bought__c, 
                                                                      Contact.X1Exchange_bought__c,         
                                                                      Opportunity.Count_1Edit__c,
                                                                      Opportunity.Count_1Exchange__c,
                                                                   FROM OpportunityContactRole  where OpportunityId IN : st_OppId])
                               {

                    if(iterating_oppConRole.Opportunity.Count_1Edit__c > 0)
                        {
                              iterating_oppConRole.Contact.X1Edit_bought__c = true;
                        }
                                             
                    if(iterating_oppConRole.Opportunity.Count_1Exchange__c> 0)
                        {
                              iterating_oppConRole.Contact.X1Exchange_bought__c = true;
                        }
                                           if(con_List == null)
                                           con_List = new List<Contact>();

                                          con_List.add(iterating_oppConRole.Contact);
                                }

               
           }
        
        if(con_List!=null && !con_List.isEmpty())
            update con_List;
}

TEST CLASS
@IsTest

Public Class testAddProductsBought
 {
    static testMethod void ValidateContactProduct()
    {
    
    Account a = new Account();
    a.Name ='demo';
    a.Industry = 'Education';
    a.BillingCountry = 'United Kingdom';
    insert a;
    
    
    Contact c = new Contact();
    c.FirstName = 'Lord';
    c.LastName = 'Test2';
    c.Accountid = a.id; 
    c.RecordTypeid = '012w000000063q6AAA';
    insert c;
    
    
    Contact ci = new Contact();
    ci.FirstName = 'Bob';
    ci.LastName  = 'Test';
    ci.AccountId = a.id;
    ci.RecordTypeid = '012w000000063q6AAA';
    insert ci;
    
    
    Opportunity o = new Opportunity();
    o.AccountId = a.Id;
    o.StageName = 'Won';
    o.RecordTypeid = '012w0000000ic3mAAA';
    o.Final_Price_Number__c = 2000;
    o.Business_Unit__c = '1Spatial United Kingdom';
    o.Name = 'Test';
    o.Opportunity_Type__c = 'Contract Renewal';
    O.CurrencyIsoCode ='GBP';
    o.Contract_Type__c = 'Framework';
    o.Estimated_Value_Number__c = 10000;
    o.Opportunity_Submission_Date__c = Date.TODAY();
    o.CloseDate = Date.TODAY() +2;
    o.Probability__c = '80-99%';
    o.Purchase_Order__c = '2L3454';
    o.Solution_Summary__c = 'Hardware';
    o.Description = 'Update Contact role';
    o.Opportunity_Process_Stage__c= 'Opportunity Submitted to Customer: Approved`';
    o.Ownerid = '005w0000004ExSiAAK';
    insert o;
    
        
     OpportunityContactRole cr = new OpportunityContactRole();
     cr.Opportunityid = o.id;
     cr.Role = 'Administrator';
     cr.Contactid = c.id;
     cr.IsPrimary = true;
     insert cr;
     
     OpportunityContactRole ocr1 = new OpportunityContactRole();
     ocr1.ContactId = ci.Id;
     ocr1.OpportunityId = o.Id;
     ocr1.IsPrimary = FALSE;
     ocr1.Role = 'Decision Maker';
     insert ocr1;
     
    
     Id pricebookId = Test.getStandardPricebookId();
     Product2 prod = new Product2();
     prod.Name = 'Product 2';
     prod.ProductCode = 'Pro-2';
     prod.isActive = true;
     prod.Revenue_Type__c = 'Services';
     prod.Product_Heading__c = '1Edit';
     insert prod;

     PricebookEntry pbEntry = new PricebookEntry();
     pbEntry.Pricebook2Id = pricebookId;
     pbEntry.Product2Id = prod.Id;
     pbEntry.UnitPrice = 100.00;
     pbEntry.IsActive = true;
     insert pbEntry;

     OpportunityLineItem oli = new OpportunityLineItem();
     oli.OpportunityId = o.Id;
     oli.quantity = 1;
     oli.PricebookEntryId = pbEntry.Id;
     oli.TotalPrice = oli.quantity * pbEntry.UnitPrice;
     insert oli;

    o.StageName = 'Won';
    update o;
    update cr;

}
}
  • February 22, 2017
  • Like
  • 0
Hello,

I have a VF page which displayes date like below
2016/12/19 14:34:54 GMT
But i want to display like 2016/12/19

Thank you for suggestion !
HI,

i have a apex class which will trigger some functionality and will sent some email on a single button click on contact table,so now i need to add a checkbox on the same contact table and if user checks the checkbox and clicks on the custom buttom, we need to add some URLs to it,is it possible?and that URLs we need to add it to the email even while sending,if check box is set it to true,else we dont need to include that URLs in that email.
Hello, 

I have a particular question where I can't seem to find any tangible examples on. 

I am writing a query like this but this is querying directly from the Contact table/object: 
 
string query = "?q=SELECT Id, Name, firstname , lastname, title, department , birthdate, phone , fax,  email, accountId, Account.Name, MailingStreet, MailingCity ,MailingState, MailingPostalCode, MailingCountry, OtherStreet,OtherCity,OtherState,OtherPostalCode,OtherCountry  from Contact";

What I want to do is query from the following: 

User-added image

I can't seem to find a way to query any of the items that are presented in the list. 

Is there a way if I can query these lists/tables/objects? I am unsure of what to call them at this point. 

If there is a way to query the object any code example would help me. 

Thank you.