• OyeCode
  • NEWBIE
  • 159 Points
  • Member since 2011
  • Harshit Pandey


  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 84
    Replies

Hi I have a command link on a Visualforce page and I need to open another VF page as a popup window on click of the commnad link.

This is my Commnad link in the main VF page.

<apex:CommandLink Value="Select Product" onclick="window.open('/apex/oppprdpage?id={!as.lnkass.SalesOpportunityId__c}')"/>

Right now, on click of this link the new page is opening as a new tab but I need to open the new VF page as a popup window. Is there any way that I can achieve this?  (Basically I am trying to replicate the standard lookup window).


Thank You in advance for your help!!

 

Regards,

Sravan.

Hi everyone,
So i have to display 70,000+ Account records in a VisualForce page, but governor limits do not allow more than 50,000 records per query. As a result, I am choosing to display 10 records sorted by alphabet order and allowing users to press the next and previous button to get either the next 10 Account records or previous 10 Account records.

How would I implement this?
  • January 16, 2014
  • Like
  • 0
Hi I have a SQL query that I want to setup through SalesForce, it querys where someDate >= (date manipulation to get last monday to last sunday).

I want to query the same way on salesforce and im not sure how I can win the existsing Date Functions available. 

I wanted to use LAST_WEEK but that gets me sunday - saturday which isn't what I wanted, I was hoping do something like:

where someDate >= LAST_WEEK + 1 AND where someDate >= LAST_WEEK + 6

Is this possible? 

thanks

Hi, I am at a loss of words for how dumb I feel asking this simple question. I have an array of product Id's in list form:

 

[01t700000017VVBAA2, 01t700000017VVBAA2, 01t300000000OIDAA2, 01t70000002KgcDAAS]

 

That comes out when I print the list:

 

List<Product2> returnProducts = new List<Product2>();

 

using this visual force code:

 

<apex:outputText value="{!Products}" />

 

How do I convert returnProducts into a list of products.. because right now i just have their ID's

 

aka, I want to be able to pull stuff in visual force like

 

<apex:outputText value="{!Products.Name}" />


<apex:outputText value="{!Products.Id}" />

 

Stuff like that?

This my Trigger code. What should the test class be for this for coverage?

 

trigger closedWonOppt on Opportunity (after Update)
{
    Opportunity opp = trigger.new[0];
    String oppId = opp.id;
    System.debug('oppId'+oppId);
    System.debug('in trigger');
    if(opp.StageName == 'Closed Won')
    {
        System.debug('in if');
        ACL__c acl = new ACL__c();
        Datetime today = datetime.now();
        Integer year = today.year();
        
        Opportunity opp1=[SELECT Name, Account.Name,Account.Id, RecordType.Name FROM Opportunity 
        where id = :oppId];
         
        acl.Name = opp1.Account.Name + ' - ' + opp1.RecordType.Name + ' - ' + String.valueOf(year);
        acl.Opportunity__c = opp1.Id;
        acl.account__C = opp1.Account.Id;
        // acl.Opportunity__c = opp1.Id;
         
        insert acl;
    }
}

I get this error while parson through this code- can anybody suggest me solution 

 

public class content {
    public String MTType;
    public String MTTitle;
    public List<String> body;
}






// JSON string that contains a Person object.
String JSONContent =
    '{"content":{'+
      '"MTType":"text/html",'+
      '"MTTitle":"Test Builder",'+
      '"body":['+
         '" <div id=\\"section_1\\" class=\\"mt-page-section\\"><span id=\\"Overview\\"></span><h2 class=\\"editable\\">Overview</h2>anslator to import test results into Odyssey Manager and a learning path is automatically created based on the results of the NWEA or state test.&nbsp;</p></div></div>",'+
         '{'+
          '  "@target":"toc",'+
          '  "#text":"<ol style=\\"list-style-type:none; margin-left:0px; padding-left:0px;\\"><li><span>1.</span> <a href=\\"#Overview\\" rel=\\"internal\\">Overview</a></li><li><span>2.</span> <a href=\\"#Building_an_Objective-Based_Test\\" rel=\\"internal\\">Building an Objective-Based Test</a><ol style=\\"list-style-type:none; margin-left:0px; padding-left:15px;\\"><li><span>2.1.</span> <a href=\\"#What_are_Learning_Paths.3F\\" rel=\\"internal\\">What are Learning Paths?</a></li></ol></li></ol>"'+
         '}'+
      ']'+
   '}'+
'}';
JSONParser parser = 
   JSON.createParser(JSONContent);
// Make calls to nextToken() 
// to point to the second
// start object marker.
parser.nextToken();
parser.nextToken();
parser.nextToken();
// Retrieve the Person object
// from the JSON string.
System.Debug('Json Content'+JSONContent);
content obj = 
   (content)parser.readValueAsStrict(content.class);
System.assertNotEquals(
   obj.body, NULL);
//System.Debug(obj.body[0]);
parser.skipChildren();  

 

 

I installed Eclipse Juno 4.2 and found force.com plugin in not compatible. I followed the steps below to fix this  as I mentioned in my blog 

 

http://www.oyecode.com/2013/03/how-to-install-forcecom-plugin-with.html

 

I lately learned that Eclipse keep on forgetting password and pops up window asking for Login Credential with every file I open. Can any body please advice 

 

 

How do I assert these cases

 

1. X > y    2. X!=Y 3. X>=Y  4.   0 < X < 10

 

Please advise

Can anyone plese advice what wrong in here

 

 

 Map<Id, List<ContactRoleCount__c>> contactRoleMap = new Map<Id, List<ContactRoleCount__c>>();
      List<ContactRoleCount__c> contactRolesList = new List<ContactRoleCount__c> ([SELECT ContactRoleCount__c from Opportunity where OpportunityId in : trigger.newmap.keyset() order by opportunityid]);
    // Iterate and poopulate the Map 
    for(ContactRoleCount__c crc: contactRoleMap)
    {
        //populate the list by fetching value from the map 
        List<ContactRoles__c> cr = contactRoleMap.get(crc.ContactRole__c);
           if (cr == null) {
                cr = new List<Service_Request__c>();
                contactRoleMap.put(crc.ContactRole__c, cr);
            }
            cr.add(crc); // add to the list 
    }

 

Error code

 

 Error: Compile Error: No such column 'opportunityid' on entity 'Opportunity'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name
Hi, new to batch Apex and got question on Apex Scheduler vs. Batch Apex. I use the term "apex scheduler" to refer to class that implements "Schedulable" interface and "Batch Apex" for class that implements "Database.Batchable" interface.

What's the difference between these two? For example, I can create class that implements "Schedulable" interface, and I would have batch job (use the "Schedule Apex" page to run the batch job). I don't need to create batch Apex class (class that implements "Database.Batchable" interface), which seems to be complex to use. Anyone could shed some light ;> ? Thanks in advance.
I have some object oriented programming class experience (3 semesters of VB6 back in the day), so consider me a noob. I want to find the single most effective way to get me on my way to learning APEX code (also, tying in with APIs, integrating systems with SFDC, etc.). 

Should I take a Java class?  Should I take C#?  C++?  Java or C# for Dummies?

Salesforce itself suggests taking its tutorials, etc., and I have, but they aren't what I'm looking for. I need something that can explain to me every piece and part of code until it makes sense.  
  • January 16, 2014
  • Like
  • 0
Afternoon,

I need soql help...
My requirements are as follows:

1. Check if it is in a North American Territory (including mid market)

2. If it is:   

a. Look at the Primary QSL.Assigned To field

b. Check that it matches the RSD/RSM on the Lead.Territory - Where im having the most trouble on how to do this

c. If there is a mismatch, display an error message "Please update the lead owner to the correct queue. If this is a PRM lead or you need help, contact salesops@imperva.com."

Below is the code i have but just looking i know its not working. I cant figure how to get my select statements correct. Can anyone help...

// North America Territory assignment
     if (this.lead.Territory__c.Name == 'NA -*'){
     
      RSD = [Select ID,Regional_Sales_Director__c.Name from Territory__c where ID := ];
      primeQ = [Select ID, Assigned_To__c.Name From QSL_Review_Request__c Where ID := ];
     
      if (RSD <> primeQ){
       addError('Please update the lead owner to the correct queue. If this is a PRM lead or you need help, contact salesops@imperva.com');
       isValid = false;
      
      }
     
     }

Hi I have a command link on a Visualforce page and I need to open another VF page as a popup window on click of the commnad link.

This is my Commnad link in the main VF page.

<apex:CommandLink Value="Select Product" onclick="window.open('/apex/oppprdpage?id={!as.lnkass.SalesOpportunityId__c}')"/>

Right now, on click of this link the new page is opening as a new tab but I need to open the new VF page as a popup window. Is there any way that I can achieve this?  (Basically I am trying to replicate the standard lookup window).


Thank You in advance for your help!!

 

Regards,

