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
Mohan Raj 33Mohan Raj 33 

Jquery data table provide a milliseconds format in date value column

here I only struggle to get the normal apex date value like in mm/dd/yyyy format. please help me to get this... I here try to provide a ownerid update for the tasks. it's specified by the duedate in the my datepicker. and that search and update function i done by remote actions respectively. my code as followingly,
controller:
//Remote function using updated the owner of the task
public class TaskOwnerUpdate {
    
    public String dueDate { get; set; }
    public Set<Id> selectedTaskIdSet {get; set;}
    String ownerIdValue {get; set;}
    String selectedColumnValue {get; set;}
    public static List<Task> taskList { get; set;}
    public TaskOwnerUpdate() { } // empty constructor
    public List<Task>selectedtaskList {get; set;}
    
    public Task getOwnerIdTask() {
    
        return [SELECT  OwnerId FROM TASK LIMIT 1];
    }
    
    @RemoteAction
    public static List<Task> getTask (String dueDate) {
    
        system.debug('dueDate value is------>'+dueDate);
        List<String> stList = dueDate.split('"');
        system.debug('stList value---->'+stList);
        List<String>s1 = stList[0].split(',');
        system.debug('stList[0] value is---->'+stList[0]);
        system.debug('stList[1] value is---->'+stList[1]);
        List<String> splitList = stList[1].split('/');
        system.debug('splitList value is---->'+splitList);
        String dueDate1 = splitList[2]+'-'+splitList[0]+'-'+splitList[1]; 
        taskList = [SELECT Id, Subject, Priority, Status, ActivityDate, Owner.Name, OwnerId
                   FROM Task WHERE ActivityDate >= :Date.valueOf(dueDate1)];
        system.debug('taskList- value is------>'+taskList);
        return taskList;        
    
    }
    
    @RemoteAction 
    public static List<Task> updateTask(String ownerIdValue, String selectedColumnValue ) {
    
        system.debug('OwnerId value is----->'+ownerIdValue);
        system.debug('selectedColumnValue value is---->'+selectedColumnValue);
        
        List<Task> updatedTaskList = new List<Task>();


        Set<Id> idSet = new Set<Id>();
        List<String> deserializeStringList = (List<String>)System.JSON.deserialize(selectedColumnValue, List<String>.class);
        
        system.debug('deserializeStringList value>>>>'+deserializeStringList);

        for (String strRecord : deserializeStringList) {
        
            Task taskRecord = new Task();
            taskRecord.Id = Id.valueOf(strRecord);
            taskRecord.OwnerId = Id.valueOf(ownerIdValue);
            updatedTaskList.add(taskRecord);
        } 
              
        if (updatedTaskList.size() > 0) {
            Update updatedTaskList;
        }
         return updatedTaskList;
         
    }
     
}

