function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anil ChunduAnil Chundu 

Opportunity name with date is populating wierd month value


I have a problem with opportunities creation that when i click on new opportunity(Overridden with Javascript), opportunity name starts with date will be showing wierd. My logic for new opportunity is
 //String for the Date      String nameDateFormat = 'yyyy/mm/dd';            //Create the Opportunity Name 'Created Date - Organisation Name - Contact Name'      String oppName = + ' - ' + con.Account.Name + ' - ' + con.Name;

Opportunity name is populating for example 2015/38/31 - JNTU University - David
when i cancel and click on new opportunity that Month 38 got increased to some 40 like that.
I don't know how solve this issue.
is this becuase of any time settings for a particular users?

Please help me on this asap.

Thanks in advance

Prabhat Kumar12Prabhat Kumar12
Try this.
String nameDateFormat = 'yyyy/MM/dd'; 
String oppName = Datetime.Now().format(nameDateFormat) + ' - ' + con.Account.Name + ' - ' + con.Name;

Let me know  know if works for you.
Anil ChunduAnil Chundu
Hi Prabhat, Thanks for your reply,
when i copy paste this piece of code it showing in my question without spaces + ' - ' + con.Account.Name + ' - ' + con.Name;
It is working for other profile users,  not working for a particular  a other profile user.

Hope you got it..

Thank you
Prabhat Kumar12Prabhat Kumar12
Have you tried the code which i have provided ?
Anil ChunduAnil Chundu
yes no difference
Prabhat Kumar12Prabhat Kumar12
May be user time zone can make different. Try to formate your data based on timezone.