How to select the only year in date field

Pushpa
Mega Expert

Hi Team,

 

How to select only year from date field.

please any one help on this.

 

Regards,

Pushpa

1 ACCEPTED SOLUTION

Hi,

for that you can use onLoad client script with GlideAjax

1) script include will check which is the current quarter and based on that hide the other quarter

Sample script to determine the quarter in server side

var test = new GlideDateTime();

var month = test.getMonth();

var quarter = Math.ceil(month/3);

gs.info('Current quarter is->'+quarter);

Output:

[0:00:00.069] Script completed in scope global: script


Script execution history and recovery available here


*** Script: Current quarter is->2

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

12 REPLIES 12

Hi Ankur,

 

Please share in details. 

Hi,

the main part on how to check the quarter is shared above.

You need to perform onLoad Client script with GlideAjax

in client script based on quarter value you need to hide the values

if(quarter == 1){

// do nothing

}

if(quarter == 2){

// hide choice value for Q1

}

if(quarter == 3){

// hide choice value for Q1,Q2

}

if(quarter == 4){

// hide choice value for Q1,Q2,Q3

}

Let me know if I have answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Pushpa 

Hope you are doing good.

Did my reply answer your question?

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Thanks!
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader