• rocwilcox
  • NEWBIE
  • 255 Points
  • Member since 2009

  • Chatter
    Feed
  • 9
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 37
    Replies

public class con1
{
account a
public account getinfo()
{
a=[select id,name,billingcity,phone from account where id=:apexpages.currentpage().getparameters().get('id')];
return a;
}
}

 

 

  • September 11, 2012
  • Like
  • 0

Hi Guys! I have an issue where a Try/Catch ALWAYS goes to the Catch when invoked from a test method. When invoked from Visualforce as normal this doesn't happen, so it has to be something in the test scenario.

 

It's the second SOQL statement below, which uses a field 'User_Contact_Link__c from the User. This is just a text field containing a Contact ID that matches a Contact record in the system.

 

Any ideas?????

 

Snippet below:

 

u = [SELECT SAG_Account_Creator__c,
                    SAG_Organization__c,
                    SAG_License_Country__c,
                    User_Contact_Link__c
             FROM User
             WHERE id = :UserInfo.getUserId()
             LIMIT 1];

ID convertToLong = u.User_Contact_Link__c;
        String longId = convertToLong;
 
        system.debug('++++UserCon'+u.User_Contact_Link__c);
        system.debug('++++Long'+longId);
        
        try{
            c = [SELECT Id
                        FROM Contact
                        WHERE id = :longId
                        LIMIT 1];system.debug('++++cid'+c.id);}
        catch(QueryException e2){error=TRUE;}

 

  • September 11, 2012
  • Like
  • 0

Hi I am getting the error: "There is already a Child Relationship named" for the following fields for ANT script migration.

 

Error: objects/Bid_Request__c.object(658,13):There is already a Child Relationship named RFPs on User.
Error: objects/Bid_Request__c.object(681,13):There is already a Child Relationship named Bid_Requests on Opportunity.
Error: objects/Bid_Request__c.object(713,13):There is already a Child Relationship named Bid_Requests1 on User.
Error: objects/Bid_Request__c.object(725,13):There is already a Child Relationship named Bid_Requests on Contact.
Error: objects/Bid_Request__c.object(748,13):There is already a Child Relationship named Bid_Requests on Account.
Error: objects/Bid_Request__c.object(952,13):There is already a Child Relationship named Bid_Requests on User.

 

This is basically parent child relationship between, standard objects (Opportunity,User,Contact,Account) and new custom object "BidRequest".


When i first deployed from dev to sandbox the deployment worket fine.Then i deleted all the deployed custom objects.
Later when i again did a new deployment it failed.


What is really strange is on the target environment(sandbox) no custom fields exists with the above mentioned "relationshipLabel" but still i keep getting the error.

The Visualforce Developers Guide has this to say about the FIND String Fuction: 

FIND

Returns the position of a string within a string of text represented as a number. 

But it doesn't give an example or show the specific syntax. How many parameters are accepted? What's the order of the parameters? Can you specify what character position to start searching at?  

 

I tried: Integer position = FIND(solution, ',');

But get: 
Error: Compile Error: Method does not exist or incorrect signature: FIND(String, String) at line 19 column 36 
I tried a number of other combinations with no luck.  Searching for "find string function" didn't help.
RichFaces.tabPanel['ApexClassEditPage:theTemplate:theForm:thePageBlock:theTabPanel']={'ontabchange':'','id':'ApexClassEditPage:theTemplate:theForm:thePageBlock:theTabPanel'} ;

Hi,

 

I am writing an Apex trigger which contains code to match a phone number to a contact phone number. It should match numbers that contain different spaces between the digits (when people store them they may store them in different formats).

 

First I thought of pulling out all the contacts in a query, then cyling through them using the trim() function on a string to match them. This seems wasteful though and there might be more contacts than the maximum number of records you are allowed to return.

 

So I then thought of creating a new string from the phone number I am matching with a '%' before and after each digit. 

Eg. '07734654342' would become '%0%7%7%3%4%6%5%4%3%4%2%' then embedding that string in a query like:

//The phone string with the % chars is wildPhone Contact[] contact = SELECT Name FROM Contact WHERE Phone LIKE :wildPhone];

 I'm not sure if this will work, but more importantly how do I go about creating that string? I thought there would be a charAt() method on the string like in Java...I can't find one though.

 

Thank you for your help.

 

Matt

 

Our company uses four types of contracts and there can only be one of each type. i would like to create a picklist that only displays the available values. I can display all of the active types but how would I receive the inverse of this list.

 

