I have a text field in the opportunity module that contains percentage values. Since we can’t delete and recreate this field, is there any way to sort it without deleting it? Currently, it’s a text field, so it doesn’t sort the percentages correctly.
Take backup of database in case to revert the code changes.
Update the custom opportunities_c table to format the number to a two digit number as shown in the following example update opportunities_cstm set percentage_c=concat(LPAD(REPLACE(percentage_c,'%',''),2,'0'),'%')
Add a new logic hook entry at custom\modules\Opportunities\logic_hooks.php as show below
Its working but only on 2 digit value, suppose we have 3 digit value like 100% , for that i updated query with 3 but it is showing 090% which we dont want, can we show normal values in list view
update opportunities_cstm set percentage_c=concat(LPAD(REPLACE(percentage_c,‘%’,‘’),3,‘0’),‘%’);
can we apply sorting without adding any aditional zero in table?
I am not 100% sure but it looks there is only one approach to this issue. If possible try creating a new custom field of type integer and copy the old values without the % sign and converted to int using an update SQL query as in previous suggestion. Use the new column at places of old percentage field. Dont forget to take the backup of php and database.