• ca_peterson_old
  • NEWBIE
  • 159 Points
  • Member since 2010

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 78
    Replies

I have an Apex method that is marked as a remoteAction which is attempting to take two parameters: a Lead and a List of custom objects ("Custom_Object__c" isn't the real object's name, just changed to protect the innocent);

 

@RemoteAction
public static Boolean insertData(Lead l, List<Custom_Object__c> customObjects) {
   // insert the Lead
   insert l;
   // assign the lead Id to each custom object in the list
   for(Custom_Object__c c : customObjects) {
      c.Lead__c = l.Id
   }
   // insert the custom objects
   insert customObjects;
   // return true (just for example)
   return true;
}

 Over in Javascript, I'm calling this remoteAction with the following data:

// sample data
var lead = {
   FirstName = 'Test',
   LastName = 'Test',
   Company = 'Test',
   Email = 'test@test.com',
   Phone = '555 555 1212'
};
var customObjects = [
   {
      Custom_Field1__c = 'A',
      Custom_Field2__c = 'B'
   },
   {
      Custom_Field1__c = 'A',
      Custom_Field2__c = 'B'
   }
];
MyApexClass.insertData(lead, customObjects, function(result, event) {
   // this would be the callback mojo
});

This code will make it as far as the insertData method, but I get the following error:

 

Visualforce Remoting Exception: undefined

 

I tried changing the insertData method to take the second parameters as List<sObject> instead of List<Custom_Object__c> (and modded the code to use dynamic DML to support this), but then I get this error:

 

Visualforce Remoting Exception: Unable to determine SObject type: SObject.  Please provide an 'id' or 'sobjectType' value.

 

I interpret this error as needing to supply a 'sobjectType' property to either a) the elements in my "customObjects" array or b) the array itself. I've tried all of the following permutations but still get the same error:

 

// ... add the property to the element doesn't work
var customObjects = [
   {
      Custom_Field1__c = 'A',
      Custom_Field2__c = 'B',
      sobjectType = 'Custom_Object__c'
   },
   {
      Custom_Field1__c = 'A',
      Custom_Field2__c = 'B',
      sobjectType = 'Custom_Object__c'
   }
];

// add the property to the array doesn't work customObjects.sobjectType = 'Custom_Object__c'; // for fun, tried to indicate that it's a list, these don't work either customObjects.sobjectType = 'List<Custom_Object__c>'; customObjects.sobjectType = 'Custom_Object__c[]';

 

Can someone point me in the right direction here? Is there another way to specify the sobjectType property? Are there issues with multiple params on a remoteaction, or issues with collection-based params? 

I'm curious what is the best way to login and authenticate users for Apex methods exposed as web services. Should the user just login with the partner or enterprise wsdl login operations?

 

The problem I see with this approach is the serverURL retruned with these login operations is something like: https://cs2-api.salesforce.com/services/Soap/u/23.0/00DR0000000GHhW .

 

Yet the URL in the wsdl for my Apex web service is something like this: https://cs2-api.salesforce.com/services/Soap/class/ClassName. 

 

Unless I am missing something you have to eithe...

A) hardcode the apex url or

B) Extract the base URL returned form the login response so you get the right instance and then store and append the relative Apex part of the url.

 

Thoughts? Insights?

 

I'm thinking of creating an idea so that wsdls created from Apex methods also have some basic operations like login.

 

Thanks,

Jason

Hi All,

 

I'm trying to copy some custom objects that have a rich text field included in them from a sandbox org back to it's production org. I've tried doing this with the data loader but the images came over as broken links - likewise with copying and pasting the data between orgs.

 

Is there really no way to move the image data over along with the rich text fields? This seems like a major oversight if so.

 

Hi Everyone,

 

 

I would like to check logged user role with a role of particular record owner. If logged user role is on top of the record owner user role then I would like to show a visualforce page. any idea How to do that it very simply ?

 

Thanks in advance !

Hi Guys,

 

I have two objects Target List and Selling Area. Also have Target List Member object as junction of both. User can create target list and add selling area based on some search criteria. I am storing that SOQL in query field of Target List. Overnight batch to run through all target list get the query and iterate over query result and insert Target List Member records. But Batch class gives me Too Many DML rows error while insertion.

 

