• CaptainObvious
  • SMARTIE
  • 1620 Points
  • Member since 2006

  • Chatter
    Feed
  • 56
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 306
    Replies
While writing a test class for a trigger handler I encountered a situation (while creating a new opportunity record) where the Account field on the opportunity, which is a lookup to the Account parent record, required me to use SOQL in the constructor rather than just assigning the account ID directly. Can anyone please explain why this is necessary for some lookups and not others? Here is the code that worked:

Opportunity newOpportunity = new Opportunity(
                                    CloseDate=date.Today(), 
                                    StageName='Quoted', 
                                    Name='Test Op', 
                                    Account=[SELECT Id FROM Account WHERE Id= :newAccount.Id]);
 
Hi Experts,

I really need some help here, I have a SOQL statement the grads a specific list of records and child records, but I need to edit the statement to only include those child records that are currently active, I have a check mark box called "Active" on the child record.

Here is my statment:

<soql>select LDC_Account_Number__c, meter_number__c from meter__c where ldc_account__c in (select id from ldc_account__c where opportunity__c='{!ServiceContract.opportunity__r.id}') order by ldc_account_number__c</soql>

meter__c is the child record
name of the field is Active__c

This is only my 5th SOQL statement, still learning, any assistance would be greatly appreciated. 

Thank-you

Hi there,

 

I'm not a developer, but am trying to accomplish something with an Onclick Javascript Button in Salesforce.com for educational purposes. I feel like I'm getting close, but I'm still failing.

 

The objective here is the following:

 

Upon clicking this Onclick Javascript Button on the opportunity record, the following actions will occur:

 

1. Update a checkbox on the opportunity

2. Create a related quote with the quote name field populated to "PQ"

3. Return to the opportunity record when complete

 

I have the following code, which is only accomplishing 1 and 3:

 

{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")} 

var update_Opp = []; /*Declaring an array to pass the parameters */ 
var oOpp= new sforce.SObject("Opportunity"); /* Declaring an object for the Case */ 
oOpp.Id='{!Opportunity.Id}'; /*setting the ID of the object to the Id of the current opp*/ 
oOpp. Quote_Requested__c = true; /* Setting the checkbox value as true */ 
update_Opp.push(oOpp); /*pushing the updated object in queue*/ 
result_Update=sforce.connection.update(update_Opp); /*updating the object*/ 
window.location.reload(); /* asking the page to refresh */ 

var newquote= new sforce.SObject("Quote"); 
newquote.Name = "PQ"; 
newquote.OpportunityID="{!Opportunity.Id}"; 
result = sforce.connection.create([newquote]); 
alert(result ); 

window.location.reload();

 

 

Can anyone help with where I am screwing this up?

 

Also, how would I go about making these actions dependent on a condition? Say, if field x on the opportunity was null, prevent the actions from taking place.

 

Thank you for any help!!!!

We are revamping cases to be better streamlined with the work flow of our call center agents.  As a result we created a custom link of of the Task object to show all open and closed cases, tasks, etc... 

 

The button is a URL link to a report, see below.

 

Label: View All History
Object Name: Task
Name: View_All_History
Link Encoding: Unicode (UTF-8)
Behavior: Display in existing window without sidebar or header
Display Type: List Button
Button or Link URL: /00Og0000000QXTQ?pv0={!Account.Name}

 

Why is this only working for Sysadmin profile users and not other users with different profiles?  I do not see any reference to Custom buttons/Links in any setting.

 

URL: https://xxxx.salesforce.com/00Og0000000QXTQ?pv0=Frank+Scerbo+and+Other+Occupants

Error:

Insufficient Privileges You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.

Good Morning Folks,

Do any of you know how to incorporate Apex code in a HTML Web-to-Lead form so that it execute when the "submit" button is pressed?   Down below  is a Web-to-Lead form that was generated by SF that I would like to modify so that apex code fires up when pressing the "submit" button.  The Apex code will then check if the Lead we are trying to enter already exists in the SF.  If it does exist, then it will update the existing Lead record accordingly.  Any help will be greatly appreciated.  And I will give kudos.  I promise

 

<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: Please add the following <META> element to your page <HEAD>.      -->
<!--  If necessary, please modify the charset parameter to specify the        -->
<!--  character set of your HTML page.                                        -->
<!--  ----------------------------------------------------------------------  -->

<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">

<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: Please add the following <FORM> element to your page.             -->
<!--  ----------------------------------------------------------------------  -->

<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

<input type=hidden name="oid" value="00DE0000000c06c">
<input type=hidden name="retURL" value="http://">

<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: These fields are optional debugging elements. Please uncomment    -->
<!--  these lines if you wish to test in debug mode.                          -->
<!--  <input type="hidden" name="debug" value=1>                              -->
<!--  <input type="hidden" name="debugEmail"                                  -->
<!--  value="jsiller@ucinnovation.com">                                       -->
<!--  ----------------------------------------------------------------------  -->

<label for="first_name">First Name</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>

<label for="last_name">Last Name</label><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>

<label for="email">Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" /><br>

<label for="company">Company</label><input  id="company" maxlength="40" name="company" size="20" type="text" /><br>

<label for="city">City</label><input  id="city" maxlength="40" name="city" size="20" type="text" /><br>

<label for="state">State/Province</label><input  id="state" maxlength="20" name="state" size="20" type="text" /><br>

<input type="submit" name="submit">

</form>

Hi All,

 

I am trying to have a jquery slideToggle() function bound to a row of data in an apex:pageBlockTable.

 

I am displaying some information in the table and want that if someone clicks on any row, some more information related to that contact is displayed in a slider and the rest of the rows move down. When he clicks again, the slider moves up and everything is back to normal.

 

If I am not wrong, I think I need to bind row elements (apex:columns) in one div and the information in the slider in the other. But somehow this is not working.

 

Here is the code:

 

<apex:page controller="xingShowSearchResult">

<head>
<style type="text/css"> 
#rowInfo,#rows
{
	padding:5px;
	text-align:center;
	background-color:#e5eecc;
	border:solid 1px #c3c3c3;
}
#rowInfo { 
	width:50px;
	display:none; 
}
 </style>
    
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>

