• jeremyfrey1
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 25
    Replies
Here's our problem:
 
We're using the partner WSDL, and we're trying to write a custom data loader for one of our users that will provide additional business logic after that user uploads a CSV file.  Each record in the CSV contains a Contact ID, and additional information, which will used to drive inserts into Event and CampaignMember.  One of my requirements is to display a list of errors in creating those records back to the user, so he can modify his CSV file and re-upload, without creating duplicates.  Obviously, I want to use batching on the creates, but this poses a problem of matching up sObject to SaveResult.  My SaveResults will contain those Objects' primary keys (00U and 00v for Event and CampaignMember, respectively), but not the sObject I used to create them, nor the ContactID I used as a foreign key for both objects.
 
My question is -- can I assume that the create call is FIFO?  I.e., if I upload sObjects a,b,c,d,e, can I be sure that my results a,b,c,d,e will be sent back in that order?
 
Thanks for the help!
 
- Jer
Hello there,
I have a requirement to create a salesforce lead from a flex application using the flex apex tool kit (i.e., lead enters the details on a flex form, and the same is created in SFDC at the background). Is there a way I can do this like any typical JSP or ASP web2lead where we post the form ? Any hints would be helpful !



Thanks,
Arun B
I've built a simple trigger that will stop an update to a record based on a user's profile.  In building a test method for this trigger, I don't see any way to simulate both sides of the processing, since the logic in the trigger is dependant on the results of the getUserInfo calls. 
 
The issue, is how to get to 100% code coverage in a test method in this sort of situation?
 
What I'd like to be able to do in my test method is the following:
 
using my current admin login,
update 200 records  (These would succeed, as the admin profile is allowed to make the updates)
 
switch login to a non-admin user login
update 200 records (These would not succeed, and the addError would be applied to the appropriate fields)
 
Jon Keener
 
Hi Everyone,
 
I'm very new to Apex code and am following the sample app that was introduced at the Salesforce Tour de Force show and attempting to learn the language.  I've created the following Apex class, but now need to unit test it and I just can't figure-out how to do it.  The workbook doesn't provide any instructions on how to write it and I've tried without success to get something running.

I talked to someone who knows Apex code and they indicated it would only take 7 or 8 lines of code to sufficiently test the attached code that would enable me to deploy it to my sandbox, but I really need some help here.
 
I know this is asking a lot, but could someone provide me what I need to test this code - with some remarks as well?  I would REALLY appreciate it!!
 
Here's the code:
 
Code:
public class MileageUtil {
 static final integer MAX_MILES_PER_DAY = 500;
 
 public static void areMilesAllowed(Mileage__c[] miles)  {
  Double totalMiles = 0;
  String createdbyId = UserInfo.getUserId();
 
 /* adds miles that were created in previous requests for today */
 for (Mileage__c mq: [select miles__c from Mileage__c
  where Date__c = TODAY and
  createdById = :createdbyId and
  miles__c != null]) {
  totalMiles += mq.miles__c;
 }
 
 /* Totals the miles in the request */
 for (Mileage__c m:miles)  {
  totalMiles += m.miles__c;
  if (totalMiles > MAX_MILES_PER_DAY)
    m.addError ('Mileage request exceeds daily limit: ' + MAX_MILES_PER_DAY);
 }  
  }
}

 
  • May 04, 2008
  • Like
  • 0
Hello,

I'm trying to set up a test method that looks something like this:

Code:
    static testMethod void testFunction() {

        // Make object
        MainObject mo = new MainObject();

        // Test object with integration set to true               
        Id[] testObjTrue = new Id[1];
        testObjTrue[0] = 'a0440000006f2cQAAQ';  // An object with Value__c = true
        Test.setFixedSearchResults(testObjTrue);
        mo.load();
        System.assert(true == mo.getValue());  // getValue() just returns this.value
    }

    public void load() {

        boolean value =
            [select Value__c
                from Main_Object__c where Name = 'MO-0000'].Value__c;
        this.value = value;
    }

As you can see from the code above, I want

However, the assertion is failing, because it's actually getting the object with Name = MO-0000 in load() (where Value__c = false) instead of using my fixed search result that I'm setting in the test method (where Value__c = true as expected).  I want to be able to do the testing without having to change MO-0000 and alter existing data.  Am I doing something wrong?  How can I do this?
  • May 01, 2008
  • Like
  • 0
I have written this code block,
trigger Firm_LOB_Check on Fund__c (before insert, before update) {
for (Fund__c lfund : Trigger.new) {
Firm__c f  = [select Line_Of_Business__c FROM Firm__c where Id = :lfund.Firm__c];
f.Name.AddError('Error');
}
}
 
I get the below mentioned error message when the trigger gets fired. If anyone got an idea please share.
 
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Firm_LOB_Check3 caused an unexpected exception, contact your administrator: Firm_LOB_Check3: execution of BeforeInsert caused by: System.Exception: SObject row does not allow errors: Trigger.Firm_LOB_Check3: line 10, column 1
  • April 25, 2008
  • Like
  • 0
How do you get the results for a relationship?
 
Code:
var sql = "Select Doctor__r.OwnerId,Doctor__r.Name,Name,First_Name__c,Last_Name__c,Id  from Patient__c where Id = '" + records[i].get("Patient__c") + "' Limit 1";
         var patqr = sforce.connection.query(sql);

newCell.innerHTML = patqr.getArray("records")[0].get("Doctor__r.OwnerId");

 
I get a null. Should it be <Doctor__c> ???
  • April 24, 2008
  • Like
  • 0
