• kotoponus
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

I am wondering if someone more experienced can tell me if I am following the instruction correctly. 

 

I am only working on the Apex Workbook as I am rather new to the apex coding:

 

http://www.salesforce.com/us/developer/docs/apex_workbook/Content/apex7_5.htm

 

I am trying out the point 1 which says:

 

>> Now that you�'ve seen how to create an exception class and how to construct your exception objects, let�'s create and >> run an example that demonstrates the usefulness of custom exceptions.

>>

>> 1. In the Developer Console, create a class named MerchandiseException and add the following to it:

>>

>> public class MerchandiseException extends Exception {}

>>

 

I read the step 1 as following:

 

In the Developer Console, I go to File -> New -> Apex Class and type "MerchandiseException" as a name for my new Apex Class in the New Apex Class window.  Then press OK button.

 

However, when I pressed OK, it gave me this error:

 

INVALID_FIELD_FOR_INSERT_UPDATE

MerchandiseException: Exception class must extend another Exception class

 

And it does not create the class.

 

Can someone give me a pointer as to where I went wrong? Something tells me that I am missing something here.

 

I am in developer instance of the SF.  Thanks!

I am wondering if someone more experienced can tell me if I am following the instruction correctly. 

 

I am only working on the Apex Workbook as I am rather new to the apex coding:

 

http://www.salesforce.com/us/developer/docs/apex_workbook/Content/apex7_5.htm

 

I am trying out the point 1 which says:

 

>> Now that you�'ve seen how to create an exception class and how to construct your exception objects, let�'s create and >> run an example that demonstrates the usefulness of custom exceptions.

>>

>> 1. In the Developer Console, create a class named MerchandiseException and add the following to it:

>>

>> public class MerchandiseException extends Exception {}

>>

 

I read the step 1 as following:

 

In the Developer Console, I go to File -> New -> Apex Class and type "MerchandiseException" as a name for my new Apex Class in the New Apex Class window.  Then press OK button.

 

However, when I pressed OK, it gave me this error:

 

INVALID_FIELD_FOR_INSERT_UPDATE

MerchandiseException: Exception class must extend another Exception class

 

And it does not create the class.

 

Can someone give me a pointer as to where I went wrong? Something tells me that I am missing something here.

 

I am in developer instance of the SF.  Thanks!

Simply put the following formula into a formula field of type "Text":

 

Id
& MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",(
    IF(FIND(MID(Id,1,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0)
    +IF(FIND(MID(Id,2,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0)
    +IF(FIND(MID(Id,3,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0)
    +IF(FIND(MID(Id,4,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0)
    +IF(FIND(MID(Id,5,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0)
    )+1,1)
& MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",(
    IF(FIND(MID(Id,6,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0)
    +IF(FIND(MID(Id,7,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0)
    +IF(FIND(MID(Id,8,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0)
    +IF(FIND(MID(Id,9,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0)
    +IF(FIND(MID(Id,10,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0)
    )+1,1)
& MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ012345",(
    IF(FIND(MID(Id,11,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,1,0)
    +IF(FIND(MID(Id,12,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,2,0)
    +IF(FIND(MID(Id,13,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,4,0)
    +IF(FIND(MID(Id,14,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,8,0)
    +IF(FIND(MID(Id,15,1), "ABCDEFGHIJKLMNOPQRSTUVWXYZ")>0,16,0)
    )+1,1)

 

This is an optimized version of the code example "BPS: 18 digit external ID within the UI" you can find on the Online Help, but unlike the example provided there, it is small enough to fit into a formula field. Also, this code doesn't contain the error found in the online help example, where the second character byte equivalent of the first 5-character chunk was "4" instead of "2". I'd be more than happy if someone could come up with an even shorter version of this formula...Still, I hope you can use this.

 

Cheers,

Erik Mittmeyer