<script>
$j = jQuery.noConflict();

   $j(document).ready(function(){
      $j("#rows").click(function(){
    $j("#rowInfo").slideToggle("slow");
  });
});

</script>

</head>
<body>

<apex:pageMessages />
    <div id='backtoDiv' style="height:20px;">
        <apex:outputLink value="/apex/XingPageTab" style="color:blue;">Back to Home Page</apex:outputLink>
    </div>
    
<apex:pageBlock title="Suche Kontakte"> 
    <apex:pageBlockSection columns="1">
    <apex:form style="float:right" >
        <apex:commandLink style="height:20px;font-weight: bold;" value="Suchergebnisse entfernen" action="{!deleteSearchResult}" />
    </apex:form>
    </apex:pageBlockSection>
    <apex:pageBlockTable value="{!newList}" var="contacts" id="contactsTable">
       
       <div id="rows">
        <apex:column > 
            <apex:image url="{!contacts.photoURL__c}" /> 
        </apex:column>
        
       
        <apex:column headerValue="Name"> {!contacts.displayName__c}</apex:column>
      
        
        <apex:column headerValue="Firma"> {!contacts.firma__c}</apex:column>
        <apex:column headerValue="Title" > {!contacts.title__c}</apex:column>
      </div>
        
               
      
     <div id="rowInfo" >
         <p>
            This is the paragraph to end all paragraphs.  You
            should feel <em>lucky</em> to have seen such a paragraph in
            your life.  Congratulations!
         </p>
     </div>  
     </apex:pageBlockTable>
</apex:pageBlock>              
</body>



</apex:page>

 

I am trying to understand VF and JS so any help would be appreciated.

 

Best,

Ankit

If we want to fix a bug and we r in a screen and we need to find the classes & page that is using it.

How to find it.

Thanks

Sai

Hello!

 

 

I am very new to Visual Force, roughly 4 weeks. 

 

I currently am in the process creating of creating a two page wizard. Pretty standard, multiple steps powered by one controller. 

 

 

Page One of the wizard allows the user to create an item. (Master-Detail Parent)

 

Page Two of the wizard allows the user to take that same item and add as many sub-items as they wish.  (Child)

 

 

Here is my only snag. Due to their relation, SUB-ITEM has a lookup field that is based off the ITEM name.

 

Upon creating the item and landing on page 2, I do not want the user to manually choose the item name in the subitem lookup field again to associate it with the parent. 

 

What are my options?

 

