• RongzhongHuang
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 11
    Replies
Hi all, I got error as below in step 5, could not figure out why, could someone help? thanks a lot
User-added image

Please see my Tax settings as below,

1. Tax Treatment
User-added image

2. Tax Legal Entity

User-added image3. Tax Rate
User-added image
Hi, if you search string contains ':', '-' within your SOSL statement, and use Search.query(), you would get exception like 'mismatched character' ...

I was wondering how many characters need to be escaped for SOSL statement. Is there a good way to handler these characters.

thanks, 

Hi all, recently I found that Salesforce native search function can't search custom objects if the objects don't have tab.

 

Is it true???

Hi all,

 

I got a problem about duplicate inserting child records.

 

The business requirement is: When a field value is changed, we want put the old value into custom history table just for tracking purpose.

 

So I wrote a trigger like below. TE_Sub_Task__c  is custom parent object, Technical_Engagement_Comments__c is a custom child object of TE_Sub_Task__c,  Comments__c is the field on parent object which we want to track.

 

Normally the trigger works well, but in one scenario, the trigger duplicates the records. The scenarios is the comments__c field got update, then workflow rules update other fields, then this trigger will be run again. So the same comments will be inserted twice. Does anybody know how to work around the problem? Hopefully I explain this issue clearly.

 

Any comments welcome. 

 

 

 

trigger TESubTask_CommentUpdated on TE_Sub_Task__c (after insert, after update) {
     List<Technical_Engagement_Comments__c> toBeInsert = new List<Technical_Engagement_Comments__c>();
     for (TE_Sub_Task__c teSubTask : trigger.new){
         if (teSubTask.Comments__c != null && teSubTask.Comments__c != ''){

               if ((trigger.isInsert) || (trigger.isUpdate && trigger.oldMap.get(teSubTask.Id).Comments__c != teSubTask.Comments__c)){
                    Technical_Engagement_Comments__c teComment = new Technical_Engagement_Comments__c();
                    teComment.Comments__c = teSubTask.comments__c;
                    teComment.TE_Sub_Task__c = teSubTask.Id;
                    toBeInsert.add(teComment);
                }
           }
      }

      if (toBeInsert.size() > 0)
             insert toBeInsert;
}

 

 

Hi, does anyone know how to migrate clob field data in other system into Salesforce? The clob field data may contain more than  32,768 characters. 

Hi guys,

 

In SOQL, you can do like [SELECT Id, Name FROM Account ORDER BY Name LIMIT 1].

I was wondering what is the sequence of 'ORDER BY' and 'LIMIT 1', does it do 'ORDER BY' or do 'LIMIT 1' firstly?

Hi guys,

 

Basically, what I want is to validate a field on a custom object before update. The requirement is to get the value of this field, and then send Http request with this value to another web application, if the result is invalid, display error message on this field.

 

I know that trigger doesn't support callout, so I tried to use a method with @future annotation to work around this limitation.

 

Now the problem is I don't know how to get the result back to trigger and display error message as methods with the future annotation cannot take sObjects or objects as arguments.

 

Does anybody have some suggestion to work around this?

 

Thanks     

Hi guys,

 

I am not sure if this question is stupid or not. I was wondering how we know which version of Salesforce we are using. Is there any way that we can know the version of Salesforce? (i.e. Sping 09 or winter 10) 

 

Any answer would be helpful.

 

Thanks.

Hi guys,

 

I have a trigger(refer to the code below) on Account object. When I run the testing of trigger, I got the error 

message "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, A workflow or approval field update caused an error when saving this record". 

 

I found that a workflow field update happening when testing. According to salesforce apex language reference, 

Triggers and Order of Execution

 

10. If there are workflow field updates, updates the record again.
11. If the record was updated with workflow field updates, fires before and after triggers one more time (and only one more time).

 

I don't understand why I get this error message.  Is there any person can help? 

 

 

