Populate date field in onChange client script

Elena Pomana
Tera Guru

Hello,

On the contract form have 3 fields. Contract end date should be calculated based on Contract start date + duration months. I created a client script and a script include but somehow I always get "null".

I work in scope, but both client script and script include are created in scope.

e.g.

Contract start date: 2022-01-01

Duration months: 12

Contract end date: should be 2022-12-31

My client script:

find_real_file.png

My script include:

find_real_file.png

My log from script include returns the correct answer:

find_real_file.png

My info message from client script returns null:

find_real_file.png

What am I missing?

 

Thank you,

Elena

 

 

 

1 ACCEPTED SOLUTION

Hi,

Your script include is in Service Module Integration scope so the API name should not start with global.

Can you try creating a fresh script include in your scope and verify this

regards
Ankur

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

View solution in original post

8 REPLIES 8

Check this

1) the script include API name should not be global. since it is not in global scope; it's in Service Module Integration scope the scope name would be different

2) try to add gs.info() to debug in the script include function; gs.log() will break the code in scoped app

Regards
Ankur

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

1) the API name of the script include is: global.AddendumCalculation

2) used gs.info, but the answer is still null 😞

Am I missing something?

Hi,

Your script include is in Service Module Integration scope so the API name should not start with global.

Can you try creating a fresh script include in your scope and verify this

regards
Ankur

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

@Elena Pomana 

any update to this one?

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

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