create record with pre-populated values in lex
the documentation on this spring20 feature is so bad its almost like the feature doesn’t exist at all.
this is all you get - one example and 2 notes
some missing ‘details’
a) date fields need to be converted to string using the TEXT formula
b) you can pass RecordTypeId (case sensitive) via a separate url parameter, but not in the default field values. the docs just say its not supported yet and strange things may happen. what is the point of having this feature without supporting record types? insert snide remark about confetti here.
example
/lightning/o/Opportunity/new?recordTypeId=012400000009dr3&defaultFieldValues=...\
c) the nooverride=1 parameter works in lex. if you have overridden the ‘new’ button on the object with say a visualforce page for example so people can only create opps from contacts or accounts, you can pass nooveride=1 and it will let you bypass that page.
d) you can pass ContactId when creating an opp to create an opportunity contact role. (this is just another field on the opp object so its not special per se, but it kinda is)
e) NO SPACES. spaces will kill your button
f) passing number fields in lightning url param seems to blow up with numbers over 1000. instead you need to wrap it in a text command.
this works : &defaultFieldValues=Exchange_Rate_c={!URLENCODE(TEXT(Opportunity.Exchange_Rate_c))}
but this causes 123456.789 to come through as 123.000, or 1,234.567 to come through as 1
&defaultFieldValues=Exchange_Rate_c={!Opportunity.Exchange_Rate_c}
note that in my case both fields are type number, length 6, and decimals 3. ymmv depending on field length etc. it looks to me like its evaluating the comma after 123 and moving on.
and finally that you can create buttons / links that work in classic and lex. tho url hacks in classic are not officially supported, but c'mon now its like jaywalking, everyone does it.
so while it took way too much time i was finally able to create a custom button on contact that creates an opp and pre-sets the record type and creates the contact role. while i love flow, i did not love rebuilding this whole thing in flow, and now i can switch back to the button.
e) using IF logic to create a button that works in classic and lex is only possible if button behavior is set to display in existing window without sidebar or header. for whatever reason, when opening in new window, IF($User.UIThemeDisplayed = ‘Theme3’, evaluates to true. no idea why - I see nothing about this on the docs