• Tom DJ
  • NEWBIE
  • 100 Points
  • Member since 2010

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 14
    Replies

I am new to SFDC. I am using Developer Edition. My friends told me that i can create apex classes and triggers in the Developer Edition. But somehow when i login to DE and go to develop->apex triggers, i dont see the "new" button to create a trigger. What i am doing now is create a sandbox out of the DE and creating triggers there. So is there somethign i am missing? do i need to change any config settings to enable apex triggers in DE?

hi

 can any one help me pls

 

 i am trying to pass a list from one visual force to other

 

 is it possible

 

thanks 

mahabub

 

I need to convert a number field of a queried record to a string and then use that
string in a dynamic SOQL query.   If the number has a large number of digits, the
converted-to string contains an exponent (e.g.  1.321135422343E10).   If I then
do a dynamic query for records that contain that number I get an exception.

I need a way to convert the internal number to a string that never returns
an exponent in the resulting string.

Example SOQL query:
  select Name,Id,OwnerId  from Lead WHERE (mynumberfield__c = 6.9935297349E10)
 
Resulting exception:
    System.QueryException: unexpected token: 'E10'
   
Here is a simplified example othe code that converts a record field value
to a string and then uses that converted string to do a dynamic SOQL query:

 

  String fieldname = 'mynumberfield__c';
  sObject dRecord = [select :fieldname FROM someObject limit 1];
  Map<String, Schema.SObjectField> schemafieldmap = SSDupeCatcherutility.getSchema(objectType);        
  Schema.sObjectField sof = schemafieldmap.get(fieldname);       
  Schema.Describefieldresult dfr =   sof.getDescribe();
  Object thevalue = foundrecord.get(fieldname);
  String convertedstring = '';
  
  // convert field value to a string
  if (fieldtype == Schema.DisplayType.Double)
  {
    Decimal converted = ((Decimal) thevalue);
    convertedstring = String.valueOf(converted);
  } 
  else if (fieldtype == Schema.DisplayType.Double) 
     ..
     ..
     
  // build query that uses the converted field 
  String querystring =  'select Name,Id,OwnerId  from ' + objectType + ' WHERE (' + fieldname + ' = ' + convertedstring + ')';

 

 

Any ideas on how to convert the record value to a string that can be used in a dynamic SOQL query?

 

Any help would be greatly appreciated.

 

 

Thanks,

 

TomDJ

  • March 25, 2011
  • Like
  • 0

 

 

 

My company has developed a managed package on App Exchange and are trying to look for a decent work around for an issue that would normally be simple, but the fact that we can't change many things in the package is making it difficult to do and still have a professional looking product.


We have defined an Object that needs a new field, either a checkbox or two item picklist.   The Object is assigned to a tab and uses the standard object views generated by salesforce.   The tab is assigned to our application.   

 

The issue arises because the checkbox is related to Person Accounts and needs to be disabled or hidden if the Org does not support Person Accounts.   Leaving it visible will be confusing  to the end user.    I cannot find a way to make this happen.    Does anyone know of a way to do this?

 

Is my only choice to create a Visual Force Page instead of using the standard pages?  I would prefer not to do this because due to our app being a managed package,  I cannot reassign the current tab to a new Visual Force page.   I would have to create a new tab for the new Visual Force page, but becuase it is a managed package I cannot delete the old tab.  We already have one deprecated tab that appears  in the list when you hit the '+' sign to see all tabs.   I do not want to junk up the list anymore than we have.  

 

 

Thanks in advance.   Great bunch of people on this board.

 

Tom DJ

 

 

  • March 04, 2011
  • Like
  • 0

I have trigger handler class that generically handles Lead, Contact, and Account records.   The Lead, Contact and Account triggers assign it to an sObject variable, which they pass to the trigger handler class.   The trigger takes one of the fields of the sObject (the handler decides which field by getting the field name from configuration data) and uses the value (e.g. 1223334.0) of that field to build a dynamic SOQL query.   

  Example SOQL query string:    “Select AnnualRevenue from Lead where (AnnualRevenue = 1223334.0) “

The problem I am having is how to generically turn a field value (e.g. 1223334.0) into a string no matter which data type it is.
My first solution was to do the following:

  Object myfieldvalue_object  = mySObjectRecord.get(fieldname);
  String myfieldvalue_string = (String) myfieldvalue_object;
  buildQuery(myfieldvalue_string)

I immediately got an exception on the second line when the object was of type DOUBLE.