Hi all:
I have a field "Site"... Now this field has to equal the same exact value that is in Status_Description which is a picklist. Now I have the following code that I try to write Obviously it is not working: Please help:
Code:
My Trigger
trigger accountsiteupdate on Account (after update) 
{
if (Trigger.isBefore){ 
Account[] accs=Trigger.new; 
acct_site_update.addacctsiteupdate(accs);
}
}

My Class
public class acct_site_update 
{
// This class updates the Account Site field on 
//account records that are
// passed to it.
public static void addacctsiteupdate(Account[] accs)
{
for (Account a:accs)
{
if (a.Site != a.Account_Status_Description__c) 
{
a.Site = a.Account_Status_Description__c;
}
}
}
}



 
Where did I got wrong?
Thanks
Shan
Hi,

Is there a timer functionality in Apex?  I want to be able to schedule some operations on a periodic basis.

The second related question is to invoke something that is only accessible from a UI control (from an installed package for which either the backend code or the web service is not available).  Is it possible to simulate a mouse click based on a timer event?

Thanks in advance!
Hi,
 
I am trying to access a look up field data from a web page but it is working when i select any listed data in a lookup data listing
page
 
here, I found some stuff from the community board
 
 
 
In which, it is stated that you can not access any lookup field from web to lead form
 
 
I have put all the html code in s-Control then that lookup field is working fine but when I copied the same html in external server
page and called in a salesforce webtab then it is not workable for me.
 
So, Kindly suggest me any alternatives / solution on this
 

Thanks & Regards
Rameshwar
Hi,
 
is there any feature in sfdc like it automatically sends or publish the data to the outer applications for any data changes
e.g: if a account is created or modified in sfdc in automatically sends to outer application through web service. currently im using the GetUpdatedValues method to get the data, but i need it automatically.
please let me know if any one has idea on this.
 
thanks,
Naag.
  • April 18, 2008
  • Like
  • 0

Hi,

  I am using Enterprise WSDL with VB.Net 2.0. I Want to return ADO.NET datatabe / dataset  based on the below code:-

 

Dim qr As QueryResult = Nothing

qr = binding.query("select id, Website, Name from Account")

If qr.size > 0 Then

Dim account As Account = CType(qr.records(0), Account)

Dim Id As String = account.Id

Dim Website As String = account.Website

 End If

  • So, I would like to return all the rows of account QueryResult  as a datatable ? What would be the best way? 
  • Do you provide any CreateDataTable methods in the webservice ?

Regards,

Hello.

I have had nothing but trouble deploying/updating/activating triggers in EE (no problem in DE).  I check the forums and found many people saying the same thing.  However I assume than most people are able to deploy/run triggers in EE without a problem?  Please respond if you're able to reliably work with Apex in EE.

Thanks
Chris


  • April 15, 2008
  • Like
  • 0
Here's our problem:
 
We're using the partner WSDL, and we're trying to write a custom data loader for one of our users that will provide additional business logic after that user uploads a CSV file.  Each record in the CSV contains a Contact ID, and additional information, which will used to drive inserts into Event and CampaignMember.  One of my requirements is to display a list of errors in creating those records back to the user, so he can modify his CSV file and re-upload, without creating duplicates.  Obviously, I want to use batching on the creates, but this poses a problem of matching up sObject to SaveResult.  My SaveResults will contain those Objects' primary keys (00U and 00v for Event and CampaignMember, respectively), but not the sObject I used to create them, nor the ContactID I used as a foreign key for both objects.
 
My question is -- can I assume that the create call is FIFO?  I.e., if I upload sObjects a,b,c,d,e, can I be sure that my results a,b,c,d,e will be sent back in that order?
 
Thanks for the help!
 
- Jer
Hi,
 
I am facing problem in setting the standard Task.ActivityDate by using .NET  
It shows me following error
 
+++++++++++++++++++++++++++
'4/11/2008' is not a valid value for the type xsd:date
 
'4/11/2008 12:00:00 PM' is not a valid value for the type xsd:date
'2008/4/11' is not a valid value for the type xsd:date
 
+++++++++++++++++++++++++++
 
 
Can anybody give me idea how to set the date in a standard object field ?
 
Help me to pull out from this problem
 
Thanks
 
Rameshwar
 
Hi,
 
I wrote some apex codes . It runs well in the developer environment,but when I deploy it into the production environment , the error message "Unable to perform save on all files: NumberFormatException: For input string" always shows up.
I write the codes with Force.com IDE.
 
Here is a sample:
 
Code:
public class CreateAccount {
 public static void verifyDealer(Account a){
  //if(UserInfo.getProfileId()=='00e20000000lJU1AAM') {
   a.addError('access denied');
  //}
 }
 
 static testMethod void test_verifyDealer(){
  Account a = new Account(Name='test');
  CreateAccount.verifyDealer(a);
 }
} 

 
Any help would be appreciated!
 
Thanks & Regards,
 
Kevin
Maybe I'm missing the obvious here, but I can't figure out how to deactivate a trigger in a production environment. I created a simple trigger in the sandbox, tested and deployed it to production. Everything works fine and the trigger works as expected in production. However now I would like to deactivate and/or undeploy it from production. In the sandbox I can edit the trigger and uncheck the IsActive field, but I can't edit the trigger in production (I am the system administrator) because there is no Edit link.

I tried deactivating in the sandbox and then redeploying to production, but that didn't work either. Do I need to write a deployment script, access the metadata, use Ant? Without the ability to roll back triggers from production, I can't use Apex. What am I missing? I searched all the documentation and this forum and didn't find anything other than references to the UI checkbox, which doesn't exist in production.

Mark

Message Edited by MarkL on 02-21-2008 09:48 AM