• jeffdonthemic
  • NEWBIE
  • 299 Points
  • Member since 2007

Badges

  • Chatter
    Feed
  • 12
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 131
    Replies

How does pricing work?  I want to distribute our own application to non-salesforce customers.  I understand there is a 15/month/user embedded license cost but if I also want to create a force.com site how does that work?  For example, if the new organization that I sell the solution to has 10 admin users but the force.com site that we create has 1,000 registered users, how much does that cost. 

 

Thanks.

-Ben

  • August 02, 2009
  • Like
  • 0

Experts,

 

I have a situation where based on where the Update is executed from, I got to decide on whether to execute or bypass the trigger. In conventional programming languages, I would have accomplished this by a context or an instance variable.

 

I am relatively new to Apex and could not get my head around on the best way to achieve this. Any ideas are welcome!

 

Thanks!

Pr@sh...

 

I have a custom object with numerous record types. I am trying to creat a more print friendly page containing data from custom fields in the custom object. Here is what I have so far, I cannot get any of the data to show up in the table.

 

 

<apex:page standardController="Inventory__c" recordSetVar="Generator_Sets" sidebar="false" showHeader="false"> <apex:image value="https://na4.salesforce.com/servlet/servlet.ImageServer?id=01560000000MKsl&oid=00D6000000072B4&lastMod=1229623939000"/> <p></p> <apex:pageBlock title="Generator Sets" mode="detail"> <apex:pageBlockTable value="{!Inventory__c}"var="Generator_Sets" rules="rows" frame="none"> <apex:column value="{!Inventory__c.KW__c}"/> <apex:column value="{!Inventory__c.Engine_Brand__c}"/> <apex:column value="{!Inventory__c.Eng_Model__c}"/> <apex:column value="{!Inventory__c.Engine_Serial_No__c}"/> <apex:column value="{!Inventory__c.Condition__c}"/> <apex:column value="{!Inventory__c.Enclosure__c}"/> <apex:column value="{!Inventory__c.Additions__c}"/> <apex:column value="{!Inventory__c.Name}"/> <apex:column value="{!Inventory__c.Advertised_Price__c}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>

 Inventory is the custom object, generatot set is the record type and the column values are the custom fields.

 

  • May 09, 2009
  • Like
  • 0

I'd like to update some records based on user interaction with a Flex SWF.  I can't find examples of the syntax for Updates.  Do I just use connection.query and specify an update statement?  Is that formed like SQL?

 