My next solution was to case on the datatype of the field and cast the myfieldvalue_object as the appropriate internal data type and then turn that datatype into a string.

  if (fieldtype == Schema.DisplayType.DateTime) {
     Double convertedvalue = ((Double) myfieldvalue_object);
     String myfieldvalue_string = convertedvalue.format();
     buildQuery(myfieldvalue_string)
  }
 
But, the converted string for a Double datatype contained commas and a decimal point (i.e the displayable value) which cannot be  used in a Dynamic SOQL query.

Given I have the field name, does anyone know how I can convert the value of a field in an sObject  to a String that can be used in a dynamic SOQL query.?    I need to be able to do it for all Object datat types with Date, Text, Number being the priority right now.

Thanks in advance.

Tom DJ

  • February 18, 2011
  • Like
  • 0

 

 

I am getting the following exception error from one of our customer for an App Exchange application (managed package)

 

  System.QueryException: sObject type 'Lead' is not supported. 

 

This is thrown when I do the following dynamic SOQL query from an "After" trigger.

 

  select Name,Id,OwnerId,Email from Lead WHERE (Email = 
'someone@yahoo.com') AND (IsConverted != TRUE) AND (Id != 
'00Q6000000RPkKPEA1') Limit 15 

 

The User Type is "LIcenseManager" and the customer has an App Exchange application, so I am pretty sure this is LMA that is having the issue with our trigger.  

 

The query is being called from a class that has "with sharing" keywords, so there could be restrictions on the query, but I am finding it hard to believe that LMA's would not have access to the Lead object because (and correct me if I am wrong)  it manages the leads that are generated when apps are downloaded.

 

Thanks in Advance.

 

Tom DJ.

 

  • February 14, 2011
  • Like
  • 0

 

I am getting the following exception error from one of our customer for an App Exchange application (managed package).   

 

Apex script unhandled exception caused by: System.SObjectException: Field is not writeable: APPPREFIX__Filter__c.APPPREFIX__Blocked_Count__c 

 

The object and field is defined by our application and is not a customer defined object or field.   The application is doing an update of the record from a VF controller that calls a class that has "Without Sharing" in order to do the update .    Shoudn't our application always be able to write to this object if using "Without Sharing"?

 

If not, how does an application make sure that it can write to its own defined objects at all times no matter what user is triggering the update.

 

Thanks in advance,

 

Tom DJ

 

  • February 14, 2011
  • Like
  • 0

 

I have an App Exchange application that is getting the following error out in the field on a custom record that was created for our application's use.

 

    System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, unable to obtain exclusive access to this record 

 

I could not find anything on this error except for one posting back in 2008 which never publicly posted the fix.

 

Does anyone know what this exception means?  Sounds like something having to do with record locking, but the app is not doing record locking.

 

Thanks in advance.

 

Tom DJ

 

  • February 14, 2011
  • Like
  • 0

 

I am trying to print the stack trace when an exception occurs using the 
Exception.getStackTraceString() method.    I have cut and paste it from documentation.

 

I get a compile error that says "Save error: Method does not exist or incorrect signature: [Exception].getStackTraceString()".

 

I do not get the compile error when I use Exception.getCause() which is another method from the same documentation.

 

Here is the code simplified.

 

 

  try
  { 
    // some working code
  } catch (Exception e) {  
            System.debug('MyController() stackTrace: ' + e.getStackTraceString());
  }

 

 

 

Does anyone know if the Exception.getStackTraceString() method is available or if it may be spelled differently?   For some reason, the IDE's method completion feature gives me an error so I can't see what the options are (aggravating!).

 

Thanks,

 

Tom DJ.

 

  • February 11, 2011
  • Like
  • 0

 

Does anyone know if there is a way to detect from Apex code if a Professional Org has bought API access?

 

Thanks in advance,

 

Tom

 

  • February 03, 2011
  • Like
  • 0

I have created a set of triggers that block duplicates on Leads,  Contacts and Accounts that are entered through the standard edit screen.   The trigger puts an error message at the top of the edit screen using Trigger.addError() when it blocks a duplicate record from  being created .    I am trying to implement an override button that shows up alongside the error.   I have the button code in place and the button shows up fine.   When clicked, I would like the override button to signal to the trigger that the current record that is being edit should not be blocked.   I need a way to signal to the trigger that the record that is currently being edited should not be blocked.

 

My initial thought was to create a new Custom Settings object that would contain a session ID field.  The override button 'onclick' javascript event handler would insert a new record into the Custom Setting table (by invoking apex class method) that includes the current session ID (UserInfo.getSessionId()).  After the API call, the event handler would auto-click the  “Save” button on the standard edit page.

 

