• an
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies
I have a need to implement countries as an object in salesforce to be able to link the countries to regions and other data easily. This will be needed especially in reporting.

We don't want to implement visualforce page for all the objects that have association to country and that is a another reason not to use custom settings for this one.

Custom settings would however make it much easier to handle the the country data in triggers (we have several integrations where we are sending country code instead of name or sf id).

What I was planning is that I would have a custom country object and a custom settings for countries. Additionally I would implement a simple trigger on country custom object that copies necessary values to country custom settings. That way I would have cached country data that could be used in triggers easily without consuming soql limits.

Has anyone used this kind of approach? Do you see any issues related to this?
  • February 14, 2014
  • Like
  • 1

Hi,

 

Online help says "Roll-up summary fields cannot calculate the values of other roll-up summary fields except for account to opportunity roll-up summary fields, which allow you to calculate the values of opportunity roll-up summary fields."

 

I have three objects A, B and C. A is a master of B and B is a master of C. In object B there is a roll-up summary field X that sums the values from the field in C. Despite of what online help says I was able to create a roll-up summary field in object A that sums the values in the field X.

 

Did I misunderstood something or are there some potential problems if I use roll-up summary field to calculate values of other roll-up summary fields?

 

 

  • August 04, 2010
  • Like
  • 0

Is it possible to query a records based on a picklist value so that I query all objects above or below the specific picklist value. For example if I have pickilist Example__c in my custom object CustomObject__c

 

Example__c contains values contains values

Example1

Example2

Example3

Example4

 

Now I would like to make a SOQL query to fetch all the records who Example__c field set to value above 'Example3'. Is this possible? Could I use getPicklistValues() method to define which values are above the specific value? In other words does the getPicklistValues() return the values in the correct order?

  • April 07, 2010
  • Like
  • 0

According to salesforce documentation there are 15 and 18 digit versions of record ids. The documentation also recommends to use the 18 digit version.

 

In salesforce user interface the 15 digit version is usually shown but the 18 digit version usually seems to work too. 

 

Now I faced the problem when I am trying to create a link to the case creation and autopopulate the account lookup. So I am passing the account name and id as parameters. But if I use the 18-digit version for the account id I get the error message "Data not available for this view". The 15 digit version works fine here. Also for the contact lookup field the both versions are ok. So to clarify here are the links I am using:

 

This gives error: /500/e?cas4=AccountName&cas4_lkid=AccountId18Digits

This doesn't:  /500/e?cas4=AccountName&cas4_lkid=AccountId15Digits

 

I thought that inside salesforce both 15 and 18 digits versions could be used. Does anyone know if there is some reference where I could check when to use 18digit and when to use 15 digit version?

 

  • February 25, 2010
  • Like
  • 0

Does anyone know if it is possible to create a digitally signed pdf attachement using apex? Or do I need to create an external webservice for it and call it from apex?

 

Any suggestions and recommendations are welcome!

  • February 16, 2010
  • Like
  • 0

I have a trigger that fires when contact object is updated and updates the related user's isActive checkbox when the spesific checkbox in the contact has been changed.

 

Because the user and contact cannot be updated in the same transaction contact trigger calls the future method that updates the user's isActive field.  This is simplified trigger code.

 

 

trigger InsertUpdateContactTrigger on Contact (after update) {
List<String> contactsToUpdate = new List<String>();
for (Contact c : trigger.new){
if(trigger.newMap.get(c.Id).IsActive__c != c.IsActive__c){
contactsToUpdate.add(c.Id);
}
}

AsyncUserUpdateHelper.updateContactUserInfo(contactsToUpdate);
}

This works fine in practice in other word when I update the contact in UI trigger fires and user is updated. I have also written a testMethod for trigger and test passes when I run it in Eclipse IDE. I am also able to deploy the trigger in production through IDE and during deployment tests run successfully. The problem is that when I try to 'Run Test' or 'Run All Tests' in Setup->Develop->Apex Classes tests fail because of MIXED_DML_OPERATION error from the row 4.

1 private static testMethod void testUpdateContact(){
2 //QUERY CONTACTS THAT HAVE PORTAL USER
3 Test.startTest();
4 update portalContacts;
5 Test.stopTest();
6 //ASSERTIONS
7 }

Does using startTest and stopTest case the both trigger and future method to run in same transaction and if so how can I test the trigger that calls @future method? And why the tests run fine when deploying the through IDE but not when running them directly from salesforce?

  • January 27, 2010
  • Like
  • 0
I have a need to implement countries as an object in salesforce to be able to link the countries to regions and other data easily. This will be needed especially in reporting.

