I have 2 custom fields named "Contract type" and "Legal Reviewer" where "Contract type" is a single choice select list (2 options: Template, Non-template) and "Legal Reviewer" is a single user picker.
Currently "Legal Reviewer" is set as hidden. I want to show it when user choose "Non-template" for "Contract type" on the create screen.
Here's my attempt:
def fieldToHide = getFieldByName("Legal Reviewer")
def contractCf = getFieldByName("Contract type")
def optionValue = contractCf.getValue().toString()
fieldToHide.setHidden(true)
if (optionValue == 'Non-template') {
fieldToHide.setHidden(false)
}
There are no errors shown but the script doesn't work. When I choose "Non-template" the field "Legal Reviewer" doesn't show up. Any idea what I did wrong here? Thanks in advance.
You need to add the Contract type field to your behaviour and define the script in your question for the added field. Right now I guess you defined the script for the whole behaviour.
You're right. I just need to move the script to the behaviour for Contract Type field. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Initializer fires only once, when a screen is loaded. Server Side script for a field fires everytime, when the value of the field changed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Got it! Thanks for the clear response.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also have the same requirement. I tried the same as explained above but its not working. Here I can use the normal Text Fields too right? or any special Type of Field?
And should the fields be a part of the Request ( Customer Portal) or should not be included there, if we want to hide them depending on the other field behaviour ? How does Field Change work here?
Do I also need a Initilaiser ?
@Nguyen Tran what do you mean by " I just need to move the script to the behaviour for Contract Type field" When I add the field in the Behaviour then I can just add the Server Side Schript below it. This is what needs to be done. Right? or there is any other setting which I might be missing ?
Thanks in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @[deleted],
You should be able to do it with text field as well. What I did was putting the server side script into the "Contract type" field (It was in the "Legal Reviewer" field).
Let say you have field A with a few options and field B that will be showing/hidden depends on field A. Put your server side script to field A so the script fire every time field A's value changes.
Hope this helps.
Nguyen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does that mean that field A needs to be a scriptable field? Or is there a way to attach the script to a regular field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guys,
I have taken Nguyen Tran code, and put it into my behaviour, in the Urgencia field, server-side.
def fieldToHide = getFieldByName("Oculto")
def urgencia = getFieldByName("Urgencia")
def optionValue = urgencia.getValue().toString()
fieldToHide.setHidden(true)
if (optionValue == 'Critical') {
fieldToHide.setHidden(false)
}
and there is no error, but it seems it does not do anything, I mean, I log into the customer portal, raise a request, and in the create screen I see Oculto field, though the Urgencia value is not Critical.
I appreciate any help, please. I am new in this kind of things. Thanks in advance.
Cheers,
Almu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you need to specify the issue when getting a custom field value.
Something like:
customField.getValue(issue)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I want to do this when user is creating the issue. So on the Create screen user would select option for the custom field and the hidden field will show up or hidden according to the selected option. Would the value for "issue" be there if the issue is not created?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Where are you running this script?
Is it as a post function? If it is then it will only execute once the transition occurres.
Maybe you could write a validation script, to only accept the value based on the first field's value?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
See below comment from Alexey.
Missunderstood the question. You need to configure behaviors.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.