For example, if the account already has Type 1 and Type 2 contracts then only Type 3 and Type 4 should be available in the dropdown.  Here is what I have so far.

 

 

public List<SelectOption> getAllContractTypes() { List<SelectOption> ContractTypes = new List<SelectOption>(); ContractTypes.add(new SelectOption('Type 1','Type 1')); ContractTypes.add(new SelectOption('Type 2','Type 2')); ContractTypes.add(new SelectOption('Type 3','Type 3')); ContractTypes.add(new SelectOption('Type 4','Type 4')); return ContractTypes; } public List<SelectOption> getActiveTypes() { List<SelectOption> options = new List<SelectOption>(); for (contract co : [SELECT Contract_Type__c FROM Contract WHERE Accountid =
:ApexPages.currentPage().getParameters().get('ctrc7') AND Active__c=TRUE]) { options.add(new SelectOption(co.Contract_Type__c,co.Contract_Type__c)); } return ActiveTypes; }

 

 

 

Hi guys,

 

I'm a beginner apex coder and I just wrote a small trigger to automatically create an account when you don't assign one to a new contact. It basically creates an individual account with the same name as the contact and then associates that account to the contact. Here's the code:

 

 

trigger CreateIndividualAccount on Contact (before insert, before update) {
Account[] acc = new Account[0];
RecordType arec = [SELECT ID from RecordType WHERE SobjectType='Account' AND Name='Individual' limit 1];
for (Contact c : trigger.new)
{
if(c.AccountID == null)
{
string cName = (c.FirstName + ' ' + c.LastName);
acc.add(new Account (Name = cName, RecordTypeId = arec.Id));

insert acc;
c.AccountID = acc[0].Id;
}
}
}

 

I tried importing contacts in my dev org and it works fine, but when I do it in production under a managed package it returns the error " INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call "

 

Does anyone know what I'm doing wrong? Again, these are some of the first lines of code I've ever written so it might be pretty obvious.

 

Thanks in advance.

 

 

Note: The account record type "Individual" does exist and is part of the managed package. Would i have to add the namespace prefix to the record type name?

 

  • December 22, 2009
  • Like
  • 0

Hello everyone,

 

 

I am very green to writing APEX and am hoping that someone might be willing to lend some advice. I have created a trigger that updates a Contact with queried information from Leads and Opportunities:

 

trigger PartnerPerformance on Contact bulk(before insert, before update){ Contact myContact = trigger.new[0]; public String getL() { if (l == null) l = 0; return '' + l; } integer l = [SELECT count() FROM Lead WHERE (lead.createddate = LAST_N_DAYS:180) AND (lead.Referring_Contact__c = :myContact.Id) LIMIT 100]; public String getQ() { if (q == null) q = 0; return '' + q; } integer q = [SELECT count() FROM Opportunity WHERE (opportunity.createddate = LAST_N_DAYS:180) AND (opportunity.Referring_Contact__c = :myContact.Id) LIMIT 1]; public String getC() { if (c == null) c = 0; return '' + c; } integer c = [SELECT count() FROM Opportunity WHERE (opportunity.closedate = LAST_N_DAYS:180) AND (opportunity.stagename = 'Closed Won') AND (opportunity.Referring_Contact__c = :myContact.Id) LIMIT 100]; if (myContact.Id != null) { myContact.Referred_Leads__c = l; myContact.Qualified_Leads__c = q; myContact.Closed_Won_Opps__c = c; } }

 

The challenge is that my Test Code only covers 40% and disregards all of my Public Strings. Can anyone provide an example of how to test the Public String established in the trigger? Thank you!

 