We don't want to implement visualforce page for all the objects that have association to country and that is a another reason not to use custom settings for this one.

Custom settings would however make it much easier to handle the the country data in triggers (we have several integrations where we are sending country code instead of name or sf id).

What I was planning is that I would have a custom country object and a custom settings for countries. Additionally I would implement a simple trigger on country custom object that copies necessary values to country custom settings. That way I would have cached country data that could be used in triggers easily without consuming soql limits.

Has anyone used this kind of approach? Do you see any issues related to this?
  • February 14, 2014
  • Like
  • 1

So in the documentation for apex attributes, it says I can pass in a "type" of "Apex Class"

 

I tried to set the following:

<apex:attribute type="jnh_dynamicPaginator_v01" name="controller" description="The paginator controller that the list applies to" />

 

And it saives fine, but when I try and put it on my page:

 

vf page:

<apex:page controller="TEMP_controller">
<apex:form>

            <c:dp_dynamicpaginator controller="{!paginator}"/>
</apex:form>
</apex:page>

 

public with sharing class TEMP_controller {

    public jnh_dynamicPaginator_v01 paginator {
        get {
            if (paginator == null) {
                paginator = new jnh_dynamicPaginator_v01();
            }
            return paginator;
        }
        set;
    }

}

 

I get the following error:

Error: Wrong type for attribute <c:dp_dynamicpaginator controller="{!paginator}">. Expected jnh_dynamicPaginator_v01, found String

 

Any ideas?

  • February 25, 2013
  • Like
  • 0

I like to put enough comments in my code to identify what stuff is without cluttering it up with verbose banners.  I also have to write design specs so other engineers can understand classes I write.  I'm faced with a quandry as the info I put in the few sentence in the comments at the top of each method and the few works off comment on each parameter are pretty much what I want in my design spec.  I don't want to have to write it twice.

 

I was thinking, it would be cool if I could annotate the code and run a util like Javadoc on it.

 

Anyone know if there's anything like that for Apex?

 

If not, would apex ignore annotation and do you think javadoc would run on it as is?

 

-Ken

 

I am trying to programmatically create a User Queue record that can own Lead records via a trigger . According to the documentation available for Group object

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_group.htm#topic-title

 

setting Group.Type = ‘Lead’  should achieve this . But, this is throwing an exception at runtime

 

Apex trigger insertSalesTeam caused an unexpected exception, contact your administrator: insertSalesTeam: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Type: bad value for restricted picklist field: Lead: [Type]: Trigger.insertSalesTeam: line 33, column 9

 

If , however , I give  Group.Type  =  ‘Queue’ , it perfectly creates a Queue record as expected , but I have to set ‘Lead’ as ‘Supported Object’ manually .

 

Have any of you faced this problem ? can you please let us know if there is some work around for this .

Hi All,

 

I have a after insert/update trigger on a custom object from where I am passing a list of the object Ids to the  @future method.

 

In the @future method, I am performing some updates to the same records and updating the records.

 

My @future method is called repeatedly and I am getting this error: "Future method cannot be called from Future method"

 

Any Idea how to overcome this?

 

Thanks

I have a trigger that fires when contact object is updated and updates the related user's isActive checkbox when the spesific checkbox in the contact has been changed.

 

Because the user and contact cannot be updated in the same transaction contact trigger calls the future method that updates the user's isActive field.  This is simplified trigger code.

 

 

trigger InsertUpdateContactTrigger on Contact (after update) {
List<String> contactsToUpdate = new List<String>();
for (Contact c : trigger.new){
if(trigger.newMap.get(c.Id).IsActive__c != c.IsActive__c){
contactsToUpdate.add(c.Id);
}
}

AsyncUserUpdateHelper.updateContactUserInfo(contactsToUpdate);
}

This works fine in practice in other word when I update the contact in UI trigger fires and user is updated. I have also written a testMethod for trigger and test passes when I run it in Eclipse IDE. I am also able to deploy the trigger in production through IDE and during deployment tests run successfully. The problem is that when I try to 'Run Test' or 'Run All Tests' in Setup->Develop->Apex Classes tests fail because of MIXED_DML_OPERATION error from the row 4.

1 private static testMethod void testUpdateContact(){
2 //QUERY CONTACTS THAT HAVE PORTAL USER
3 Test.startTest();
4 update portalContacts;
5 Test.stopTest();
6 //ASSERTIONS
7 }

Does using startTest and stopTest case the both trigger and future method to run in same transaction and if so how can I test the trigger that calls @future method? And why the tests run fine when deploying the through IDE but not when running them directly from salesforce?

  • January 27, 2010
  • Like
  • 0