- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-22-2022 05:23 AM - edited ā12-22-2022 05:43 AM
Hi,
I have a catalog form.In which i have two fields.
Field one-- is a single line text type.
Field two--is a date type.
So now my requirement is whenever we enter 1 value in field one then field two must populate todays date.
And when we enter 2 value in field one then field two must populate tomorrow date.
And when we enter 3 in field one then field two must populate day after tomorrow date....etc.
Kindly provide ur inputs,it is on priority.
Best Regards,
Shaik Nabi Khaja.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-23-2022 02:08 AM
Hi taha,
Just now i have implemented but is is not working.
Have u tried this code in ur PDI.
Please help me.
Thanks,
Shaik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-23-2022 05:40 AM
Hey Nabi,
Try the following script in your script include, you just have to change the function to use
"addYearsLocalTime."
var ScriptIncludeExampleThree = Class.create();
ScriptIncludeExampleThree.prototype = Object.extendsObject(AbstractAjaxProcessor, {
helloWorld:function() {
gs.log("lolatleast");
//var dtc= this.getParameter('caldate');
var days= this.getParameter('noofday');
var gdt = new GlideDateTime();
//gdt.setValue(dtc);
// gdt.addDaysLocalTime(days);
//gdt.addDaysLocalTime(-1); // to implement for 1 value to have today's date and so on
gdt.addYearsLocalTime(days);
gdt.addYearsLocalTime(-1);
gs.info(gdt.getLocalDate());
return (gdt.getLocalDate());
} ,
type: 'ScriptIncludeExampleThree'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-23-2022 01:30 AM - edited ā12-23-2022 01:33 AM
Hello Shaik nabi khaj,
You can use a combination of catalog client scripts and the client callable script include to fulfill this requirement.
I have created the required scripts for your requirement, please have a look at it. I hope it helps you.
Here date is the backend name of your date field and integer_value is the backend name of your integer.
Catalog Client Script which will run on change of the integer field.
function onChange()
{
var datepass= g_form.getValue('date');
var day= g_form.getValue('integer_value');
var ga = new GlideAjax('global.ScriptIncludeExampleThree');
ga.addParam('sysparm_name', 'helloWorld');
ga.addParam('noofday', day);
ga.addParam('caldate', datepass);
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//alert(answer);
g_form.setValue('date', answer);
}
}
Client Callable script Include:
var ScriptIncludeExampleThree = Class.create();
ScriptIncludeExampleThree.prototype = Object.extendsObject(AbstractAjaxProcessor, {
helloWorld:function() {
//gs.log("lol atleast");
//var dtc= this.getParameter('caldate');
var days= this.getParameter('noofday');
var gdt = new GlideDateTime();
//gdt.setValue(dtc);
gdt.addDaysLocalTime(days);
gdt.addDaysLocalTime(-1); // to implement for 1 value to have today's date and so on
gs.info(gdt.getLocalDate());
return (gdt.getLocalDate());
} ,
type: 'ScriptIncludeExampleThree'
});
Catalog client script:
Script Include:
Result:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-23-2022 02:08 AM
Hi taha,
Just now i have implemented but is is not working.
Have u tried this code in ur PDI.
Please help me.
Thanks,
Shaik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-23-2022 02:19 AM
Hi Taha,
Just now i have implemented again.
it is working as expected as.
Thanks alot.
Best Regards,
Shaik Nabi Khaja.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-23-2022 02:40 AM
If you find the solution helpful mark it as Helpful please, Thank you.