I am testing this with 4 target lists Each of them have separate query. These quries return 2764 records of selling area. Means 2764*4 target list members.  Now requirement is one target list can have up to 50K-80K selling area, so setting scope to 1 won't solve my problem. Any suggestion or workaround?

 

Thanks,

Ankur

 

Hi All, i am getting some problem about licence management..Let me explain you. Suppose i have created A managed package(Which Contains my App say "Recruiting").i have installed LMA in my sales org,and listed my App in Appexchange.. Now Subscriber can install my App.... and all the things(like how many no. of licencses he is using) we can track through LMA.. Now if i have given him 10 licenses to subscribber..and if for our App subscribers Admin is using 5 customer portal licese and 5 salesforce platform.... and i want to charge for my App according to licese he has..(say 100$ for salesforce platform and 50$ for customer portal license).... can i do this??? How?

 

Hi,

 

I want to know if we have multiple user profiles set in the org. Then can we get counts by user types in LMA.

 

For e.g. I sell the product with 10 licenses. I create two user types...Type 1and Type 2. I create 3 Type 1 users and 4 Type 2 users manually from Admin profile. Then in LMA can I get the count separately? 

 

 

Regards,

Devendra S

Hello All,

I 'd an issue regarding sending emails using singleemailmessage class. Heard that we can send 10 * 1000 = 10000 emails per execution (10 arrays, each array to accomodate 1000 emails). Is this true?

But i am unable to send more than 10 emails. Could anyone plz clarify me how to do. PFB my code snippet:

 

            }

for(Permit__c p:permitList){
                 Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); 
                                    String subject = p.Name+' | '+p.Region__c+' | '+p.Full_State__c+' | '+p.Channel__c+' | Status=Expired';
                                    email.setSubject(subject);
                                    String emailadd = 'abc@xyz.com';
                                    String[] toAddresses = emailadd.split(',');
                                    email.setToAddresses(toAddresses);
                                    email.setHTMLBody( 'email body.' );
                 Messaging.SendEmailResult[] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); 

 

 

An error is being thrown when 10 mails are sent and is about to send 11th email.

Plz help!

Has anyone been able to get jQuery to work in a custom button for a standard page layout?  All the examples I can find are on custom VF pages :(

 

Example code or a link to example code would be very much appreciated.

 

Thank you.

Hey guys-

I need to create a trigger on the account object that does the following:

  • Look at the Account Owner’s User Record
  • Look at the “Region” field on the User Record
  • Update the “Apex Region” field on the Account Object based on the Region value from the User’s Record

 

I have a similar trigger that works perfectly for a text field, but I would like to set this up as a picklist (for easier reporting).

 

Here’s the code that I'm trying (it complies but doesn't update the picklist)-

 

 

trigger ApexTestTrigger on Account (before insert, before update) {

// create a set of all the unique ownerIds  
       Set<Id> ownerIds = new Set<Id>();  
       for (Account a : Trigger.new)  
           ownerIds.add(a.OwnerId);      
     
    // query for all the User records for the unique userIds in the records  
       // create a map for a lookup / hash table for the user info  
       Map<Id, User> owners = new Map<Id, User>([Select Region__c from User Where Id in 
       :ownerIds]);     
     
       // iterate over the list of records being processed in the trigger and  
      // set the Region before being inserted or updated  
      for (Account a : Trigger.new)  
           a.Apex_Region__c = owners.get(a.OwnerId).Region__c;   
}

 Help would be greatly appreciated!

 

Dear All,

 

I have been involved in a rather frustrating email exchange with Salesforce support (both partner and 'premier' support) but I simply cannot believe what they are saying is true.

 

We signed up for our first development org in October 2007 where we started to build a managed package to manage our support cases, timesheets and invoicing for our Unlimited Edition instance.  I contacted my Salesforce account manager at the end of March 2011 and asked him to enable Entitlements in our live Unlimited Edition org.  At the same time I contacted Salesforce support and asked them to enable Entitlements in our Developer Edition org so that we could integrate the Entitlements functionality into our managed package.  This was the response I received:

 

 

Developer Edition (DE) orgs created before this feature was made available (164 release, which was after your dev org was created) will not have this feature enabled.  Anyone wanting to use this feature in a DE org, should sign-up for a new DE org on the page below: (link to sign up page)

