You need to sign in to do that
Don't have an account?
cribis
Formatting Address Fields with Apex
I have the following trigger that is pulling an address from a custom formula field. into a text field on the opportunity. When the address is pasted onto the opportunity, the address includes the line break syntax <br>, but pastes the entire address on one line.
Below is the code for the trigger:
trigger OpportunityOwnersAddress2 on Opportunity (before insert, before update) { Set<Id> UserIds = new Set<Id>(); for (Opportunity oppo: Trigger.new){ System.debug('**** 0 userids id : '+oppo.ownerid); UserIds.add(oppo.ownerId); System.debug('**** 1 oppo id : '+oppo.id); } Map<Id, User> entries = new Map<Id, User>(); List<user> us = [select Id, User_Address__c from User where id in :UserIds]; for(Opportunity unity: Trigger.new) { unity.Opp_Owner_Address__c = us[0].User_Address__c; } }
How do I format the custom field to correctly format the address in the new field?
Thank you
Depending on where this value is going to be displayed, you might try using\r\n or just \n to denote a newline.
Jeremy