@istest private class PastPerformanceTriggerTest { static testMethod void canInsertPerformance(){ Account account = TestUtilities.setupAccountTestData(); Account partneraccount= new Account(Name = 'TestPartnerAccount', Phone = '(000) 000-0000'); insert partneraccount; Contact contact = TestUtilities.setupContactTestData(); Contact partner = new Contact(FirstName = 'Test', LastName = 'Partner', Partner_Tier__c= 'Standard', Phone = '(000) 000-0000', Email = 'unk@guidantfinancial.com', AccountID = partneraccount.ID); test.startTest(); insert partner; if(partner.Referred_Leads__c == 0){ System.Assert(false); } else{ System.Assert(true); } if(partner.Qualified_Leads__c == 0){ System.Assert(false); } else{ System.Assert(true); } if(partner.Closed_Won_Opps__c == 0){ System.Assert(false); } else{ System.Assert(true); } test.stopTest(); } static testMethod void canUpdatePerformance(){ Account account = TestUtilities.setupAccountTestData(); Account partneraccount= new Account(Name = 'TestPartnerAccount', Phone = '(000) 000-0000'); insert partneraccount; Contact contact = TestUtilities.setupContactTestData(); Contact partner = new Contact(FirstName = 'Test', LastName = 'Partner', Partner_Tier__c= 'Standard', Phone = '(000) 000-0000', Email = 'unk@guidantfinancial.com', AccountID = partneraccount.ID); insert partner; Lead lead = TestUtilities.setupLeadTestData(); Lead partnerlead= new Lead(FirstName = 'Test', LastName = 'One', Company = 'Test Company', Status = 'Outreach', Phone = '(000) 000-0000', Email = 'unk@guidantfinancial.com', ProductInterest__c = '401k Small Business Financing', Referring_Contact__c = partner.Id); Lead nonpartnerlead= new Lead(FirstName = 'Test', LastName = 'Two', Company = 'Test Company', Status = 'Outreach', Phone = '(000) 000-0000', Email = 'unk@guidantfinancial.com', ProductInterest__c = '401k Small Business Financing'); insert partnerlead; insert nonpartnerlead; Opportunity opportunity = TestUtilities.setupOpportunityTestData(); Opportunity opportunity1 = new Opportunity(Name = 'Test Partner Opportunity', AccountID = partneraccount.Id, CloseDate = date.today(), StageName = 'Closed Won', Areas_of_Interest__c = 'Business: Existing', Product_Interest__c = '401k Small Business Financing'); insert opportunity1; test.startTest(); update partner; if(partner.Referred_Leads__c == 1){ System.Assert(false); } else{ System.Assert(true); } if(partner.Qualified_Leads__c == 1){ System.Assert(false); } else{ System.Assert(true); } if(partner.Closed_Won_Opps__c == 1){ System.Assert(false); } else{ System.Assert(true); } test.stopTest(); } }

 

Message Edited by dbruns on 12-21-2009 11:43 PM
  • December 22, 2009
  • Like
  • 0

I've made some changes last week on some of my Appex classes and this morning with the same configuration and when I try to save my changes on the server I get this error message:

 

File only saved locally, not to server

 

So I've created a new project, a new workfolder and  made a checkout of everything and without even changing the code, I still get this error. I have some Appex pages too, but they work fine (compile ans save on server).

 

I notice on ''Monitor Deployment'' that the deployment status is supposedly completed and all my classes have the API version 15 but when I create new classes I can only select API version 16 now. Is this related to my problem?

 

Does some of you knows a good way to fix this?

I'm testing a trigger and in my test, I need to create a role and then I assign it to a user and insert the user. The test then hinges on that user having that role name. 

 

When I debug, I see that the role is created with that name and a new ID and when the user is created, the role id is the same as the new role created. However, the role name on the user is null. How do I set the role name?

 

Code snippets:

 

UserRole SomeRole = new UserRole(Name = 'Some Role');
      insert SomeRole;

 

[debug shows ID and name]

 

User SomeUser = new User(username = 'GAILTESTING@TEST.COM',
              email = 'test@example.com',
              title = 'test',
              lastname = 'test',
              alias = 'test',
              TimezoneSIDKey = 'America/Los_Angeles',
              LocaleSIDKey = 'en_US',
              EmailEncodingKey = 'UTF-8',
              ProfileId = PROFILEID, //this was set in some other code
              UserRoleId = SMERole.Id, 
              LanguageLocaleKey = 'en_US',)
    insert SomeUser;

 

[debug shows same role id from above but role name is null]

  • September 11, 2012
  • Like
  • 0

public class con1
{
account a
public account getinfo()
{
a=[select id,name,billingcity,phone from account where id=:apexpages.currentpage().getparameters().get('id')];
return a;
}
}

 

 

  • September 11, 2012
  • Like
  • 0

Hi,

We have a package that needs to query numerous contacts by email address. It could be as many as 50 email addresses. Typically, we use a bulk query like:

 

Set<String> EmailSet = new Set<String>();
//EmailSet is populated
[Select Id From Contact Where Email in :EmailSet];

 This works fine in orgs with fewer than 100k contacts, but we get non-selective query errors when there are more than 100k contacts. According to Salesforce, Contact Email is indexed, so the error is likely due to the IN operator. A (poor) alternative is to query a single email address at a time, which does successfully avoid the non-selective error, but then we quickly exhaust the 100 SOQL query governor limit since there is a lot of other processing going on aside from the contact retrieval. So we're stuck here - we can't use an efficient bulk query since it throws an error, and we can't use multiple selective queries since we hit the governor limit. Does anybody have advice on how to approach selecting a set of records from a 100k+ count object?

