You need to sign in to do that
Don't have an account?
gokubi
Dealing with Record Types in a way that will load to Appexchange
Winter '07 added some validation on the upload of Appexchange packages
that affected some of my code. Any S-Controls that had explicit
references to Record Type Ids wouldn't load to the Appexchange. I would often write code like this:
var PurchaseRecordTypeId = "0000000000fff55";
When I needed this code in another instance, I would Appexchange it, install it, and then change the hard-coded reference.
Here's more elegant code that gets Record Type Ids dynamically, and doesn't trip the Appexchange validator:
I'd love to hear feedback if you have suggestions on how this code could do the job better.
Enjoy!
var PurchaseRecordTypeId = "0000000000fff55";
When I needed this code in another instance, I would Appexchange it, install it, and then change the hard-coded reference.
Here's more elegant code that gets Record Type Ids dynamically, and doesn't trip the Appexchange validator:
var oOppRecordTypes = getRecrodTypesforObjects("Opportunity"); var DonationLabel = "Gift"; var MembershipLabel = "Membership"; var DonationRecordType = oOppRecordTypes[DonationLabel].Id; var MembershipRecordType = oOppRecordTypes[MembershipLabel].Id; function getRecrodTypesforObjects(ObjectName) { var RecordTypesArray = new Array(); sfc = sforce.connection; var result = sfc.query("Select r.Id, r.Name, r.SobjectType from RecordType r where r.IsActive=true and r.SobjectType='"+ ObjectName +"'"); var RecordTypesArray = result.getArray("records"); oRecordTypes = new Object(); for (var i=0;i<RecordTypesArray.length;i++) { var oSingleRecordType = new Object(); oSingleRecordType.Name=RecordTypesArray[i].Name; oSingleRecordType.Id=RecordTypesArray[i].Id; oRecordTypes[RecordTypesArray[i].Name]=oSingleRecordType; } return oRecordTypes; }
I'd love to hear feedback if you have suggestions on how this code could do the job better.
Enjoy!
Thanks.