Ideally speaking this will not be an out of box feature that everybody needs in CRM, however I came across many such requirements these days where people either wanted to use id fields on the screen as unique reference values. Some just wanted to display them on the screen for viewing purpose. Some wanted to put them in the list for ordering. I will be discussing the today’s topic based on the similar grounds. Throughout the write up I will take up opportunity entity for explanation.
ID value to be used just for viewing purpose:
Suppose you want Opportunity ID only to be displayed on the summary screen only for viewing purpose. For this create a new field under opportunity entity of size 1 char. Place it on the opportunity screen (Opportunity Detail Screen). On Create script of the newly created field get the opportunity id from context. Put the value in the caption part and then make the field read-only. Refer below given code snippet
var CurrOppoId = eWare.GetContextInfo(“Opportunity”,”Oppo_opportunityid”)
Caption=”Opportunity ID: “+ CurrOppoId;
ID value to be used for checking uniqueness as an alternate to reference Id:
Yes we can create stored procedure fields In CRM to generate reference id’s for the entities, however when the table size grows and insert operations become slow, running the procedures prior to insert operation add up to the task. Again we need this only for finding unique records through search screen or add them in the list for ordering purpose so we can also use the already existing unique factor i.e. ID value. Below is how you can achieve the same.
1. Create a dummy integer field in entity. E.g.Oppo_DummyOppoId.
2. Add this field to OpportunitySearchBox, OpportunityFilterBox etc. i.e. wherever needed for searching purpose.
3. Add the same to OpportunityDetailBox if you want to display it on summary screen as well but do not forget to make it readonly.
4. As now we are done with adding dummy field everywhere you have to write either a Table level script or SQL trigger to update the id value (Oppo_OpportunityId) of the record being inserted in this dummy field (Oppo_DummyOppoId).
5. You can add the similar field on the list boxes too in order to apply order by clause based on ID value.