Thanks,
Earl

Hi Guys! I have an issue where a Try/Catch ALWAYS goes to the Catch when invoked from a test method. When invoked from Visualforce as normal this doesn't happen, so it has to be something in the test scenario.

 

It's the second SOQL statement below, which uses a field 'User_Contact_Link__c from the User. This is just a text field containing a Contact ID that matches a Contact record in the system.

 

Any ideas?????

 

Snippet below:

 

u = [SELECT SAG_Account_Creator__c,
                    SAG_Organization__c,
                    SAG_License_Country__c,
                    User_Contact_Link__c
             FROM User
             WHERE id = :UserInfo.getUserId()
             LIMIT 1];

ID convertToLong = u.User_Contact_Link__c;
        String longId = convertToLong;
 
        system.debug('++++UserCon'+u.User_Contact_Link__c);
        system.debug('++++Long'+longId);
        
        try{
            c = [SELECT Id
                        FROM Contact
                        WHERE id = :longId
                        LIMIT 1];system.debug('++++cid'+c.id);}
        catch(QueryException e2){error=TRUE;}

 

  • September 11, 2012
  • Like
  • 0

While deploying a class with its test class( coverage 100%) I got error msges. The errors are in the test classes which have already been deployed into the production. It said the code coverage for 4 test classes which are already in production is less than 75%. I made the necessary changes and made the code coverage more than 75% for all the 4 test classes and tried to deploy the classes. But again am getting the same error messages.

 

How to solve this problem?

 

 

Please help me.

Hi,

 

I'm using ApexDataLoader.exe version 17 and I want to update it to version 25 (up to date version).

Do I simply replace the exe files?

Where can I read more details about the changes done from one version to another? (changes, features, bug fixes, etc...)

 

Thank you

 

  • September 11, 2012
  • Like
  • 0

Hi,

 

In my application I have an object namely "Position".

 

In Position object I have a field called Description. This is a text are field.

 

Hereafter I want this description field as Checkbox.

 

If I change the datatype of Description field to Checkbox, data in this field for already created records will be lost.

 

So I have created a new field as Description1 using Checkbox datatype.

 

Now my requirement is,

 

For existing Position records - display the Description field if it has any value and hide Description1. If it doesn't have any value hide Descrption and show Description1. 

 

For new Position records - only display the Description1 field.

 

Position page is standard page not a visualforce page. So I want to do this without using visualforce page.

 

 

Thanks,

Arunkumar

Are deployments are starting to take an exceedingly long amount of time.  We have about 600 apex tests and it's now taking hours to run them.  Since we need to do several validations to flush out any deployment issues, it's really putting a damper on our release cycle.

 

Anyone else have this problem?

 

 

What I've noticed looking at some logs of tests is a huge amount of time is spent inserting test data.  I know it's best practice to insert data specifically for testing rather than rely on data alredy there.  But, it is take many seconds just to insert and Account.  More than half of that is territory processing.

 

I don't want to have to rewrite all our tests to work of data already in the database but I want to come up with some way to speed up the validation.

 