Sravan.

Hi all,

I'm having issues with mass editing from list views while using the static variable trick to control recursive triggers. I dislike this new message format so I've switched over to stackexchange. Please have a look at my full detailed question witch flow and code snippets:

http://salesforce.stackexchange.com/questions/24307 (http://salesforce.stackexchange.com/questions/24307/how-do-i-control-recursive-triggers-with-static-variables-and-permit-mass-edit-f)
  • January 16, 2014
  • Like
  • 1
I am trying to create a scheduled job to do this but having trouble referencing the contact from the related opportunity.
Hi everyone,
So i have to display 70,000+ Account records in a VisualForce page, but governor limits do not allow more than 50,000 records per query. As a result, I am choosing to display 10 records sorted by alphabet order and allowing users to press the next and previous button to get either the next 10 Account records or previous 10 Account records.

How would I implement this?
  • January 16, 2014
  • Like
  • 0
Hi,
With the recent enhancement to allow a formula field to resolve to a checkbox, we thought it might make sense to eliminate some workflows that do the same thing via Field Updates for checkbox fields in our current configuration and replace them with Formula fields whose output is a checkbox true/false value.

Anyone have some general advice on Formula versus Workflow Rules and when it makes sense to use one over the other?  One concern I have about switching from WFR to Formulas for this scenario is how the Formula field approach will affect report performance if the formula checkbox field is used as a filter criteria.

Thanks for any input you may have!
  • January 16, 2014
  • Like
  • 0
Hi I have a SQL query that I want to setup through SalesForce, it querys where someDate >= (date manipulation to get last monday to last sunday).

I want to query the same way on salesforce and im not sure how I can win the existsing Date Functions available. 

I wanted to use LAST_WEEK but that gets me sunday - saturday which isn't what I wanted, I was hoping do something like:

where someDate >= LAST_WEEK + 1 AND where someDate >= LAST_WEEK + 6

Is this possible? 

thanks
Hello,

I have following trigger that validate some field's value before Opportunity Won and specific profile can revoke this trigger validation.
It works fine as expected but struggling to get 100% test code coverage on the .addError method

Can someone help me here?

Thanks,

Trigger:

trigger validSchedule on Opportunity (before update) {
   
    List<Id> oppsIDs = new List<Id>();  
  
        Id distributionId = '00e200000';
        for(Opportunity opp : Trigger.new) {
            if(opp.StageName == 'Confirmation') {
                oppsIds.add(opp.Id);               
            }           
        }       
            List<OpportunityLineItem> oli = [Select Id, Schedule_start_date__c, Contract_start_date__c, HasRevenueSchedule from OpportunityLineItem where Opportunity.Id in :oppsIds];           
            if(oli.size() > 0) {               
                for (OpportunityLineItem olis : oli) {  
                    if(olis.Schedule_start_date__c < olis.Contract_start_date__c && olis.HasRevenueSchedule == true
                      && UserInfo.getProfileId() != distributionId) {
                        Trigger.new[0].addError('My ERROR Message');  /* Does not get the code coverage */
                    }
              }
       }
}

Test Class:

@isTest(SeeAllData=true)
private class validScheduleTest{

    static testMethod void myUnitForvalidScheduleTest() {
      Pricebook2 pb = [Select Id, Name From Pricebook2 Where IsStandard = true Limit 1];
       
       Account act = [SELECT Id from Account LIMIT 1];      
       
        // Create a test Opportunity for the Subscription contract
        Opportunity o  = new Opportunity();
        o.Name         = 'TEST valid Contract';
        o.AccountId    = act.Id;
        o.CloseDate    = Date.today();
        o.StageName    = 'Interest';      
        insert o;

        // Create a test product2
        Product2 p = new Product2();
        p.Name     = 'TEST valid Sub';
        p.CanUseRevenueSchedule = true;
        p.NumberOfRevenueInstallments = 2;

        insert p;
       
        // Create a test pricebook entry.
        PricebookEntry pbe = new PricebookEntry();
        pbe.Pricebook2Id = pb.id;
        pbe.Product2Id   = p.id;       
        pbe.IsActive     = true;
        pbe.UnitPrice    = 500.00;
       
        insert pbe;
       
        // Create a test Opportunity line item
        OpportunityLineItem i = new OpportunityLineItem();
        i.opportunityId       = o.id;
        i.pricebookentryid    = pbe.id;
        i.quantity            = 1;
        i.TotalPrice = 1000.00;
        i.ServiceDate = Date.today();
        insert i;
       
        OpportunityLineItemSchedule[] OliSchInsert = new OpportunityLineItemSchedule[]{};
            Date curDate = Date.today().addDays(-2);
            for(Integer x=0; x < 3; x++) {
             OpportunityLineItemSchedule OliSchIn = new OpportunityLineItemSchedule();
                OliSchIn.OpportunityLineItemId = i.Id;
                OliSchIn.Revenue = 500.00;
                OliSchIn.Type = 'Revenue';
                OliSchIn.ScheduleDate = curDate;
               
                OliSchInsert.add(OliSchIn);
               
                curDate = Date.today().addMonths(2);               
            }
         insert OliSchInsert;      
       
        o.StageName = 'Confirmation';
        try{
            update o;
         }
         catch(Exception ex){
             Boolean expectedExceptionThrown =  ex.getMessage().contains('My Error Message') ? true : false;
                System.AssertEquals(expectedExceptionThrown, true);
         }
     }
}
What's the cost of using dynamic soql over standard soql queries. Is there any measurable difference between doing:

