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
Sankar GaneshSankar Ganesh 

Pre Populated Values in Lightning by url using visualforce

I have visual force page if user click proceed then I have to redirect to order object with some pre-populating values of my custom object.
I am not able to pass EffectiveDate as salesforce date format doesn't take this. I have salesforce date format as DD/MM/YYYY so I convert date to this format but still I am getting error for the above code.
I have used sforce.one.createRecord it works for string field but it doesn't work for date field. I can't set default value to date asit is standard field and I tried {!Today} and {!Now} which doesn't work in javascript. Kindly suggest a solution for this.
 
<script>

function GenerateOrder(){

  var d = new Date();               
  var day = d.getDate();           
  var monthIndex = d.getMonth()+1;          
  var year = d.getFullYear();

  var todaydate=day + '/' + monthIndex + '/' + year;

      var defaultValues = { 
                                 'Cart_No__c' : '{!Crt.Id}',
                                 'AccountId' : '{!Crt.Account__c}',
                                 'EffectiveDate' : todaydate
                           };

      sforce.one.createRecord("Order", null, defaultValues);
  }
</script>

 
NagendraNagendra (Salesforce Developers) 
Hi Sankar,

May I suggest you please check with below link from the stack exchange community with a similar issue and a suggested workaround which might help you further with the above requirement. Please let us know if this helps.

Kindly mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra
Sankar GaneshSankar Ganesh
@Nagendra

I can't use quick action since I need the values from vf page so I used  sforce.one.createRecord.

The problem I facing is I can't populate date fields from javascript can you suggest how to pass date value .