Display Planned start time in Service Portal

palmen
Tera Guru

In the Service portal when you open a change as an end user, we want to display the field "Planned start date".

There is no issue to display the field in the widget suming up the change, but the valu showing is incorrect.

If the Planned start date is 4 days ago it all show correct

find_real_file.png

If I change the Planned start date to be 4 days in the future it display the value "just now" which is totally wrong

find_real_file.png

As you can see the planned start date is 2016-09-12 12:36:56 but the displayed value is transformed into "just now" which is wrong.

Any idea how this can be changed? Seems like there are some automatic function that display all date/time fields as "just now" when they are in the future.

1 ACCEPTED SOLUTION

palmen
Tera Guru

I raised a ticket to HI on this and their reply is that it's by design.


In my opinion this is a bad design since we can't customize the portal the way we want.


If the creation date would be in the future you have other issues in your instane you need to take care of, not write correcting code for the portal to solve bad data. You should always correct whatever is wrong, not write a new solution and keep the incorrect behaviour.




"Even though in the back-end we can set the data to be in the future, this was a design decision in the service portal in order to avoid showing potentially bad data with future dates, as it doesn't make sense for a Change Request's creation date to be in the future, so the assumption is that the data is wrong. You also still have "planned start date" for future dates."


View solution in original post

12 REPLIES 12

Inactive_Us1474
Giga Guru

Edit the widget and check how the start dates are getting set.


Widget editor



Thanks


Akhil


Hit Like/Helpful/Correct, if applicable.


In the widget we capture the display value, but it's being transformed to "Just now".


I need to know where I can find the code transforming the date/time value and can't find anythign about it in the widget.



This is the code we use, it follow the same structure as the code for "recurring price" which is there out of the box.


if (gr.getValue('start_date') != null) {


  var sd = $sp.getField(gr, 'start_date');


  if (gr.isValidField("start_date"))


  sd.display_value = sd.display_value + " " + gr.getDisplayValue("start_date");


  fields.push(sd);


}


Could you paste the full widget script as fields are not defined and where it is printing the start_date field.


It's the out of box widget we are using with this modification



HTML Template


<div ng-if="data.canRead" class="panel b">


  <div class="panel-heading bg-primary">


      <div ng-init="spSearch.targetRequests()">


          <sp-c-link target="form" table="data.table" id="data.sys_id"/>


      </div>


      <span ng-if="data.agent" >


          ${Agent working on this {{data.tableLabel}}}:


          <div>{{data.agent}}</div>


      </span>


      <span ng-if="!data.agent && data.agentPossible" >${Your request has been submitted}</span>


      <span ng-if="!data.agentPossible">${{{data.tableLabel}} record details}</span>


  </div>




  <div class="panel-body">


      <div ng-if="data.fields.length > 0">


          <div class="row">


              <div class="col-md-6 col-sm-12 col-xs-6 m-b break-word" ng-repeat="field in data.fields"


                        ng-if="field.value && (field.type != 'decimal' || field.type == 'decimal' && field.value != 0)" >


                  <label class="m-n">{{field.label}}</label>


                  <span ng-switch="field.type">


                      <div ng-switch-when="glide_date_time" title="{{field.display_value}}">


                          <sn-time-ago timestamp="::field.value" />


                      </div>


                      <div ng-switch-default >{{field.display_value}}</div>


                  </span>


              </div>


          </div>


      </div>




      <div ng-if="data.variables.length > 0" ng-init="variable_toggle=true">


          <h4 ng-click="variable_toggle = !variable_toggle" style="cursor: pointer;">


              <span style="font-size: 12px;" class="glyphicon"


                          ng-class="{'glyphicon-chevron-down': !variable_toggle, 'glyphicon-chevron-up': variable_toggle}"></span>


              ${Options}


          </h4>


         


          <div ng-if="variable_toggle">


              <hr>


              <div class="m-b break-word" ng-repeat="variable in data.variables">


                  <label class="m-n">{{variable.label}}</label>


                  <div>{{variable.display_value}}</div>


              </div>


          </div>


      </div>


  </div>




  <div ng-if="data.agentPossible && !data.agent && options.pickup_msg" class="panel-footer">


      <div id="ticket_fields_footer" class="text-center text-muted" style="font-style: italic;" ng-bind-html="options.pickup_msg">


      </div>


  </div>




</div>



Server Script


(function(){


  var gr = $sp.getRecord();


  data.canRead = gr.canRead();


  if (!data.canRead)


  return;




  var agent = "";


  var a = $sp.getField(gr, 'assigned_to');


  if (a != null)


  agent = a.display_value;




  var fields = $sp.getFields(gr, 'number,state,priority,sys_created_on,assigned_to');


  if (gr.getValue("sys_mod_count") > 0)


  fields.push($sp.getField(gr, 'sys_updated_on'));




  if (gr.getValue('price') > 0)


  fields.push($sp.getField(gr, 'price'));



  if (gr.getValue('recurring_price') > 0) {


  var rp = $sp.getField(gr, 'recurring_price');


  if (gr.isValidField("recurring_price"))


  rp.display_value = rp.display_value + " " + gr.getDisplayValue("recurring_frequency");


  fields.push(rp);


  }


  //This is the code we've added to display Planned start date:


  if (gr.getValue('start_date') != null) {


  var sd = $sp.getField(gr, 'start_date');


  if (gr.isValidField("start_date"))


  sd.display_value = sd.display_value + " " + gr.getDisplayValue("start_date");


  fields.push(sd);


  }


  //End of our code



  data.tableLabel = gr.getLabel();


  data.fields = fields;


  data.variables = $sp.getVariablesArray();


  data.agent = agent;


  data.agentPossible = gr.isValidField("assigned_to");


  data.table = gr.getTableName();


  data.sys_id = gr.getUniqueValue();


})()