The help for "Using Rich Text Area Fields" (https://na5.salesforce.com/help/doc/en/fields_using_rich_text_area.htm) says:

 

  • There are no limits to the number of rich text area and long text area fields that an object can contain, although your Edition's limit for the total number of custom fields allowed on an object, regardless of field type, applies. Each object can contain a total of 1.6 million characters across long text area and rich text area fields. The default character limit for long text area and rich text area fields is 32,768 characters. A long text area or rich text area field needs to contain at least 256 characters.

 

Does this mean that a single record can have at most 1.6 million characters in rich/long text fiels, or that all the rich/long data for an entire object can't exceed 1.6 million?

Hello All,

 

I am trying to create fields in salesforce through Force.com IDE.

 

But i am getting an error: 

 

Unable to synchronize resource 'Ownership__c.object' to server:
classcastException:
com.salesforce.ide,api.metadata.types,Metadata$JaxbAccessorF_fullName cannot be cast to com,sun.xml,internal.bind,v2,runtime.reflect.Accessor.
Reason:
com.salesforce.ide,api.metadata.types,Metadata$JaxbAccessorF_fullName cannot be cast to com,sun.xml,internal.bind,v2,runtime.reflect.Accessor.

 

Kindly advice.

 

Thanks

 

Anwar

 

  • September 10, 2012
  • Like
  • 0

Hi I am getting the error: "There is already a Child Relationship named" for the following fields for ANT script migration.

 

Error: objects/Bid_Request__c.object(658,13):There is already a Child Relationship named RFPs on User.
Error: objects/Bid_Request__c.object(681,13):There is already a Child Relationship named Bid_Requests on Opportunity.
Error: objects/Bid_Request__c.object(713,13):There is already a Child Relationship named Bid_Requests1 on User.
Error: objects/Bid_Request__c.object(725,13):There is already a Child Relationship named Bid_Requests on Contact.
Error: objects/Bid_Request__c.object(748,13):There is already a Child Relationship named Bid_Requests on Account.
Error: objects/Bid_Request__c.object(952,13):There is already a Child Relationship named Bid_Requests on User.

 

This is basically parent child relationship between, standard objects (Opportunity,User,Contact,Account) and new custom object "BidRequest".


When i first deployed from dev to sandbox the deployment worket fine.Then i deleted all the deployed custom objects.
Later when i again did a new deployment it failed.


What is really strange is on the target environment(sandbox) no custom fields exists with the above mentioned "relationshipLabel" but still i keep getting the error.

hi,

 

I have tried to create enterprise.jar file. but i am getting the following error.

 

Location of the files:

D:\Program Files\Java\jdk1.6.0_30\lib---->wsc-22.jar

                                                                   ----->enterprise.wsdl

 


D:\Program Files\Java\jdk1.6.0_30\lib>java -classpath "D:\Program Files\Java\jdk
1.6.0_30\lib\wsc-22.jar" com.sforce.ws.tools.wsdlc enterprise.wsdl enterprise.ja
r
[WSC][wsdlc.run:312]Created temp dir: C:\DOCUME~1\abins9\LOCALS~1\Temp\wsdlc-tem
p-2576323047246107284-dir
Exception in thread "main" com.sforce.ws.wsdl.WsdlParseException: Parse error: e
nterprise.wsdl (The system cannot find the file specified)
        at com.sforce.ws.wsdl.WsdlFactory.create(WsdlFactory.java:61)
        at com.sforce.ws.tools.wsdlc.<init>(wsdlc.java:75)
        at com.sforce.ws.tools.wsdlc.run(wsdlc.java:312)
        at com.sforce.ws.tools.wsdlc.main(wsdlc.java:303)
Caused by: java.io.FileNotFoundException: enterprise.wsdl (The system cannot fin
d the file specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(Unknown Source)
        at java.io.FileInputStream.<init>(Unknown Source)
        at com.sforce.ws.wsdl.WsdlFactory.create(WsdlFactory.java:58)
        ... 3 more

D:\Program Files\Java\jdk1.6.0_30\lib>

 

  • September 07, 2012
  • Like
  • 0

When I try to deploy via ant migration tool.  Have not tried any other way because I want to deploy this local copy I have, not what is on the server.

 

1) Upon error about 16 seemingly random classes are listed along with the error.  None of my code implements batchable.

2) I have pushed this same code to multiple other orgs.

3) Under Setup->Monitoring->Apex Jobs there is nothing with status other than "Completed" or "Aborted".

4) Under Setup->Monitoring->Scheduled Jobs there is nothing scheduled with type "Scheduled Apex".

5) I executed the following code in hopes of killing zombie jobs:

 

for(AsyncApexJob aaj : [SELECT Id FROM AsyncApexJob]) {
 System.abortJob(aaj.Id);
}

None of this worked.  Error on deploy.  At this point im fairly confident its an sfdc issue but maybe the community has ran into this and has some secret knowledge.

 

Thanks

I'm puzzled

 

Running Eclipse Helios and Force.com IDE plug 20.0.1

 

  • On 2011-05-20, our Sandbox was on Spring 11.  If I used the IDE and did Run Tests on class Foo, I got a full debug log of the entire class execution in the Apex Test Runner view
  • On 2011-05-23, after our Sandbox was upgraded to Summer 11, running the exact same test in the IDE on class Foo yields a vastly truncated debug log in the Apex Test Runner view. The log is only about 130KB.

 

I know the code executes to completion because the same Run tests in the Force.com browser Apex Classes | Run Tests yields a debug log of 3300KB using the same log filters.

 

As far as I can tell, it is something about Summer 11 and how the Eclipse IDE version 20.0.1 obtains the debug log.

 

Any ideas greatly appreciated (I'm already filtering the log to LoggingLevel.INFO and thus avoiding the noise; but I need more than 130KB of debug log to analyze my execution).