Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

validation of user form date fields with organization date fields

Padmavathi
Regular Contributor
Regular Contributor

Hi Team, 

we have a requirement like validating the user form dates fields in between organization date fields.

Trying the below way.

1. Created a hidden attribute in user form which contains organization startdate from customer table. so, that we can compare user form startdate with organization startdate under validation condition ${(startdate <= orgstartdate )}.
But, while retriving the start date of organization date field from database attribute type is coming as string instead of Datetime. so, whenever trying to validate getting this below error.

"java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date" 

Tried converting string to date format in mysql query as well as in validation condition, still same error.


2. Tried to place the query directly in validation condition like below

 ${((startdate) >= (select startdate as id from customer where customername = "ACN" ))}

but getting this below error

SimpleTemplateScript145.groovy: 1: expecting ')', found 'startdate' @ line 1, column 40.
out.print("""${((startdate) >= (select startdate as id from customer where customername = "ACN" ))}""");


Can anyone please suggest the way that, how can we get the functionality.

Thanks in Advance!

6 REPLIES 6

Dhruv_S
Saviynt Employee
Saviynt Employee

Hi @Padmavathi 

Could you please share full screenshot of the attribute from register user form and also please confirm the attribute type mentioned in the attribute details.

Regards,

Dhruv Sharma

Padmavathi
Regular Contributor
Regular Contributor

Hi @Dhruv_S 

Thanks for the response !

Please find the attached screenshot of user form. attribute type of startedate (user) is Date, the attribute type of orgstartdate (organization) is SQL ENUM

we have converted that SQL Enum output (from db it is coming as string type) into date in validation condition and validated. It is working.

We tried this way, please suggest us the other ways that we can use. 

Thanks in advance!

 

Padmavathi_0-1707920140124.png

 

Hi @Padmavathi 

Please check and confirm what is the format of date in the output of the below query. Please share screenshot of the output.

select startdate as id from customer where customername = "ACN" 

Regards,

Dhruv Sharma

Dhruv_S
Saviynt Employee
Saviynt Employee

Hi @Padmavathi 

Just checking if the issue got resolved? If not- could you, please provide the information requested above.

Regards,

Dhruv Sharma

Padmavathi
Regular Contributor
Regular Contributor

Hi @Dhruv_S 

Sorry for the delay!

The output of the query is coming in string format. then we converted that into date using date parse under validation condition. Now, the issue is resolved.

 

${(Date.parse("yyyy-MM-dd", orgenddate) >= enddate) && (enddate >=(startdate))}

Padmavathi_0-1708617186123.png

 

Thanks!

Dave
Community Manager
Community Manager

Hi @Padmavathi - Please click the "Accept As Solution" button on the reply (or replies) that best answered your original question. 

Solution.JPG

Thank you!