I am integrating Salesforce with my third party app and we both need to share a common mapping attribute for Account Object.
These are the steps I follow:
I created a Custom Setting called XYZ_Custom_Settings which has a Mapping Attribute of type Text XYZ_Mapping_Column_Name.
I display a SelectOption in My Settings tab by describing all the fields in the Account Custom Object.
Admin of the Customer Salesforce App changes this setting appropriately to be in sync with my system.
Once this setting is done I will fetch the mapping attribute as XYZ_Mapping_Column_Name.XYZ_Custom_Settings and will send it as a
to my web Application.
Assuming the Admin has set "Id" I will map my Account with SF_ACCOUNT_ID.
String query = 'SELECT '+XYZ_Mapping_Column_Name.XYZ_Custom_Settings+' FROM Account where id=\''+account.id+'\''; Account acc = Database.query(query); return (String)acc.get(XYZ_Mapping_Column_Name.XYZ_Custom_Settings);
Current problem I am facing is since I display all Fields of Account in mapping. When Admin wrongly sets an object which cannot be Stringified by String cast, then it throws an error as follows:
Content cannot be displayed: Invalid conversion from runtime type Date to String
This happens for all the attributes which cannot be casted by String.
I can't put a limitation on which fields can be mapped, since it can be any Custom Field and my Managed Package should work across them.
Is there a generic way to convert any Attribute to String ? ( as java would respond with Object hash by default if it doesn't has its own toString() )
I tried this zConvert but still I need to know the Class of Mapping Attribute to call this zConvert.ToString(SpecificClass). By Default the attribute is an Object class.