page:
<apex:page controller="TaskOwnerUpdate">
    <apex:form>
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"/>
    <apex:includeScript value="https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"/>

    <apex:sectionHeader title="Task Ownership Update"/>

    <apex:pageBlock title="Tasks">
 <!---- Section to draw search field for account-------> 
        <apex:pageBlockSection title="Search Tasks" columns="2">
            <apex:pageBlockSectionItem >
                <apex:inputText value="{!dueDate}" size="10" id="demo" onfocus="DatePicker.pickDate(false, this , false)">dueDate</apex:inputText>
                <apex:inputField value="{!OwnerIdTask.OwnerId}" id="owner"></apex:inputField>
            </apex:pageBlockSectionItem>               
        </apex:pageBlockSection>
        
        <apex:pageBlockSection >
                <button onclick="getTask();return false;">Get Task</button>            
                <button id = "button">Update</button>     
        </apex:pageBlockSection>

        <apex:actionFunction name="callaction" oncomplete="getTask()" reRender="output"/>
    
     <!-- result section for showing matching accounts ------->
        <apex:outputPanel id="output">
            <apex:pageBlockSection title="Matching Tasks !" columns="1">
            <!-- 
            Created Empty table using the CSS styles of visualforce pageBlockTable 
            This gives same look and feel ------>
            
                <table cellspacing="0" cellpadding="0" border="0" id="searchResults" class="list ">
                    <colgroup span="2"></colgroup>
                    <thead class="rich-table-thead">
                        <tr class="headerRow ">
                            <th colspan="1" scope="col" class="headerRow">Select</th> 
                            <!--<th colspan="1" scope="col" class="headerRow">Id</th>---->
                            <th colspan="1" scope="col" class="headerRow">Subject</th>
                            <th colspan="1" scope="col" class="headerRow">Priority</th>
                            <th colspan="1" scope="col" class="headerRow">Status</th>
                            <th colspan="1" scope="col" class="headerRow">ActivityDate</th>
                            <th colspan="1" scope="col" class="headerRow">OwnerName</th>
                        </tr>
                    </thead>
                <!-- table body left empty for populating via row template using jquery-------> 
                    <tbody />
                </table>
            </apex:pageBlockSection>
        </apex:outputPanel>  
        
    <script id="resultTableRowTemplate" type="text/x-jquery-tmpl">
        <tr onfocus="if (window.hiOn){hiOn(this);}" onblur="if (window.hiOff){hiOff(this);}" onmouseout="if (window.hiOff){hiOff(this);} " onmouseover="if (window.hiOn){hiOn(this);} " class="dataRow even  first">
            <td class="datacel">${Select}<input type = "checkbox" id="${Id}"/></td>
            <!---<td class="Idvalue">${Id}</td>------>
            <td class="datacell">${Subject}</td>
            <td class="dataCell">${Priority}</td>
            <td class="dataCell">${Status}</td>
            <td class="datecell">${ActivityDate}</td>
            <td class="datacell">${Owner.Name}</td>      
        </tr>
    </script>
    
  </apex:pageBlock> 
                 
    <script type="text/javascript">
        // if you are inside some component
        // use jquery nonConflict
        // var t$ = jQuery.noConflict();
        console.log("check call correct");
      
        function getTask() {
        
            var dueDate = $('[id$=":demo"]').val();//$('#demo').val();
            console.log("check data",dueDate);
            // clear previous results, if any
            $("#searchResults tbody").html('');
            
            // The Spring-11 gift from force.com. Javascript remoting fires here
            // Please note "abhinav" if my org wide namespace prefix
            // testremotingcontroller is the Apex controller
            // searchAccounts is Apex Controller method demarcated with @RemoteAction annotation.
            // DEPRECATED -     abhinav.testremotingcontroller.searchAccounts( accountName, ...) 
            // NEW - summer'12 approach for calling'
            
            dueDate = JSON.stringify(dueDate);
            Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.TaskOwnerUpdate.getTask}',
                           dueDate, function(result, event){  
                           console.log("due date",dueDate);          
                if (event.status && event.result) {  
                  $.each(event.result, function () {                
                     // for each result, apply it to template and append generated markup
                     // to the results table body.
                     $("#resultTableRowTemplate" ).tmpl(this).appendTo( "#searchResults tbody" );
                  }
                 );            
                } else {
                   alert(event.message);
                }
            }, {escape:true});
        }
    </script>

    <script type="text/javascript">
        console.log("check update correct");
        
        $(function () {
          
          $('.datacel').click(function() {
            var allData = $(this).parent().parent().first().text();
            console.log("allData value is>>>>",allData);
            //alert(allData);
          });
          
          $('input:not(#button)').click(function () {
            t = $(this).attr('id');
        
            text = $('.time' + t).text();
            //alert(text);
          });
        
          $('#button').click(function (e) {
            e.preventDefault();
            var trs = $('table tr');
            var values = trs.first().find('td');
           // var idr = $('#Idvalue').val();
           // console.log("idr value",idr);
            var values1 = $('table tr td :checkbox:checked').map(function () {
             
             console.log('\nId::::',$(this).attr('id'));
             return $(this).attr('id');
             
             /*return $(this).closest('tr').find('td').text() + "=="
             + values.eq($(this).parent().index()).text();
             console.log("id val",$(this).parent().find('td').eq(1).text());
             return $(this).closest('td').find('td').eq(1).text()+
             values.eq($(this).parent().intex()).text();*/
                
            }).get(); 
                
            console.log("values1",values1);
            getUpdate(values1);
            console.log("after passing vales1", values1);
            console.log("values1",values1);
            return values1;

            });
        
            //alert(values1);
            //console.log("values1",values1);
            //return values1;           
            //getUpdate(values1);
        
          });    
    
        function getUpdate(values1) { 
        
            var taskRecord = JSON.stringify(values1);
            console.log("data type taskRecord",typeof(taskRecord));
            console.log("task record value is>>>",taskRecord);
            var ownerIdValue = $('[id$="owner_lkid"]').val();
            console.log("data type ownerIdValue",typeof(ownerIdValue));
            //var ownerIdValue = document.getElementById('{!$Component.owner}').value;
            console.log("ownerId value is >>>>",ownerIdValue);
            console.log("values1 >>>>",values1);
            Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.TaskOwnerUpdate.updateTask}',
                       ownerIdValue, taskRecord, function(result, event){  
                              
            if (event.status) {  
            
                     callaction();   
            } else {
               
            }
            }, {escape:true});            
         }
    </script> 

    </apex:form>
</apex:page>

For any response appreciated!!!! 
NagendraNagendra (Salesforce Developers) 
Hi Mohan,

May I suggest you to please check with below link from stack exchange community which might help you with above requirement. Regards,
Nagendra.
Suraj SinghSuraj Singh
This will be handle in two ways: 
1st: on VF page:
Use this javascript to parse your response date in milliseconds
var date = new Date(1500422400000);
console.log(date.getMonth() + '/' + date.getDate() + '/' + date.getFullYear());
2nd: on Controller

Create a modal class and parse your date in respective formate before showing on page
just like :
DateTime dt = DateTime.newInstance(activeityDate.year(),activeityDate.month(),activeityDate.day(),0,0,0);
                    String ActivityDateStr = dt.format('EEE MMM dd yyyy hh:mm a');



 
Mohan Raj 33Mohan Raj 33
@Suraj Singh 
thanks for your reply.but i don't know to provided result will be help to me. I am here using the datatable to provide the result of every time to click the gettask button. Like iterative so your first solution is possible for the my condition ? and please explain brief on your second solution with code for better understanding for myself please.