How to validate constraints of complex contract input

1
0
-1

Hello,

I have a complex contract with another complex contract.

open?id=1wCgNRkfhw6_68Frc6zZ8axGq7zqp7LMe

picture

open?id=1wCgNRkfhw6_68Frc6zZ8axGq7zqp7LMe

I would like to validate the end date should be in the future as an example.

travelRequestInput.departureDate.isAfter(java.time.LocalDate.now())

In case of array object, how to validate list of end date input on Constraints tab?

I tried to create a groovy script but I couldn't get yet.

I am confusing how it approaches the issue actually.

Any help would be appreciated.

Thanks in advanced

Comments

Submitted by Dibyajit.Roy on Sat, 02/23/2019 - 07:32

Hi
Which version of BonitaSoft are you using ? Community or Subscription.

For Subscription version, you can do this at the Front end. Usually I create a fragment that takes the values and use Javascript to validate my scenario. Hence I can put restriction on data in the Form itsef.

Submitted by donghee.baik on Mon, 02/25/2019 - 15:20

Thanks for the comment.

I am using the Subscription version. As you recommended, I tried to add a javascript variable in UI.

I put the date piker value as String then, using javascript, the date can be validated.

However, I am confusing how to return $item.enddate from javascript because the input date form has to return $item.enddate.

Would you explain more detail?

Thanks in advanced.

Submitted by Dibyajit.Roy on Mon, 02/25/2019 - 16:13

Hello
I am assuming that you have been successful in doing the validation as you wanted ?
If yes, then to return value in javascript, you can use $data.item.enddate
But this is how we do inside a Fragment.

Do you have a sample page that you can share in google drive. I will download it and take a look.
Please do mention which version of Bpm Studio you are using.

Regards

Submitted by donghee.baik on Mon, 02/25/2019 - 16:32

I appreciate your help.

I am using BONITA subscription 7.6.3 version.

I created a validation sample form and shared with url :

https://drive.google.com/open?id=1-bxXKo522cMCNZHLb2gzMFnxV-Y_nGrs

Thanks a lot.

Best regards

Submitted by Dibyajit.Roy on Mon, 02/25/2019 - 18:06

Hi
Here is the link to download the form
https://drive.google.com/file/d/1HCqDf959sTOZkrnObwIZsr5mGpDHc86y/view?usp=sharing

I had version 7.8.2 installed . Please see if you are able to import it.
The change is very easy. I can explain it in case you are not able to open the form.

regards

Submitted by donghee.baik on Mon, 02/25/2019 - 18:21

Thanks a lot!

Unfortunately, I couldn't install the form you shared. I tried to change page.json. It still has an error.

I would appreciate if you explain how it works.

Best regards,

Submitted by Dibyajit.Roy on Mon, 02/25/2019 - 18:40

Hello
Here is the Pic
https://drive.google.com/file/d/1lc4QVEP282-r6Rf_1MM0GL4EUJh-s6av/view?u...

1) Take a Container. Set the value of the container as $item.timerTask
Inside the container, take 1 text widget, 2 date widget and set the value of Text as $item.title, $item.StartDate,$item.endDate
(You have already done this part.)

2)Save the Container as Fragment. Set a Name for the Fragment. Please refer to my Pic 1. After you have already created the fragment it will be available in the form. Just take a new container. drag the Fragment inside the container. Set the value of the container as $item.timerTask (same as before)

3) Edit the fragment and add the following variables inside the Fragment.
i) item - type should be yes you must bind the variable to a variable in the page....
ii) checkDate - javascript Expression -- set the code as below

var dataDa = $data.item.startDate;
var today = new Date();
if(dataDa < today ){
alert("Error: end date should be after today");
}
//return $item.startdate;

3)Save the Fragment. Go back to the Form. click On the Fragment. set item as $item.

4) Remove validation from the form

P.S -i will share screenshots of the steps as well.

regards

Submitted by donghee.baik on Mon, 02/25/2019 - 20:39

Thanks a lot. I appreciated your help.

Finally, I got the answer, I need to update the javascript.

Thanks for helping me to solve the issue.

Best regards,

No answers yet.
Notifications