My thought was that the trigger would get the current session Id using UserInfo.getSessionId() and query the Custom settings for a record that matches the the current session ID and is not older than a hard coded time (e.g. 5 seconds).  If it finds a matching record, it exits instead of running the trigger logic.

 

I printed the session ID from the Web Servcie method and again from the trigger and the Ids are different so this approach does not work.

 

Apex WebService method sessionId:

00DA0000000c7YG!AQ4AQE6qc65itrKsrkPRxobinnc_Q7NaaECyv7Iyciu_pLtt_Asz_uISpmDRfpxQQJhV3k_cJCOYrlufnhU7D0zqNXkoCRk6

 

Trigger sessionId:

00DA0000000c7YG!AQ4AQMqmgZYEVoCtC12KYptrbLEbznz8HVvaIFtgf1KvpP5Mb4s6ODZJloN8.8M1rwN0XQ8WppIvT8YA_zxCaDr4hyXNpHv_

 

Does anyone know of something I can use to correlate a new record that is being created in an edit page to a trigger that is invoked when that record is saved?

 

Any ideas or help this would be greatly appreciated.

 

Tom DesJardins

  • February 03, 2011
  • Like
  • 0

 


I have run into a situation during testing (using Salesforce rolesand private sharing setting on Accounts) in which an account record becomes viewable but not editable by a user in a role.

 
The record turns up in the result set of a "with sharing" queryby our AppExchange application but it is not editable by the user.   This fine, but our AppExchange application needs to be able to detect that the record is not editable and warn the user.


I have tried the following code that calls the DescribeSObjectResult.isUpdateable()method on the record instance.  It return true on the record that is not editable.  It seems to be returning its result based on the user profile instead of the role assigned to the user.  Is this proper use of the isUpdateable() function?

 



I have tried the following two approaches also, but neither is a good solution.

  • Used AccountShare which worked fine, but we get an error on installations that says the feature is not turned on.  We cannot ask our customers to turn it on.
  • Updated the account without changing data. An exception tells the app that the account   is not editable.  But, it results in a nasty log in the log file and also the LastModified date on the record is altered when it should not be.  Not good.

 


Can someone help me with a solution that can determine if a viewable record is editable by a user.  It needs to be able to work across the various and sundry org types and configurations out there, and hopefully won't require too much org type detection or feature detection to work.

.

It would be much appreciated.  Also, I could use it ASAP because we are trying to get a release out the door.

Thanks,


Tom DesJardins

 

  • January 21, 2011
  • Like
  • 0

 

I need to be able to provide the version number of our managed package in emails that are generated when application exceptions occur.   Is there an easy way to get the package version at runtime using Apex without having to update code each  release cycle?

 

Your help is greatly appreciated.

 

Thanks,

 

Tom D.

  • December 01, 2010
  • Like
  • 0

 

I am developing an AppExchange app that has passed security review.    I noticed a statement in the Salesforce  "Developing Packages for Distribution"  doc that says after security review the app is "eligible" for an API token that can be appended to the SOAP headers that will allow the App to use the Web API in Group and Personal editions even if the customer does not have API access.

 

Our next release which should be coming out in a few days has a feature that we plan to release soon that dpends on this access.  I would greatly appreciated if anyone can tell me  how I can find the API token for our app.   Should we have received it in our security review approval email?  Is there a link or phone number we are supposed to call?  Does it automatically get appended to the SOAP header after passing security review?   

 

Thanks,

 

Tom D.

  • November 08, 2010
  • Like
  • 0

Hi All,

 

We are about to get a new PBX and I would like to get one that interfaces with SFDC sio that users can click on telephone numbers and connect directly etc.

 

A few years ago there were a few systems that connected to Salesforce pretty much out of the box. Does anyone know what/where that list is today?

 

Thanks

 

Ben

as we migrate to SFDC from our legacy systemm I have to decide how to deal with a large dependant picklist.

 

the controlling field has 1027 selectable values, and there are 5,000 total dependent values over the 1027 primary values.

 

SF dependant picklist controlling field only supports 300 values..

 

has anyone made a solution that supports larger amounts of data..

 

I know I can attempt to redesign the data, but we have a number of business processes that would also need to be revised.

and that work is scheduled in a subsequent release after migration..

 

ideas welcomed..

 

Sam

 

 

I am trying to print the stack trace when an exception occurs using the 
Exception.getStackTraceString() method.    I have cut and paste it from documentation.

 