<pre>Database.query('select Id from Contact where Id=:contact_id'); </pre> 

vs

<pre>[select Id from Contact where Id=:contact_id' ]; </pre>

If there is a performance difference, does the penalty increase with complexity of queries? 

Today we’re excited to announce the new Salesforce Developers Discussion Forums. We’ve listened to your feedback on how we can improve the forums.  With Chatter Answers, built on the Salesforce1 Platform, we were able to implement an entirely new experience, integrated with the rest of the Salesforce Developers site.  By the way, it’s also mobile-friendly.

We’ve migrated all the existing data, including user accounts. You can use the same Salesforce account you’ve always used to login right away.  You’ll also have a great new user profile page that will highlight your community activity.  Kudos have been replaced by “liking” a post instead and you’ll now be able to filter solved vs unsolved posts.

This is, of course, only the beginning  and because it’s built on the Salesforce1 Platform, we’re going to be able to bring you more features faster than ever before.  Be sure to share any feedback, ideas, or questions you have on this forum post.

Hats off to our development team who has been working tirelessly over the past few months to bring this new experience to our community. And thanks to each of you for helping to build one of the most vibrant and collaborative developer communities ever.
 

Hi - we have just gone live with SF Partner Portal and have partners creating opps - however, we would like a specific campaign to be populated on creation.

 

I have found that I am not able to do this using standard workflow, and I would like to avoid apex coding as we do not have a developer on board.  I have been looking at using a custom 'new' button to pre-populate the field but I can't get this to work, so far I have:

 

https://eu1.salesforce.com/006/e?opp17_lkid=701D0000000ttOD 

 

Of course this is assuming that I can hide the list view button, if not any advice on the code needed?

 

Any help much appreciated, many thanks.

  • January 15, 2013
  • Like
  • 0

I'm going through the Visualforce Developer's guide and trying to get my head around how to begin our app.  Right now im looking at $CurrentPage and what all can be done with that.  This is from the documentation:

 

"Using $CurrentPage you can access the query string parameters for the page by specifying the parameters attribute, after which you can access each individual parameter"

 

The example references id and cid.  What are the other parameters?  Is there a piece of documentation with a list of all the individual parameters for $CurrentPage?

 

I'm trying to get this to work...

<apex:page standardController="Account" showHeader="true" tabStyle="account" > {!$CurrentPage.parameters.tabFocus} <br/><br/> <apex:tabPanel switchType="client" escape="false" selectedTab="{!$CurrentPage.parameters.tabFocus}" id="tabPanel" > <apex:tab label="Details" name="AccDetails" id="tabdetails"> <apex:detail relatedList="false" title="true"/> </apex:tab> <apex:tab label="Contacts" name="Contacts" id="tabContact" > <apex:relatedList subject="{!account}" list="contacts" /> </apex:tab> </apex:tabPanel> </apex:page>

 ...by requesting this URL: https://c.cs1.visual.force.com/apex/TabbedAccount?id=15DigitAccountId&tabFocus=Contacts

I know {!$CurrentPage.parameters.tabFocus} works, because it displays "Contacts".
And the selectedTab attribute works great if I hard-code it to "Contacts".

But the combo does nothing. Is this disabled because of Cross site scripting attacks? Or am I missing something? Any help appreciated.

At the end of the day, I'm trying to set the focus of a tab in a tab panel in this VF page when returning from a different page in the app.

Thanks,

cb
Message Edited by Chris Barry on 03-18-2009 12:10 PM