We recommend reviewing what is submitted before posting, in case your idea has already been submitted by another community member. If it has been submitted, vote for that existing feature request (by clicking the up arrow) to increase its opportunity of being added to Cireson solutions.
For more information around feature requests in the Cireson Community click here.
Cireson Portal fields mandatory based on other fields value
From our business we have optional maintenance contracts or custom support options for our software contracts that have a relationship with date and/or other field.
So when a software CI has a maintenance contract, a boolean field is changed from 0 to 1. Once this boolean is changed to 1, we would like some other fields, like date fields, to become mandatory.
At the moment, I can make a field mandatory by Required: true, but then it always applies, I would like to have the functionaliteit to let it be dependent on another field.
Comments
@Bart_Leving it is possible to have fields be required based on the condition of a Boolean field. Rather than setting Required to true or false, you can set it to a Boolean property. I'm not sure which Boolean property you're wanting to base the requirement on, but you can use pageForm.viewModel.<propertyName> as the value for Required. Here is a screenshot from the incident form that makes Assigned User required if the Escalated box is checked:
The only catch to this is it doesn't take effect immediately. The page has to refresh before requirement is enforced.
Justin, thank you, I will check this out.
@Justin_Workman I tried that in our Software Asset Form with a boolean and it didn't work :( When I wrote it like in the screenshot I wasn't able to open any SW asset, as a layout error has been shown and when I set it under quotation marks, it doesn't work neither.
Is there some dependency I have to check?
@Simon_Zeinhofer - Which property were you using on the Software Asset?
@Justin_Workman a custom Property (Enumeration List), which should only be required, when a custom boolean is set to true.
What's the name of the bool property? Can you show me your form definition?
@Justin_Workman the form definition is as followed:
But when I use it that way, an error message appears, whenever I want to open a SW Asset in the portal
I experience the same issue with my custom property (Date Field), which should be required when custom boolean is set to true.
I have double checked the values in the class to be correct, but once I add: Required: pageForm.viewModel.<value>, the license page goes into error.
@Simon_Zeinhofer @Bart_Leving - you guys are correct! The Asset Management forms go through some additional backend validation that the work items don't go through and therefore can't have js statements determine the requirement on the controls. I built a custom task to get around this. It's available here:
https://github.com/justinkwork/SWARequired/blob/main/SWARequired.js
This has the added benefit of listening for changes to the viewModel and therefore the requirement on the contingentProps updates according to the current value of the boolProp.
@Justin_Workman
Woah...
@Justin_Workman How about a "Definitive Cireson JavaScript " Course, like Adam's powershell one 😁
Simon,
Its an interesting request. Have you watched the eLearning Masterclass? Particularly these two sections?
Geoff
@Justin_Workman Thank you for the code!
I will also implement this on our side.
I understand which variables to use, but I am not used to work with javascript tasks in the Cireson Portal. Should I put the piece of code from SWARequired.js in the Custom.js file or can I have just separate .js file like SWARequired.js in my Custom folder for all the fields that I want to have this functionality?
@Geoff_Ross as we don't have Cireson Plus, we haven't :(
Looks very interesting though :)
@Bart_Leving - You can add the SWARequired.js file to CustomSpace then call it using loadScript. You will have to add loadScript to your custom.js. Here is a quick instruction on that:
https://community.cireson.com/discussion/comment/14268#Comment_14268
@Justin_Workman Thank you, that works for me.
In my case with License management, I had to change SoftwareAsset into License, but then adding the loadScript to custom.js makes everything work like a charm.
@Bart_Leving - Great! Glad to hear it!