I get a compile error that says "Save error: Method does not exist or incorrect signature: [Exception].getStackTraceString()".

 

I do not get the compile error when I use Exception.getCause() which is another method from the same documentation.

 

Here is the code simplified.

 

 

  try
  { 
    // some working code
  } catch (Exception e) {  
            System.debug('MyController() stackTrace: ' + e.getStackTraceString());
  }

 

 

 

Does anyone know if the Exception.getStackTraceString() method is available or if it may be spelled differently?   For some reason, the IDE's method completion feature gives me an error so I can't see what the options are (aggravating!).

 

Thanks,

 

Tom DJ.

 

  • February 11, 2011
  • Like
  • 0

 

Does anyone know if there is a way to detect from Apex code if a Professional Org has bought API access?

 

Thanks in advance,

 

Tom

 

  • February 03, 2011
  • Like
  • 0

I am new to SFDC. I am using Developer Edition. My friends told me that i can create apex classes and triggers in the Developer Edition. But somehow when i login to DE and go to develop->apex triggers, i dont see the "new" button to create a trigger. What i am doing now is create a sandbox out of the DE and creating triggers there. So is there somethign i am missing? do i need to change any config settings to enable apex triggers in DE?

I have created a set of triggers that block duplicates on Leads,  Contacts and Accounts that are entered through the standard edit screen.   The trigger puts an error message at the top of the edit screen using Trigger.addError() when it blocks a duplicate record from  being created .    I am trying to implement an override button that shows up alongside the error.   I have the button code in place and the button shows up fine.   When clicked, I would like the override button to signal to the trigger that the current record that is being edit should not be blocked.   I need a way to signal to the trigger that the record that is currently being edited should not be blocked.

 

My initial thought was to create a new Custom Settings object that would contain a session ID field.  The override button 'onclick' javascript event handler would insert a new record into the Custom Setting table (by invoking apex class method) that includes the current session ID (UserInfo.getSessionId()).  After the API call, the event handler would auto-click the  “Save” button on the standard edit page.

 

My thought was that the trigger would get the current session Id using UserInfo.getSessionId() and query the Custom settings for a record that matches the the current session ID and is not older than a hard coded time (e.g. 5 seconds).  If it finds a matching record, it exits instead of running the trigger logic.

 

I printed the session ID from the Web Servcie method and again from the trigger and the Ids are different so this approach does not work.

 

Apex WebService method sessionId:

00DA0000000c7YG!AQ4AQE6qc65itrKsrkPRxobinnc_Q7NaaECyv7Iyciu_pLtt_Asz_uISpmDRfpxQQJhV3k_cJCOYrlufnhU7D0zqNXkoCRk6

 

Trigger sessionId:

00DA0000000c7YG!AQ4AQMqmgZYEVoCtC12KYptrbLEbznz8HVvaIFtgf1KvpP5Mb4s6ODZJloN8.8M1rwN0XQ8WppIvT8YA_zxCaDr4hyXNpHv_

 

Does anyone know of something I can use to correlate a new record that is being created in an edit page to a trigger that is invoked when that record is saved?

 

Any ideas or help this would be greatly appreciated.

 

Tom DesJardins

  • February 03, 2011
  • Like
  • 0

hi

 can any one help me pls

 

 i am trying to pass a list from one visual force to other

 

 is it possible

 

thanks 

mahabub

 

I am developing an AppExchange app that has passed security review.    I noticed a statement in the Salesforce  "Developing Packages for Distribution"  doc that says after security review the app is "eligible" for an API token that can be appended to the SOAP headers that will allow the App to use the Web API in Group and Personal editions even if the customer does not have API access.

 

Our next release which should be coming out in a few days has a feature that we plan to release soon that dpends on this access.  I would greatly appreciated if anyone can tell me  how I can find the API token for our app.   Should we have received it in our security review approval email?  Is there a link or phone number we are supposed to call?  Does it automatically get appended to the SOAP header after passing security review?   

 

Thanks,

 

Tom D.

  • November 08, 2010
  • Like
  • 0

It seems we can't use the 'Action' method in <apex:page>. If any Action method is defined in the controller which takes an Id, then it violates 'Cross-Site Request Forgery (CSRF)' and the custom Action method doesn't support anti-CSRF token.

 

In suggestions, it's mentioned that to use POST method, but I am not sure how to use POST method in <apex:page> Action.

 

If you have any idea on this problem, please let us know.

 

Thanks

Bhaskar Roy

  • June 18, 2010
  • Like
  • 0