- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 09:48 AM - edited 07-21-2023 10:06 AM
Hi All,
i am new to split function.
I want to separate date, month and year from dd-mm-yyyy format on catalog item and show just month at there.
there are 2 variables. one is date [dt] and second is show date[u_sd]. the requirement is: autopopulate date on show date variable and the date that is present on show date, it's month must be convert into name, like jan for 1 or march for 3 etc.
thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 11:19 AM
hello @DEV976 ,
write a onchange client script on first date field and try code like below.
you can do something like below:-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 06:19 AM - edited 07-25-2023 07:27 AM
Hello @DEV976
unction onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var months=["jan","feb","march","april","may","june","july","sep","october","november","december"];
newValue= newValue.split("-",[3]);
var month=newValue[1];
var name=(months[month-1]);
var dateM = newValue[2].split("");
var date2;
if((dateM[0]==0 || dateM[0]==2) && (dateM[1]==1)) {
date2= newValue[0]+"-"+name+"-"+newValue[2]+"st";
}
else if((dateM[0]==0 || dateM[0]==2)&& (dateM[1]==2) ){
date2= newValue[0]+"-"+name+"-"+newValue[2]+"nd";
}
else if((dateM[0]==0 || dateM[0]==2) && (dateM[1]==3) ){
date2= newValue[0]+"-"+name+"-"+newValue[2]+"rd";
}
else{
date2= newValue[0]+"-"+name+"-"+newValue[2]+"th";
}
g_form.setValue('u_date2',date2);
}
I have tried on my pdi, it is working fine.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 11:19 AM
hello @DEV976 ,
write a onchange client script on first date field and try code like below.
you can do something like below:-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 12:12 PM
@Ranjit Nimbalka, i've try your code but it is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 12:14 PM
please use field names as your field or share the screenshot what error u r getting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 12:18 PM
it is catalog variable name:
u_date (from there I am taking date) and write(it contain the july value)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 12:20 PM
so you have two field one is date type second is string and if you select 2023-07-17 in date field then you want to set JULY into second string type field is it right?