I just noticed an interesting event. Here is the scenario:
1. Server-side user-event script record set to run when lead record is submitted
2. Open a lead record and set its status to 'Prospect' and save.
3. Lead record server-side script runs (which is interesting because beforeSubmit it is still a lead but afterSubmit it is a prospect...)
[LIST=a]
[*]Before Submit runs appropriately (because still a lead before submit)
[*]After Submit also runs under the lead record (should it since it is now a prospect???). Look what happens:
[LIST=i]
[*]Load the current record using getNewRecord (read only). Returns an object variable called recordObj.
[*]Want to write back to this record, so load using loadRecord and use recordObj.getRecordType() to pass to loadRecord for record type.
[*]Script errors: "The record you are attempting to load has a different type: prospect from the type specified: lead".
[/LIST]
[/LIST]
I understand why this would occur, but it seems the recordObj.getRecordType() should have returned 'prospect' when instead it returned 'lead' which is no longer the case. I believe this is a bug and causes script errors whenever making a transition from one stage to another.
[Update:]
I also ran recordObj.getFieldValue('stage') which returned 'LEAD' even though getRecordType err'd with the note that the record type was in fact 'prospect'. I was hoping I could use stage to check the record type and make the correction to avoid the error, but evidently not.
-Steve