Configuring Styles for a Particular Field

preethiraokn
Kilo Explorer

Hi ,

Requirement is need to configure Styles for   Status Indicator field based on condition.

The condition is ,If current date < Expected closure date , the field by the name status indicator should be green

We defined   by writing the value but it is not wokring

Script was   javascript:gs.nowDateTime()<current.u_glide_date_time_60

find_real_file.png

Regards
Preethi

14 REPLIES 14

preethiraokn
Kilo Explorer

Hi Shishir,



As suggested tried with javascript:gs.dateDiff(gs.nowDateTime(), current.u_glide_date_time_60, true) <= 0 but it is not working



Thanks


Preethi


preethiraokn
Kilo Explorer

Thanks for your inputs Harsh


In List view also the status indicator field is not getting updated with color.


Also if i want the configure styles to work on list and form level then i need to leave the value as blank.


But if i leave value as blank then i cannot define the conditions here at all



find_real_file.png


Please refer the thread below. hope it will help you



field conditional formatting


by the way i checked at my end and it's working on my PDI. yes i test on list view.


Please check if this helps.



Script Include:


var clientDateTimeUtils = Class.create();


clientDateTimeUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {


isDateTimeBefore: function() {


var nowdate1 = new GlideDateTime();


var dt = new GlideDateTime(this.getParameter('sysparm_date'));


var diff = gs.dateDiff(nowdate1.getDisplayValue(), dt.getDisplayValue(), true);


if(diff<0)


return true;


},


type: 'clientDateTimeUtils'


});



Client Script:


function onChange(control, oldValue, newValue, isLoading) {


if (isLoading || newValue == '') {


return;


}


var ajaxStartDate = new GlideAjax('clientDateTimeUtils');


ajaxStartDate.addParam('sysparm_name', 'isDateTimeBefore');


ajaxStartDate.addParam('sysparm_date', newValue);


ajaxStartDate.getXML(validateStartDate);


function validateStartDate(response) {


var answer = response.responseXML.documentElement.getAttribute("answer");


if(answer == 'true')


g_form.getControl('u_status_indicator').style.backgroundColor = "#32cd32"; //Changes the field color to LimeGreen.


}