1) So far I only attempted a preliminary insert statememt of subitem.item__c = item.name__c which gave me the good old string id error. I assume this is because a lookup does not work simply by pulling the string as im sure it related to the ID on the backend. 

 

2) I figured another way to do it would be writing java script to grab the apex:inputhidden item.name text and paste it into the lookup field.

 

3) Or possibly use a trigger?

 

I have stewed on this for awhile but I figured I would mention this on the forums as I do not want a band-aid or a quick fix. I want to learn how to do it the write way as this will be a recurring problem as i continue my development.

 

In advance, I greatly appreciate your assistance! 

Anyone have an idea why this query works just fine:

soql = 'SELECT Name,Status__c,Contractor__c,Name_Of_Job__c,Job__r.Type__c FROM Bid__c WHERE name != null'; runQuery();       }

 

 

but this one fails:

soql = 'SELECT Name,Status__c,Contractor__c,Name_Of_Job__c,Job__r.Type__c FROM Bid__c WHERE name != null ORDER BY Name_Of_Job__c'; runQuery();       }

 

 

I am not seeing the issue with the ORDER BY clause.

Hello:

 

I have developed the following Visualforce page but nothing is showing up. I assume its a style issues. Any help is greatly appreciated.

<apex:page standardController="CBW_Rev_Share__c" tabStyle="CBW_Rev_Share__c">
    <apex:form >
        <style>
        .tableStyle {border-collapse: collapse; border-spacing: 0px 0px; }
        .colStyle1 { width: 33.3%;text-align:right; padding-top:3px; padding-bottom:5px}
        .colStyle2 { width: 33.3%; padding-left:20px; padding-top:5px; padding-bottom:5px}
        .colStyle3 { width: 33.4%;text-align:right; padding-top:5px; padding-bottom:5px}
        .rowstyle { border-bottom-style:solid; border-bottom-width:1px;border-bottom-color:#E8E8E8 } 
            <apex:pageBlock >
                <apex:pageBlockSection showHeader="true" title="Details" columns="3" id="details">
                    <apex:panelGrid columns="3" border="0" styleClass="tableStyle" width="100%" columnClasses="colStyle1,colStyle2,colStyle3" rowClasses="rowstyle">
                        <apex:outputLabel value="Tier One" styleClass="labStyle"/>
                        <apex:outputField value="{!CBW_Rev_Share__c.Tier_One__c}" id="TierOne"/>
                        <apex:outputLabel value="Low End Tier One" styleClass="labStyle"/>
                        <apex:outputField value="{!CBW_Rev_Share__c.Low_End_Tier_One__c}" id="LowEndTierOne"/>
                        <apex:outputLabel value="High End Tier One" styleClass="labStyle"/>
                        <apex:outputField value="{!CBW_Rev_Share__c.High_End_Tier_One__c}" id="HighEndTierOne"/>
                    </apex:panelGrid>       
                </apex:pageBlockSection>
            </apex:pageBlock>
        </style>            
    </apex:form>
</apex:page>

 Thanks in advance,

 

Hampton

Hi All

 

We're trying to turn off a trigger in our Production org and I've tried the following:

 

1.  Make the trigger Inactive in Sandbox

2.  Use the IDE to deploy the trigger to Production

 

The trigger is designed such that it fires on the insert, update, upsert of an Asset.  When the trigger fires, it will call an APEX class to perform th business logic, which is to put the Contact associated to the Asset into a Campaign.   The errors we are getting are due to assertion failures (see code below to see the assertion statements).  It seems like the tests are failing because the trigger is inactive in Sandbox and so it can't fire and therefore can't inititiate the action to put the Contact into the Campaign, and hence the assertion fails?  Does this sound right?  If so, how do I disable a trigger which is a dependency on an active APEX test?

 

 

Here is the Test Class code:

 

@isTest
private class XXXXXXXXX Test {

@isTest(SeeAllData=true) static void testContactGetsAddedToControlGroup() {
List<Asset> getAssets = smbNurtureCampaignTest.setup(1239.0,'Timeshare Lease');

List<CampaignMember> controlCampaignMemeber = [Select id from CampaignMember where Campaign.Name='ProDoc Trial Nurture Control Group' and ContactId=:getAssets[0].ContactId];
System.assert(controlCampaignMemeber.size() == 1);
}

@isTest(SeeAllData=true) static void testContactGetsAddedToTestGroup2Group() {
List<Asset> getAssets = smbNurtureCampaignTest.setup(1230.0,'Timeshare Lease');

List<CampaignMember> testCampaignMemeber = [Select id from CampaignMember where Campaign.Name='ProDoc Trial Nurture Test Group 2' and ContactId=:getAssets[0].ContactId];
System.assert(testCampaignMemeber.size() == 1);
}

 

I wrote a simple class, and have a test method which in the Force.com IDE is telling me covers this class 100%.  When I right-click on the class in the Package Explorer, go to Force.com > Deploy to server... I enter my production credentials and they are validated, then I see that only my class is set to add to the production environment and I go forward with the deployment.

After several minutes, I get a FAILURE message related to one test along the lines of 'too many DML rows', looking into the logs I see there are 10283 rows which exceeds the limit of 10000.  I log in to the production environment and run the failing test, and it fails in production too WITH THE SAME ERROR.

Now I have a chicken/egg situation and I don't know how to get any code to production with this failing test, and furthermore, I don't know how anything that would have broken this test would have made it to production!  I tried locally commenting out everything in the test class and the deployment failed in the exact same way (to the character) so I know it is not anything locally that I need to change.  I did have to fix some things in the test to get it to run locally, but that is irrelevant here especially since I commented the entire body out and got the same error.

HELP!!

Class I'm trying to deploy:

public class AuthorizationToken {

public String LoginId;

public String Password;

public AuthorizationToken(String user, String pw)

{

Password = pw;

LoginId = user;

}

statictestMethodvoid testAuthTokenInstantiation()

{

String user = 'testUser';

String pw = 'testPw';

Test.startTest();

AuthorizationToken testAuthToken = new AuthorizationToken(user, pw);

Test.stopTest();

System.assertEquals(testAuthToken.LoginId, 'testUser');

}

}

FAILING TEST CLASS:

@isTest
public with sharing class generateRenewalOppty_TEST
{
    static testMethod void myTest()
    {
        Boolean success = true;
       
       
           
            Account testAccount = new Account();
            testAccount.Name = 'Test';
            testAccount.Phone = '1111111111';
            testAccount.County__c = 'Macomb';
            testAccount.Member_Payment_Form__c ='Standard - Cash';
            testAccount.Type = 'Membership - New';
        
            insert testAccount;
           
            update testAccount;
           
            Product2 testProduct2 = new Product2(Name='TestProduct', ProductCode = '123', IsActive = true);
            insert testProduct2;
           
            List<Pricebook2> testPB2List = [select Id from Pricebook2 where IsStandard = true];
           
            PricebookEntry testPBE = new PricebookEntry(Product2Id = testProduct2.Id, Pricebook2Id = testPB2List[0].Id, UnitPrice = 5.0, UseStandardPrice = false, IsActive = true);
            insert testPBE;
           
           
            Opportunity oppObj = new Opportunity(Name='Test Opp',StageName='Closed Won - In-Kind',CloseDate=System.Today(),AccountId=testAccount.Id, type='Membership - New');
            insert oppObj;
           
            OpportunityLineItem testOPL = new OpportunityLineItem(OpportunityId = oppObj.Id, Quantity = 1.0, TotalPrice = 100, PricebookEntryId = testPBE.Id);
            insert testOPL;
           
            OpportunityLineItem testOPL1 = new OpportunityLineItem(OpportunityId = oppObj.Id, Quantity = 1.0, TotalPrice = 100, PricebookEntryId = testPBE.Id);
            insert testOPL1;
           
        
            testAccount.Generate_Renewal_Oppty__c = true;
            update testAccount;
          
            Opportunity[] oppOpen =[Select Id,Amount from Opportunity Where (StageName='Open' or StageName='Membership - Renewal') and AccountId =:testAccount.Id];
            System.assertEquals(1, oppOpen.size());
          
            OpportunityLineItem[] oppLi =[Select Id,TotalPrice from OpportunityLineItem Where OpportunityId=:oppOpen[0].Id];
            System.assertEquals(2, oppLi.size());
            System.assertEquals(100, oppLi[0].TotalPrice);
            System.assertEquals(100, oppLi[1].TotalPrice);
           
            Opportunity[] oppRec = [Select Id from Opportunity];
            delete oppRec;
           
            Opportunity oppOb = new Opportunity(Name='Test Opp1',StageName='Open',CloseDate=System.Today(),AccountId=testAccount.Id);
            insert oppOb;
           
            testAccount.Generate_Renewal_Oppty__c = true;
            update testAccount;
           
            Opportunity[] oppRec1 = [Select Id from Opportunity];
THIS IS LINE 52: delete oppRec1;
           
            Opportunity oppOb1 = new Opportunity(Name='Test Opp1',StageName='Open',CloseDate=System.Today(),AccountId=testAccount.Id,Type = 'Membership - New');
            insert oppOb1;
           
            testAccount.Generate_Renewal_Oppty__c = true;
            update testAccount;
           
            //delete oppOpen;
                      
        }
 
}


TEST RESULT DETAIL:

Class: generateRenewalOppty_TEST

Method Name: myTest

Pass/Fail: Fail

Error Message: System.LimitException: Too many DML rows: 10001

Stack Trace: Class.generateRenewalOppty_TEST.myTest: line 52, column 1

 

Hello

I have the following two sections of code that I need to understand. Initiative_settings__c is not a standard object or custom object that I can see in SF. But I can see the scheme through Eclipse. The scheme has fields in it. One of which is ANN_Marketing__c which is referenced in the second set of code? How is this sObject Built and how do I add additional fields to it? 

private Initiative_Settings__c getInitiativeSettings() {
return Initiative_Settings__c.getInstance();
}

public boolean getContainsAnnMarketingCampaigns() {
return getInitiativeSettings().ANN_Marketing__c && !getAnnMarketingCampaigns().isEmpty();
}

public List getAnnMarketingCampaigns() {
return filterList('ANN Marketing');
}

i have created an object with name PS_Detail__c .in this custom object i created a custom field of picklist type.in this picklist i defined two values Dollar ,Unit. when i go to P/S Detail Tab for creating a new PS_Detail__c object then i get None also as a value in picklist field .i want only Dollar and Unit as Picklist values .some one please help how to remove this None from Picklist

Hi there,

We have a lookup field on LEADS point to Accounts. The Web To Lead Form does not display the Lookup field called "Reseller", and I am not sure what HTML element should be used to grab the data from the Web Form and then populate into the look up field into LEADS object.

We have tried using something like this:-

Reseller: 

 

 

Reseller:<input  id="00N80000004nbGG" maxlength="100" name="00N80000004nbGG" size="20" type="text" /><br>



This is not working.

On the Web Form the field Reseller is a picklist while in SFDC we are trying to populate into lookup field.

How should this be resolve, what do we need to do on our web form to populate this value into SFDC under the lookup field.?

I wrote this rul but it is not working correctly. When a salesman in converting a lead to a opportunity i want the forcasted amount to be greater than zero.  See detail below.   Validation Rule Detail
Error: Invalid Data.
Review all error messages below to correct your data.
Rule NameForecasted_AmountActiveChecked
Error Condition FormulaAND(
NOT(ISNEW()),
ISBLANK(Amount))
Error MessageTo save a new Opportunity. The forecasted $ amount needs to be greater than $0. If you do not know at least the ballpark range for sales, it is not yet an Opportunity, but a lead that requires further qualification.Error LocationAmount
DescriptionAmount Forecasted for Opportunity is less than $0. All Opportunities must have a forecasted $ amount
Created By, 10/12/2011 9:47 AM

Hi,

 

Unable to fetch and save Force.com Components to Project: com.salesforce.ide.api.metadata.types.Metadata$JaxAccessorF_fullName cannot be cast to com.sun.xm.internal.bind.v2.runtime.reflect.Accessor

 

Abort or Continute Force.com project creation?

==============

while i am creating a new force.com project i got this error: can u please tell me why this error came. i downloaded eclipse and added force.com ide.... when i try to creating a new force.com project i got this error... and i am able to create a force.com project but not getting all existing classes and pages. And not added my new page or class content to the sever when i save. Is it required any other software installations?

 

Hi All,

I would like my leads to fill a medical from, which has about 30 yes / no questions and some open lines.

I wouldn't like to create a field for each of these. what's a smart way to do this?
I thought perhaps there is a way to compile these fields into one big text document, in which each question and it's answer would be written line after line.
it can then be sent to salesforce as one single large text file.

Any Ideas on how I should implement this?

Thanks