Huh?  So what Salesforce are saying is that any developer who has an older org (i.e who has been a Salesforce customer for longer) will not get access to any new Salesforce.com functionality.   If a developer wants to get access to the new functionality and ultimately help increase Salesforce.com's revenues they need to create a new package and migrate all of their customers' data from the old objects in to the new objects?  Seems slightly odd and very counter productive!  I can't imagine if likes of BMC / DreamFactory / Vertical Response have Developer Edition instances on NA5 that they would have been given the same response!

 

I decided to contact my account manager to see whether this response was just due to a momentary lapse on the part of the support rep, as I couldn't beleive it was true!  Apparently it is.  Salesforce will not enable new functionality in old developer edition orgs!  If this is true, then it does pose an interesting question.  Are the Developer Edition orgs the same as the live ones?  Surely in the world of SAAS and after a major upgrade by the hosting provider everyone should be on the same version of the 'software'?

 

Has anyone else come across this issue?  If so, how did you fix it?  I know that Salesforce do support behind the scenes migration of development orgs as we have recently had a publishing org migrated from NA7 to NA10, so I know that it can be done, but I do not understand why it hasn't been offered!

 

Please can anyone help?

 

Salesforce, is anyone able to put right what seems like a very simply administrative mistake and get our org moved or updated so we can integrate entitlements into our business processes!

There is a custom picklist field (payment__c) in Account, same as in Quote

 

Ok, if one people create an Account (also select one payment in it), and then create one opportunity, and then click 'add new Quote', the payment__c will be got automatically before save the quote (because it's same as Account's payment__C).

 

Is it possible? Anyone can tell me how to do it? Or will one trigger?

 

Thanks.

I have a trigger on a custom object which depending on some criteria; it is supposed to create a list of emails to send.  I have created the trigger and it works fine.  Code coverage is 100%.  I’m ready to deploy it to production.

 

I’m calling a future method to process the records asynchronously.  I was expecting to be able to pass a list of account Ids created from my 2000 records to the future method to process but the trigger gives me 200 records at a time.  By the time the test method is done running, I’m very close to the limit of Number of future calls I can make.  What I really wanted and expected was for the future method to be called once and for all the processing to happen there.

 

Why does the trigger or apex automatically break up the 2000 records into bunches of 200 and process them separately? 

 

10:18:45.395|METHOD_EXIT|[7]|testAWAfterInsert

10:18:45.395|METHOD_ENTRY|[69]|System.debug(ANY)

10:18:45.395|USER_DEBUG|[69]|DEBUG|********** TEST 5 **********

10:18:47.357|METHOD_EXIT|[84]|system.Test.startTest()

10:18:47.358|DML_BEGIN|[85]|Op:Insert|Type:Actuals_Weekly__c|Rows:2000

10:18:48.160|USER_DEBUG|[19]|DEBUG|********** newAWs.size = 200

Number of future calls: 1 out of 10

...

10:18:55.859|USER_DEBUG|[19]|DEBUG|********** newAWs.size = 200

Number of future calls: 10 out of 10 ******* CLOSE TO LIMIT

 

Here is my trigger:

trigger AWTriggers on Actuals_Weekly__c (after delete, after insert, after undelete,after update,

                                         before delete, before insert, before update) {

   

    if(trigger.isAfter){

                      if(trigger.isInsert){

                                              AWAfterInsert myAfterInsert = new AWAfterInsert(Trigger.new);

                        }

                        if(trigger.isUpdate){}

                        if(trigger.isDelete){}

                        if(trigger.isUndelete){}

    }

   

    if(trigger.isBefore){

                        if(trigger.isDelete){}

                        if(trigger.isInsert){}

                        if(trigger.isUpdate){}

    }

}

Here is my class:

public with sharing class AWAfterInsert {

 

                        public AWAfterInsert(Actuals_Weekly__c[] newAWs){

                                                NotOrderedMGA14(newAWs);

                        }

                        public static void NotOrderedMGA14(Actuals_Weekly__c[] newAWs){

                                                System.debug('********** newAWs.size = ' + newAWs.size());

                                               

                                                Set<Id> accountIds = new Set<Id>();

                                                for(Actuals_Weekly__c aw : newAWs){

                                                                        accountIds.add(aw.Account__c);

                                                }

 

                                                AWGlobalUtils.asyncNotOrderedMGA14(accountIds);

                        }

}

Here is my future method:

global class AWGlobalUtils {

 @future public static void asyncNotOrderedMGA14(Set<Id> accountIds){

  System.debug('****************************** accountIds.size = ' + accountIds.size());

  list<Actuals_Weekly__c> awl = Database.query('Select Id, Procedure__c, Read_Date__c, Account__c, Account__r.Name, Account__r.OwnerId From Actuals_Weekly__c Where Procedure__c = \'MOLECULAR GRADING ASSAY\' And Read_Date__c < ' + getTargetDate() + ' And Account__c in : accountIds');

  System.debug('********** awl.size = ' + awl.size());

  Map<Id,Actuals_Weekly__c> am = new Map<Id,Actuals_Weekly__c>();

  if(!awl.isEmpty()) {

   for(Actuals_Weekly__c aw2 : awl){

    am.put(aw2.Account__c,aw2);

   }

  }

  System.debug('********** am.size = ' + am.size());

  // Send an email to each account owner

  list<Messaging.SingleEmailMessage> el = new list<Messaging.SingleEmailMessage>();

  for(Actuals_Weekly__c aw3 : am.values()){

   Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

   mail.setTargetObjectId(aw3.Account__r.OwnerId);

   mail.setSaveAsActivity(false);

   mail.setPlainTextBody('Your account: ' + aw3.Account__r.Name +' has not ordered MGA in the past 14 days.');

   mail.setHtmlBody('Your account:<b> ' + aw3.Account__r.Name +' </b>has not ordered MGA in the past 14 days.<p>'+

   ' To view the account <a href=https://cs1.salesforce.com/' + aw3.Account__r.Id + '>click here</a>');

   el.add(mail);

  }

  System.debug('********** el.size = ' + el.size());

  if(!el.isEmpty()){

   Messaging.sendEmail(el);

  }

 }

}

Here is my test method:

@isTest

private class testAWAfterInsert {

 static testMethod void AccountHasOrderedBulkTesting2(){

   System.debug('********** TEST 5 **********');

   List<Account> testAL = new List<Account>();

   for(integer i=0; i<200; i++){

    testAL.add(new Account(Name = 'Test Account ' + i, Account_Classification__c = 'Doctor'));

   }

   insert testAL;

   Date d2 = date.newinstance(2011, 1, 17);

   List<Actuals_Weekly__c> testAWL2 = new List<Actuals_Weekly__c>();

   for(Account a : testAL){

    for(integer i=0; i<10; i++){

     testAWL2.add(new Actuals_Weekly__c(Account__c = a.Id, Read_Date__c = d2, Procedure__c = 'MOLECULAR GRADING ASSAY'));

    }

   }

   test.startTest();

   insert testAWL2;

   test.stopTest();

 }

} 

Hi

 

I've  a custom field in a custom object. I'm posting an xml file through external API. It is posted successfully. Now I want to map that data into Contact Object. I'm facing too many Script statements.

 

My code is:

 

 

trigger dmldata on CnPData__c (before insert,after insert) {
String dataxml;
    for(CnP__CnPData__c cpdata:Trigger.new){
         dataxml=cpdata.CnP__DataXML__c;
    }
    System.debug('hiiiiiiiii'+dataxml);
    XmlStreamReader reader= new XmlStreamReader(dataxml);
    System.debug('reader valueeee'+reader);
    while(reader.hasNext()) {
    System.debug('reader event nameee'+reader.getEventType());
     /*if (reader.getEventType() == XmlTag.START_DOCUMENT) {
     System.debug('local nameee'+reader.getLocalName());
    
}*/
}
 
}
My sample xml in the field is :
<?xml version="1.0" encoding="utf-8"?>
<Contact>
 <FirstName>anu</FirstName>
    <LastName>rrr</LastName>  
 </Contact>
One more, If I debug the reader.getEventType() it is showing the Start_Document. I want this value as START_ELEMENT. how can I get that?
If it START_DOCUMENT how can I proceed with that to read the values.
Thanks a ton in advance.

 

Is it possible not to render apex:component in SPAN,  just let it rendered whatever I've coded

I have an Apex Class that is Schedulable.  What is the proper way to package this class so that when a user installs it into their org it automatically schedules the class to run?

I am playing with the translation workbench and a managed package.

 

It seems that you cannot rename the "Tab Name" and "Display Name" for a custom object when you install the package in an org where the translation workbench is enabled.

 

It works for any other field but not this one, the edit link is not displayed.

 

Is there a reason for this or did I miss something ?

 

Thanks