update [table] set [columnList[a]=value,[columnList[b]] where id = :[id]?

 

I'm already directly querying (rather than using the WebService API) so ideally I could use the flex toolkit to make those updates based on ActionScript.  Thanks

How does one access a product2's name (description) within an OpportunityLineItem?

 

I don't care about the product's ID or price book information--just the product's name.  I haven't figured out how to do this yet, though it seems like it should be simple...

 

I'm building (hopefully some day) a OpportunityLineItem trigger to update a field elsewhere based on whether or certain products appear in line items.

 

Thanks,

Kevin

  • April 23, 2009
  • Like
  • 0

Here i am using an Apex Trigger and would like to create an apex method from an apex class in the trigger is that possible to use an apex custom class in an apex trigger.

for example:

 

public class myclass

{

 public String mymethod()

{

.............. 

 

Apex Trigger:

 

trigger Testobj on myObject__c (after insert) { 

 myObject__c  myobj = Trigger.new[0];

 

 myclass clas = new myclass();

class. mymethod(.......);

 

 

 

Here in this trigger the afterInsert action is taken such that after the values are inserted the action from the apex method takes place.

 

 

  • April 06, 2009
  • Like
  • 0

How do I get data published publicly I  have created this custom object and am trying to display the data in a visualforce page. however When I try and view this page with a browser it does a server side redirect to Authorization Require. 

 

Is there a security setting I need to set to allow unauthenticated access to data?

 

 

Hi,

 

I am getting Save error: Unexpected token:  

 

when saving to the server, here is the code and in red the line with the error:

 

 if(39 < loopContact.MiFID_Total_Points__c < 80){
                if(loopContact.Application_Date__c < dueDate){
                    sendEmailUpgrade(loopContact, 1); //EMAIL UPGRADE1
                } else {
                    sendEmailUpgrade(loopContact, 2); //EMAIL UPGRADE2
                }
 } else {

 .................

 }

 

Any Ideas?  MiFID_Total_Points__c is a number

 

Thanks

  • March 26, 2009
  • Like
  • 0

Hi

 

I need some help with "auto complete" (code completion) in eclipse.

 

I start using Eclipse to write Apex code but the code "auto complete" is not working.

Does anyone know what should I do?

 

thanks

Yitzchak

Message Edited by yud on 02-17-2009 03:52 AM
  • February 17, 2009
  • Like
  • 0

HI ALL,

Is the any methods in Apex API , so i can generate log files as per my conditions when my application in running within force.com platform. Please reply asap ..anyone ..thnx 

I have a custom button on one of my custom objects called with an API name of "DeleteX".  I want to include this button in the button bar of my visual force page right next to the edit button.  But when I say "action='{!DeleteX}'" in the commandButton component it doesn't work.  Is what I'm trying to do possible and if so what's the syntax?

 

Thanks in advance. Here's my page as it currently exists.

 

 

<apex:page standardController="Web_Integration__c" showHeader="true" tabStyle="opportunity" title="Web Integration: {!Web_Integration__c.Name}"> <apex:form > <apex:pageBlock title="Web Integration Detail"> <apex:pageBlockButtons > <apex:commandButton action="{!edit}" value="Edit"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>

 

 - Hank

 

Hello.

I have a trigger on Leads that, when a lead is entered or modified, it checks for any potential duplicate leads in the system. If it finds any, it sends an email to an administrator. The code for the trigger is below.

How do I write unit tests for a trigger like this? What exactly am I testing for? I've written a number of other unit tests for triggers across other objects, both default and custom, and have achieved 100% coverage, but I can't figure out what I should be testing for.

Thanks in advance.

Code:
trigger trigDupeLeadEmailAlert on Lead (before insert, before update) {

    List<Lead> changedLead = new List<Lead>(); // List of the changed leads
    List<Lead> dupeLead = new List<Lead>(); // hold dupes being entered.
    List<Lead> searchResults;
    
    for(Lead le: Trigger.new) {
        changedLead.add(le);
    }

    // Loop on the changed Leads, building the query based on the entered info
    for (Lead cl : changedLead) {
        // Only check if a new record, or if it's an update and the name or company has changed.
        if (Trigger.isInsert || ((cl.LastName != Trigger.oldMap.get(cl.Id).LastName) || (cl.Company != Trigger.oldMap.get(cl.Id).Company) )) {
            String queryString = 'SELECT Id,Name,Company,Email,Owner.Name FROM Lead WHERE IsConverted=False';
            queryString = queryString + ' AND Lead.LastName LIKE \'%' + String.escapeSingleQuotes(cl.LastName) + '%\'';
            queryString = queryString + ' AND Lead.Company LIKE \'%' + String.escapeSingleQuotes(cl.Company) + '%\'';
            queryString = queryString + ' ORDER BY LastName ASC';
            searchResults = Database.query(queryString);
            for (Integer i = 0; i < searchResults.size(); ++i) {    
                dupeLead.add(searchResults[i]);
            }
        }

        // If the dupeLead list contains dupes, create a messaging object and send
        if (dupeLead.size() > 0) {

            // First get the owner of the lead being added
            User leadOwner = [SELECT Name,Email FROM User WHERE Id=:cl.OwnerId];

            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            String[] toAddresses = new String[] {'xxxxxx@xxxxxxxxxxx.com'}; 
            mail.setToAddresses(toAddresses);
            mail.setReplyTo('xxxx@xxxxxxxxxxxx.com');
            mail.setSenderDisplayName('Salesforce Support');
            mail.setSubject('Duplicate Lead Entered');
            mail.setUseSignature(false);
            
            String sendDate = Datetime.now().format('MM.dd.yyyy');
            String MailBodyHTML;
            MailBodyHTML = '<html><body style="font-family: Arial; font-size: 9pt;">';
            MailBodyHTML = MailBodyHTML + sendDate + '<br/>';
            MailBodyHTML = MailBodyHTML + '<font size=+1><strong>Salesforce.com: Potential Duplicate Prospect</strong></font><br/><br/>';
            MailBodyHTML = MailBodyHTML + 'The following Prospect was just entered or modified in Salesforce by <strong>' + leadOwner.Name + '</strong>.<br/><br/>';
            MailBodyHTML = MailBodyHTML + '<table border="1" cellpadding="4" cellspacing="0" style="font-family: Arial; font-size: 9pt;"><tr>';
            MailBodyHTML = MailBodyHTML + '<td><strong>Prospect Name<strong></td>';
            MailBodyHTML = MailBodyHTML + '<td><strong>Company<strong></td>';
            MailBodyHTML = MailBodyHTML + '<td><strong>Email Address<strong></td>';
            MailBodyHTML = MailBodyHTML + '<td><strong>Link<strong></td>';
            MailBodyHTML = MailBodyHTML + '</tr>';
            MailBodyHTML = MailBodyHTML + '<tr><td>'+ cl.FirstName + ' ' + cl.LastName + '</td><td>' + cl.Company + '</td>';
            MailBodyHTML = MailBodyHTML + '<td>'+ cl.Email + '</td>';
            MailBodyHTML = MailBodyHTML + '<td><a href="https://na1.salesforce.com/'+ cl.Id + '" target="_blank">View Prospect</a></td></tr>';
            MailBodyHTML = MailBodyHTML + '</table>';
            MailBodyHTML = MailBodyHTML + '</br><br/>Similar prospects are listed below. Please check to make sure there aren\'t any conflicts.</br><br/>';

            MailBodyHTML = MailBodyHTML + '<table border="1" cellpadding="4" cellspacing="0" style="font-family: Arial; font-size: 9pt;"><tr>';
            MailBodyHTML = MailBodyHTML + '<td><strong>Prospect Name<strong></td>';
            MailBodyHTML = MailBodyHTML + '<td><strong>Company<strong></td>';
            MailBodyHTML = MailBodyHTML + '<td><strong>Email Address<strong></td>';
            MailBodyHTML = MailBodyHTML + '<td><strong>Owner<strong></td>';
            MailBodyHTML = MailBodyHTML + '<td><strong>Link<strong></td>';
            MailBodyHTML = MailBodyHTML + '</tr>';
     // Loop on the dupes
for (Lead ol : dupeLead) { MailBodyHTML = MailBodyHTML + '<tr><td>'+ ol.Name + '</td><td>' + ol.Company + '</td>'; MailBodyHTML = MailBodyHTML + '<td>'+ ol.Email + '</td><td>' + ol.Owner.Name + '</td>'; MailBodyHTML = MailBodyHTML + '<td><a href="https://na1.salesforce.com/'+ ol.Id + '" target="_blank">View Prospect</a></td></tr>'; } MailBodyHTML = MailBodyHTML + '</table>'; MailBodyHTML = MailBodyHTML + '</body></html>'; mail.setHtmlBody(MailBodyHTML); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } } }

 -Greg

I'm trying to create a Visualforce page that allows a user to choose a Lead Queue form a picklist. I see the QueueSobject object but it appears to only contain the SobjectType and QueueId; not the Queue Name. Any idea how I can get both the Queue's Id and Name?

 

Thanks

 

Jeff Douglas
Informa Plc
http://blog.jeffdouglas.com

I have the following controller that contains a simple inner class. My original test methods where in the
controller but as my test code began to grow I decided to move it to their own class.

My test class is throwing the following error: Invalid type: MyProduct

 

I know that that I can move MyProduct to its own class but that is not the point. How does my test class
access this inner class?

 

 

public class MyController {

public class MyProduct {
public String name {get;set;}
public String code {get;set;}
}

public List<MyProduct> products {
get {
List<MyProduct> theProducts = new List<MyProduct>();
// do something here to fill the list with MyProducts
return theProducts;
}
set;
}
// more code that may or may not be important

}

 

 

@isTest
private class MyControllerTest {

private static testmethod void testMe() {

MyController myCon = new MyController();
List<MyProduct> testProduction = myCon.products; <--- throws error

}

}

 


 

Thanks

 

Jeff Douglas
Informa Plc
http://blog.jeffdouglas.com

On 2/10 I deployed a Visualforce page and Controller to Production using Eclipse. The deployment process validated the code and successfully deployed the page and class. I logged into Produciton and the page was working correctly.

 

I came back in on Monday and realized that I had not written any test cases but that the code had deployed succcessfully! I submitted a case but to this date L3 support cannot tell why this happened?

 

Can anyone explain how my code could be deployed to Production without any test cases (ie 0% coverage)?

 

Thanks

 

Jeff Douglas
Informa Plc
http://blog.jeffdouglas.com

I saw on the Winter ‘09 Developer Screencast a screenshot of a tree conrol. Does anyone know if that code will be released?

I started working on a lazy-loading Flex tree control but don't want to go too far down that road if a Visualforce/Apex version is going to be released.

Flex tree control: http://blog.jeffdouglas.com/2008/12/08/flex-salesforcecom-tree-control/

Jeff Douglas
Informa Plc
blog.jeffdouglas.com
I have a Visualforce page with the following code:

Code:
<apex:commandButton value="Sharing" onclick="window.top.location='{!URLFOR($Action.Opportunity.Share,Opportunity.Id)}'" />

 
When clicked, the button only redirects you to the correct page if "Develoment Mode" is check for your user. If not checked, the page simply refreshes the current page.

I've tried with a number of different browsers and still the same results. Any idea?

Thanks
Jeff Douglas
Informa Plc
We have a number of Flex apps running in production for several months. We recently began receiving reports of fatal errors when running the new Flash 10 player:

"Security error accessing url"

Has anyone seen a fix for this?

Thanks
Jeff Douglas
Informa Plc
I have the following trigger that sets a field on the Account based upon the owner's settings. The Owner object appears to be blank during the execution of the trigger?? Running the code from Eclipse, I can see that the Owner is not null and the values should be set properly.

Any idea why the Owner reference is null?

Code:
trigger UpdateBusinessUnit on Account (before insert, before update) {
 
 for (Account a : Trigger.new) {
     
  System.debug('Industry: '+a.Industry__c);   
  System.debug('SubLocation: '+a.Owner.SubLocation__c);  // <----- returned as null—
  System.debug('Location: '+a.Owner.Location__c); // <----- returned as null–
  
  if (a.Industry__c != null && a.Owner.SubLocation__c != null && a.Owner.Location__c != null) {
   // set the value   
   a.Business_Unit__c = a.Industry__c+a.Owner.SubLocation__c+a.Owner.Location__c;
  } else {
   a.Business_Unit__c = '';
  }
  
 }

}

 


Hi All,

 

I am new to Salesforce CRM.

 

Currently am Java Developer . How can I learn this Salesforce CRM.

 

I have registered my self and download the books, but as a Developer I am not understanding where to start this Salesforce from .

 

Please suggest.

 

Regards,

Ram Shankar.

922 22 175 60. 

How does pricing work?  I want to distribute our own application to non-salesforce customers.  I understand there is a 15/month/user embedded license cost but if I also want to create a force.com site how does that work?  For example, if the new organization that I sell the solution to has 10 admin users but the force.com site that we create has 1,000 registered users, how much does that cost. 

 

Thanks.

-Ben

  • August 02, 2009
  • Like
  • 0

I'm sure this is much, much easier than I am ascribing to it...for some reason I am unable to vision my way into a first venture into APEX code.

 

I have read and read and read posts and have found a multitude that seem like they should be close but I can never quite transform them.  At now that I have hit 7 hours of reading and have made no progress I have to concede and ask for help.

 

I need a "fake" roll-up summary (I have created a field called "Trained Contacts" on my Account object that counts related Contacts when custom field "Date_of_Last_Implantation_Training__c" is not equal to null.  It has to recalculate when Contacts are added and that field is filled in, when Contacts are deleted (and therefore the count should go down) or when the contents of that field are deleted (rare, but usually only when there is a data entry error).

 

Anyone out there that can help me through my first Trigger?  I'm sure I can then study the code and then adapt if for other future uses if necessary (although we have made it 2 years without needing any heavy customization yet...).

 

Thank you in advance for your patience and any assistance you may be able to offer...

 

Kelly

  • August 02, 2009
  • Like
  • 0

 Could somebody please explain to my why this fails?

 

public static ID[] GetAccountContacts(String AccountId)

 {

ID[] iddata = [select id from contact where AccountId];

 

return iddata;

 

}

Please excuse my ignorance on something that may be quite simple for some of you. Thanks in advance for assisting me in learning how to maximize the potential of Salesforce.

 

I am using the free quote line item app from app exchange and would like to have the visualForce page that generates the PDF be dynamic. Possibly an if statement that will go up to the quote and check the value of the custom picklist I created, 'template__c' and then use this value to determine which visualforce page to use for the quote. The conditions might be something like this:

 

String template;
template = quote.template__c;  

 

if ( template == 'quote1' ) {
PageReference pdfPage = new PageReference( '/apex/quotePDF');
}

if ( template == 'quote2' ) {
PageReference pdfPage = new PageReference( '/apex/quotePDF');
}

 I could not figure out how to get the quote.template__c value and store it in a variable so that it could be used to select the correct template. This is the section of the controller that generates and attaches the PDF.

 

/* The action method that will generate a PDF document from the QuotePDF page and attach it to the quote provided by the standard controller. Called by the action binding for the attachQuote page, this will do the work and take the user back to the quote detail page. */

public PageReference attachQuote() {

/* Get the page definition */
PageReference pdfPage = new PageReference( '/apex/quotePDF' );

/* set the quote id on the page definition */
pdfPage.getParameters().put('id',quote.id);

/* generate the pdf blob */
Blob pdfBlob = pdfPage.getContent();

/* create the attachment against the quote */
Attachment a = new Attachment(parentId = quote.id, name=quote.name + '.pdf', body = pdfBlob);

/* insert the attachment */
insert a;

/* send the user back to the quote detail page */
return controller.view();
}

 

 

 

Message Edited by JamesZ on 07-24-2009 05:04 PM

I have some before and after insert triggers on Contact. When a Contact is imported via the Account/Contact import wizard, the triggers don't behave as expected. All my tests are passing--one-offs and bulk.

 

My question is, how do I troubleshoot a problem like this? I can't write a test that uses the import wizard. Import wizard DMLs don't appear to be recorded in the debug log. I'm not sure where the dupe checking of the import wizard fits in the execution stack--it's not listed in the Apex docs that talk about execution order.

 

Is there any way for me to see what might be happening here?

 

Thanks,

Steve 

I have an Account trigger where I want to update all the contacts.

 

I might have more than a 1000 contacts (query limit) or 100 contacts (DML Limit) So I might have to resort to a @future method. 

 

However given that @future methods have 200 a day limit (per user or per org?), I don't want to call a @future method if an Account has only 2 contacts.

 

But how do I find out that I have only 2 contacts? I have to query, and that might cause a governor limit error...

 

 

Hi all, I have problems calling a web service using the POST method. I think that I have the idea of how to do it...:S but Im not sure. Here is my code

 

 

public static String sendContent(String url,String parameters)
{
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(url); //this is the http://myws/
req.setMethod('POST');
req.setBody(parameters);this is like parameters="var1=value1&var2=value2&var3=value3"

req.setHeader('Content-type', 'application/x-www-form-urlencoded');
req.setHeader('Content-length', String.valueOf(parameters.length()) );
HttpResponse res = h.send(req);
return res.getBody();
}

 

 

Now when i execute this the res.getBody() throws me the following error:

 

 <?xml version='1.0' encoding='ISO-8859-1' ?> <SOAP-ENV:Envelope> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>Unknown exception</faultstring> <faultactor>server name:listen port</faultactor> <detail><appSpecific>Unknown Exception has occurred</appSpecific> </detail> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

 

 I don't really know if I'm setting the headers correctly or what is missing so Ill really appreciate your help.

 

Thank you for your time 

Experts,

 

I have a situation where based on where the Update is executed from, I got to decide on whether to execute or bypass the trigger. In conventional programming languages, I would have accomplished this by a context or an instance variable.

 

I am relatively new to Apex and could not get my head around on the best way to achieve this. Any ideas are welcome!

 

Thanks!

Pr@sh...

 

Hello - I am getting the following error when attempting to Save a record using a VisualForce Page (VisualForcExtension) and a Controller Extension (positionExtension):

 

System.NullPointerException: Attempt to de-reference a null object

                                                                                                                                                   

Class.positionExtension.Save: line 54, column 16 External entry point (line 54 column 16 is underlined in the following code fragment "return theController.save()";)

 

public class positionExtension { public string positionTypeID {get; set;} public positionExtension(ApexPages.StandardController positionController) { this.position = (Position__c)positionController.getRecord(); } public List<selectOption> PositionTypeOptions {get { List<selectOption> positionTypes = new List<selectOption>(); for (Position_Type__c ptr : [select name from Position_Type__c pt where pt.Department__c = :position.Department__c order by Name ]) positionTypes.add(new selectOption(ptr.id, ptr.name)); if (position.Department__c != null) { positionTypes.add(new selectOption('other', 'Other')); } else { positionTypes.add(new selectOption('', 'Please select a department', true)); } return positionTypes; } private set;} public Position_Type__c newPositionType{ get{ if (newPositionType == null) { newPositionType = new Position_Type__c();} return newPositionType; } private set; } public void resetPositionType() { positionTypeID = null; } public PageReference Save() { if (positionTypeID == 'other') { try{ newPositionType.Department__c = position.Department__c; insert newPositionType; position.Position_Type__c = newPositionType.ID; } catch (DmlException e) { ApexPages.addMessages(e); } } else { position.Position_Type__c = positionTypeID; } return theController.save(); } private final Position__c position; private final ApexPages.StandardController theController; }

 

The markup from the Visualforce Page that calls the Apex Class:

 

<apex:page standardController="Position__c" extensions="positionExtension" > <apex:form > <apex:sectionHeader title="Add New Position"/> <apex:pageBlock mode="edit" id="thePageBlock"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageBlocksection title="Information"> <apex:inputField value="{!Position__c.Location__c}"/> <apex:inputField value="{!Position__c.Hiring_Manager__c}"/> <apex:inputField value="{!Position__c.Status__c}"/> <apex:inputField value="{!Position__c.Notification__c}"/> <apex:inputField value="{!Position__c.Start_Date__c}"/> </apex:pageBlocksection> <apex:actionRegion > <apex:pageblocksection columns="1" title="Department"> <apex:inputField value="{!Position__c.Department__c}"> <apex:actionSupport event="onchange" rerender="dependentPositionType" action="{!resetPositionType}" status="departmentStatus"/> <apex:actionStatus id="departmentStatus" startText="Fetching position types..."/> </apex:inputField> </apex:pageblockSection> </apex:actionRegion> <apex:pageblockSection id="dependentPositionType" columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel value="Position Type" for="pt"/> <apex:panelGrid columns="2"> <apex:actionRegion > <apex:outputText value="{!Position__c.Position_Type__c}" rendered="false"/> <apex:selectList id="pt" value="{!positionTypeID}" size="1" disabled="{!ISNULL(Position__c.Department__c)}"> <apex:selectOptions value="{!PositionTypeOptions}"/> <apex:actionSupport event="onchange" rerender="dependentPositionType" status="typeStatus"/> </apex:selectList> </apex:actionRegion> <apex:actionStatus id="typeStatus" startText="updating form..."> <apex:facet name="stop"> <apex:inputField value="{!newPositionType.Name}" rendered="{!positionTypeId == 'other'}" required="true"/> </apex:facet> </apex:actionStatus> </apex:panelGrid> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection title="Position Details"> <apex:inputField value="{!Position__c.Job_Description__c}"/> <apex:inputField value="{!Position__c.Responsibilities__c}"/> <apex:inputField value="{!Position__c.Programming_Languages__c}"/> <apex:inputField value="{!Position__c.Educational_Requirements__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

I would appreciate any ideas for resolving this problem.  Please go easy on newbie learning VF and Apex.

 

Thanks,

SCR

  • July 23, 2009
  • Like
  • 0

Apologies first of all as I am very new to apex but I am struggling to create a test to ensure rows are returned from a test header.id  

 

This is the class 

 

public class SDW_NonRechargeable_Line_Items {

private SFDC_Expense_Header__c header;

private ApexPages.StandardController controller;

 

public SDW_NonRechargeable_Line_Items(ApexPages.StandardController stdController) {

controller = stdController;

header = (SFDC_Expense_Header__c)controller.getRecord();

}

 

public List<Expense_Line_Item__c> NRLineItems {get {

if(header == null){

return new List<Expense_Line_Item__c>();

 

}

List <Expense_Line_Item__c> Non_Rechargeable_Line_Items = [

Select

Name,

Expenditure_Type_Non_Rechargeable__c,

Description__c,

Date__c,

Amount_net__c,

Amount_Gross__c,

CurrencyIsoCode

from Expense_Line_Item__c

where Expense_Report__c = :header.Id order by Date__c];

return Non_Rechargeable_Line_Items;

 

}

set;

}

}

 

 

My test class so far...

 

 

@isTest

private class ExpensesTestSuite {

 

 

static testMethod void run_SDW_NonRechargeable_Line_Items_Tests() {

 

// TO DO: implement unit test

 

List <Expense_Line_Item__c> Non_Rechargeable_Line_Items = new list<Expense_Line_Item__c>();

 

ApexPages.StandardSetController ssc = new

ApexPages.StandardSetController(Non_Rechargeable_Line_Items);

 

 

// Validate bulk SELECT

System.debug('Testing SELECT List return');

 

 

 

//

 

 

}

}

 

Where do I go from here, the examples I see on the forum don't seem to be helping me test for a select as opposed to updates or inserts.

 

Help gratefully appreciated.

 

Regards,

Steve 

 

Good day, 
first sorry for my english. 
I am a newbie and ask the council for writing bulk trigger.

I created a trigger, which should create a contact, account and assets for imports through the Data Loader.

 

Now I get an error: Too Many SOQL queries

 

I know that all queries need to move out of for


I request your assistance in this matter. 

 

Here is my trigger code:

 

trigger ImportAsset on Asset (before insert) {

 

List<Asset> asset = Trigger.new;

String accId;

for (Asset a : asset){

if (a.Import_AccountName__c != null){

List<Account> acc = [Select Id from Account where Name = :a.Import_AccountName__c];

for (Account account: acc) {

if (acc.size() == 0){

Account accnew;

accnew = new Account();

accnew.Name = a.Import_AccountName__c;

accnew.BillingCity = a.Import_AccountCity__c;

accnew.BillingStreet = a.Import_AccountAddress__c;

accnew.Phone = a.Import_AccountPhone__c;

accnew.Tel2__c = a.Import_AccountPhone2__c;

accnew.Website = a.Import_AccountUrl__c;

insert accnew;

accId = accnew.Id;

} else {

accId = account.Id;

}

}

List<Contact> contactLines = new List<Contact>();

if (a.Import_FirstName1__c != null){

Contact cnt1 = new Contact();

cnt1.FirstName = a.Import_FirstName1__c;

cnt1.LastName = a.Import_LastName1__c;

cnt1.Title = a.Import_Title1__c;

cnt1.Phone = a.Import_MobilePhone1__c;

cnt1.AccountId = accId;

contactLines.add(cnt1);

}

if (a.Import_FirstName2__c != null){

Contact cnt2 = new Contact();

cnt2.FirstName = a.Import_FirstName2__c;

cnt2.LastName = a.Import_LastName2__c;

cnt2.Title = a.Import_Title2__c;

cnt2.Phone = a.Import_MobilePhone2__c;

cnt2.AccountId = accId;

contactLines.add(cnt2);

}

if (a.Import_FirstName3__c != null){

Contact cnt3 = new Contact();

cnt3.FirstName = a.Import_FirstName3__c;

cnt3.LastName = a.Import_LastName3__c;

cnt3.Title = a.Import_Title3__c;

cnt3.Phone = a.Import_MobilePhone3__c;

cnt3.AccountId = accId;

contactLines.add(cnt3);

}

insert contactLines;

}

if (a.Import_ProductCode__c != null){

List<Product2> prod = [Select Id, Name from Product2 where ProductCode = :a.Import_ProductCode__c];

for (Product2 p: prod){

a.Name = p.Name;

a.Product2Id = p.Id;

a.AccountId = accId;

a.Status = 'Setup';

}

}

}

}

 

 I'm grateful for any help..

 

Hi SFDC developers -

 

I've been trying to see if there is a way in Apex to retrieve the values of a picklist by record type.  The getPickListValues() method doesnt seem to take input arguments for record type id.  Also the DescribeSObjectResult object seems to retrieve record types info, but this child object doesnt seem to be able to get the values either.   Is there sometihng I'm missing or is there another creative solution for this?  

 

The basic requirement is on VF page to dynamically show task object picklist values based on what country a user is  from (we'll get that off user record and match to a record type on the task object and get the appropriate values). 

 

Thanks everyone!

   

Hi,

I have a Trigger :

trigger UpdateSubTotalAndTotalTax on InventoryReceiptDetail__c (after insert, after update, after delete, after undelete, before update)
{
/* if(Trigger.isBefore && Trigger.isUpdate)
{
InventoryReceipt.UpdateReceivedCostInInventoryReceiptDetail(Trigger.new);
} */
if(Trigger.isDelete && Trigger.isAfter)
{
for(Integer i = 0; i < Trigger.old.size(); i++)
{
InventoryReceipt.UpdateSubTotalAndTotalTax(Trigger.old[i].ReceiptNo__c);
}
}
else if(Trigger.isInsert && Trigger.isAfter)
{
for(Integer i = 0; i < Trigger.new.size(); i++)
{
InventoryReceipt.UpdateSubTotalAndTotalTax(Trigger.new[i].ReceiptNo__c);
}
}
if(Trigger.isUpdate && Trigger.isAfter)
{
for(Integer i = 0; i < Trigger.new.size(); i++)
{
InventoryReceipt.UpdateInventoryStatusFromDetail(Trigger.new[i].ReceiptNo__c);
}
}
}

I dont know that how can i test this by writing Test method for this.

Please Help to solve this.

Thanks in advance

Shwetal Desai

I have a custom object with numerous record types. I am trying to creat a more print friendly page containing data from custom fields in the custom object. Here is what I have so far, I cannot get any of the data to show up in the table.

 

 

<apex:page standardController="Inventory__c" recordSetVar="Generator_Sets" sidebar="false" showHeader="false"> <apex:image value="https://na4.salesforce.com/servlet/servlet.ImageServer?id=01560000000MKsl&oid=00D6000000072B4&lastMod=1229623939000"/> <p></p> <apex:pageBlock title="Generator Sets" mode="detail"> <apex:pageBlockTable value="{!Inventory__c}"var="Generator_Sets" rules="rows" frame="none"> <apex:column value="{!Inventory__c.KW__c}"/> <apex:column value="{!Inventory__c.Engine_Brand__c}"/> <apex:column value="{!Inventory__c.Eng_Model__c}"/> <apex:column value="{!Inventory__c.Engine_Serial_No__c}"/> <apex:column value="{!Inventory__c.Condition__c}"/> <apex:column value="{!Inventory__c.Enclosure__c}"/> <apex:column value="{!Inventory__c.Additions__c}"/> <apex:column value="{!Inventory__c.Name}"/> <apex:column value="{!Inventory__c.Advertised_Price__c}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>

 Inventory is the custom object, generatot set is the record type and the column values are the custom fields.

 

  • May 09, 2009
  • Like
  • 0

Folks,

 

From my apex class i want to get the 'Web Tab' URL using its name.  I want to avoid the hardcoding the url my code following.

 

 

private final String RedirectUrl = '/servlet/servlet.Integration?lid=01r70000000EWxQ&ic=1'; public PageReference cancelView(){ PageReference newPage = new PageReference(RedirectUrl); newPage.setRedirect(true); return newPage; }

 

 

 

Hi ,

 

I am trying to insert 200 records at a time in TestMethod for Trigger but it fails saying :-

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ConnectCompiere.ScheduleWorkFlow: execution of BeforeInsert caused by: System.Exception: ConnectCompiere:Too many SOQL queries: 21
Trigger.ConnectCompiere.ScheduleWorkFlow.getCompiereSetUpId.....

 

My Trigger :-

 

 

trigger ScheduleWorkFlow on Workflow__c (before insert, before update) {

// This Apex trigger is designed to fire when the batch workflow scheduler
// checks the Trigger Batch Run checkbox or when changes are made to the Batch Run
// record manually.
Set<Id> wkIds = new Set<Id>();
for (Workflow__c batchRun : Trigger.new) {

String setUpId = getCompiereSetUpId(batchRun);
    // Apex code.......... 
}public String getCompiereSetUpId(Workflow__c batchRunOld){
//System.debug('in call getCompiereSetUpId');
List<Rule__c> ruleList = [select Compiere_Setup__c from Rule__c where Workflow_Rule__c =: batchRunOld.id];
String setUpId = '';
for(Rule__c rule:ruleList){
setUpId = rule.Compiere_Setup__c;
}
return setUpId;
}}

 

 

TestMethod :-

 

 public static testMethod void TriggerTest(){
       List<WorkFlow__c> batchS = new List<WorkFlow__c>();
        for(Integer x=0; x<200;x++){
            WorkFlow__c batch = new WorkFlow__c();
            batch.Username__c = 'XXXXXX';           
            batchS.add(batch);
        }
       
        Test.startTest();
        insert batchS;
        Test.stopTest();
        
    }

 

its running ok for 20 insert , which i can understand why my problem is happening..Basically its bcoz of the SOQL limits , but can please some gimme some idea to finetune my code in trigger..

 

 

Thanks...