trigger updataRegionMapping on Account (before insert, before update)
{
    //List<Account> accNew = trigger.new;
    List<String> accSuburbs = new List<String>();
    List<String> accStates = new List<String>();
    List<String> accPostCode = new List<String>();
    for (Account acc : trigger.new)
    {
        accSuburbs.add(acc.ShippingCity);
        accStates.add(acc.ShippingState);
        accPostCode.add(acc.ShippingPostalCode);
    }
   
    List<Region_Mapping__c> regionMapping = [select ID,Name,Regional_Metro__c, Region__c
                                             from Region_Mapping__c where PostCode__c in :accPostCode
                                             and State__c in :accStates and Suburb__c in :accSuburbs ];
    System.debug('regionMapping found: '+ regionMapping.size());
    if (regionMapping.size() == 1)
    {
        for (Integer i = 0;i<trigger.new.size();i++)
        {
            //trigger.new[i].Region__c = regionMapping[0].Region__c;
            //trigger.new[i].Region_Type__c = regionMapping[0].Regional_Metro__c;
            trigger.new[i].Region_Mapping__c = regionMapping[0].Id;
        }
    }
                                       
}

Hi all, I got error as below in step 5, could not figure out why, could someone help? thanks a lot
User-added image

Please see my Tax settings as below,

1. Tax Treatment
User-added image

2. Tax Legal Entity

User-added image3. Tax Rate
User-added image

Hi all, recently I found that Salesforce native search function can't search custom objects if the objects don't have tab.

 

Is it true???

Hi all,

 

I got a problem about duplicate inserting child records.

 

The business requirement is: When a field value is changed, we want put the old value into custom history table just for tracking purpose.

 

So I wrote a trigger like below. TE_Sub_Task__c  is custom parent object, Technical_Engagement_Comments__c is a custom child object of TE_Sub_Task__c,  Comments__c is the field on parent object which we want to track.

 

Normally the trigger works well, but in one scenario, the trigger duplicates the records. The scenarios is the comments__c field got update, then workflow rules update other fields, then this trigger will be run again. So the same comments will be inserted twice. Does anybody know how to work around the problem? Hopefully I explain this issue clearly.

 

Any comments welcome. 

 

 

 

trigger TESubTask_CommentUpdated on TE_Sub_Task__c (after insert, after update) {
     List<Technical_Engagement_Comments__c> toBeInsert = new List<Technical_Engagement_Comments__c>();
     for (TE_Sub_Task__c teSubTask : trigger.new){
         if (teSubTask.Comments__c != null && teSubTask.Comments__c != ''){

               if ((trigger.isInsert) || (trigger.isUpdate && trigger.oldMap.get(teSubTask.Id).Comments__c != teSubTask.Comments__c)){
                    Technical_Engagement_Comments__c teComment = new Technical_Engagement_Comments__c();
                    teComment.Comments__c = teSubTask.comments__c;
                    teComment.TE_Sub_Task__c = teSubTask.Id;
                    toBeInsert.add(teComment);
                }
           }
      }

      if (toBeInsert.size() > 0)
             insert toBeInsert;
}

 

 

Hi, does anyone know how to migrate clob field data in other system into Salesforce? The clob field data may contain more than  32,768 characters. 

Hi guys,

 

I have a trigger(refer to the code below) on Account object. When I run the testing of trigger, I got the error 

message "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, A workflow or approval field update caused an error when saving this record". 

 

I found that a workflow field update happening when testing. According to salesforce apex language reference, 

Triggers and Order of Execution

 

10. If there are workflow field updates, updates the record again.
11. If the record was updated with workflow field updates, fires before and after triggers one more time (and only one more time).

 

I don't understand why I get this error message.  Is there any person can help? 

 

 

trigger updataRegionMapping on Account (before insert, before update)
{
    //List<Account> accNew = trigger.new;
    List<String> accSuburbs = new List<String>();
    List<String> accStates = new List<String>();
    List<String> accPostCode = new List<String>();
    for (Account acc : trigger.new)
    {
        accSuburbs.add(acc.ShippingCity);
        accStates.add(acc.ShippingState);
        accPostCode.add(acc.ShippingPostalCode);
    }
   
    List<Region_Mapping__c> regionMapping = [select ID,Name,Regional_Metro__c, Region__c
                                             from Region_Mapping__c where PostCode__c in :accPostCode
                                             and State__c in :accStates and Suburb__c in :accSuburbs ];
    System.debug('regionMapping found: '+ regionMapping.size());
    if (regionMapping.size() == 1)
    {
        for (Integer i = 0;i<trigger.new.size();i++)
        {
            //trigger.new[i].Region__c = regionMapping[0].Region__c;
            //trigger.new[i].Region_Type__c = regionMapping[0].Regional_Metro__c;
            trigger.new[i].Region_Mapping__c = regionMapping[0].Id;
        }
    }
                                       
}