TFS 'when' and 'required' rules does not set the field to required - tfs-workitem

I have a custom field (fixedInVersion), the field is required when state = 'Closed'.
I also have a custom control for the field (combo with sorting, because the default sorting of TFS control is ascending).
When the work Item state is Closed, I display in my control Required but the user can still save the work item without getting error.
Does anyone knows what is the problem?
If I remove the text Required the item cannot be saved, but the only indication for the user is that the combo is yellow (no text Required is displayed).

The "When" Required value, did you use it? see the following example:
<FieldDefinition refname="fixedInVersion" name="fixedInVersion" type="String">
<WHEN field="System.State" value="Closed">
<REQUIRED />
</WHEN>
</FieldDefinition>

Related

Way to make Dropdown Form Fields required in semantic ui react

I have a Form, Is there a way to make these Dropdown Fields required?
Yes it's possible to make a Dropdown field required :
<Form.DropDown
required
fluid
label='Required Dropdown'
options={options}
/>
As per my knowledge i dont think "required" works with Form.select in semantic ui.
What we can do is use if and else in the handleSubmit function and not let the function run when Form.select is empty and show a relevant message to the user.

ColdFusion 10 getting element is undefined in form error

I've got a ColdFusion 10 form, to which I'm adding a new multiple select list
<SELECT multiple="multiple" id="icd9list"
name="icd9list"
size="2"
class="pageText2"
style="width:400px;">
</SELECT>
It shows up on the form correctly and I can get items added to it with JavaScript, but when I go to process the form, the form action page is giving the following error:
Element ICD9LIST is undefined in FORM.
I've added cfparam tags on the initial form page, as well as the form action page where I'm getting the error.
Can't for the life of me figure out why it's not passing the form element to the action page. The method is post, so it should be picking it up. All of the other form elements on the page are picked up fine.
<cfform action="updform.cfm" name="custform" method="POST">
I also tried to use custform.icd9list and got the same issue:
Element ICD9LIST is undefined in CUSTFORM.
This page is some VERY legacy code that we can't really go back and refactor too much. The only thing I'm thinking is that when the page first loads, the multiple select option is blank and then we are adding options to it via javascript from a pop-out window after the fact. When I inspect the element in Chrome, after I've added options to it, they are there, but I'm wondering if it's still being treated as a blank multiple select list. I do know that if I remove the multiple attribute and treat the form element as a single drop down list that it shows up in the form dump with a value, but only the first (or whatever selected) value.
Beginning to think the answer may be to have a hidden field with the option values populated and let the form read that.
Adding options to a multiple select list isn't enough. They have to be selected as well. Otherwise, the list isn't considered a successful control and the field won't be passed to the action page (emphasis mine)
A successful control is "valid" for submission. Every successful
control has its control name paired with its current value as part of
the submitted form data set. A successful control must be defined
within a FORM element and must have a control name.
However:
Controls that are disabled cannot be successful.
If a form contains more than one submit button, only the activated submit button is successful.
All "on" checkboxes may be successful.
For radio buttons that share the same value of the name attribute, only the "on" radio button may be successful.
For menus, the control name is provided by a SELECT element and values are provided by OPTION elements. Only selected options may be
successful. When no options are selected, the control is not
successful and neither the name nor any values are submitted to the
server when the form is submitted.
The current value of a file select is a list of one or more file names. Upon submission of the form, the contents of each file are
submitted with the rest of the form data. The file contents are
packaged according to the form's content type.
The current value of an object control is determined by the object's implementation.
I suspect the form isn't forcing the items to be "selected" before the form is submitted and that's why nothing shows up on the action page.
It sounds like you need one of two things
Either required it on the client side
<SELECT multiple="multiple" required id="icd9list" name="icd9list" size="2" class="pageText2" style="width:400px;">
...
</SELECT>
Or make sure ColdFusion can handle it not existing on the server side.
<cfparam name="icd9list" default="">
As pointed out,
<cfparam name="form.icd9list" default="">
will get an even tighter scope
How are you calling on the form? Are you using form.variable or icd9list.variable? You shouldn't have to give it an ID or name unless there are multiple forms on the page. You can just name and ID your element and reference it like this: form.name

Column from content type missing in document library

When I assign one of my content types to a document library, the last column defined in this content types is missing in the list of library columns. It is defined as
<Field
Type="Choice"
DisplayName="Document Class"
EnforceUniqueValues="FALSE"
Indexed="FALSE"
MaxLength="255"
Group="Project Site Columns"
ID="{xxx...x}"
StaticName="prj_document_class"
Name="prj_document_class"
ShowInNewForm="FALSE"
ShowInEditForm="FALSE"
ShowInDisplayForm="TRUE"
ShowInViewForms="FALSE"
ShowInListSettings="FALSE"
ShowInFileDlg="FALSE"
ShowInVersionHistory="TRUE">
<CHOICES>
<CHOICE>Public</CHOICE>
<CHOICE>Private</CHOICE>
</CHOICES>
</Field>
In the content type definition, the column is referenced as
<FieldRefs>
...
<FieldRef
ID="{xxx...x}"
DisplayName="Document Class"
Required="FALSE"
Name="prj_document_class"
Sortable="FALSE" />
</FieldRefs>
What am I doing wrong?
Have you added FieldRef to the Views in Schema.xml of your list?
Check your list's Content Types if they already have the required field. (Either with Sharepoint Manager or Powershell)
For powershell, try something like this:
$web = Get-SPWeb *site-url*
$list = $web.GetList(*list-url*)
$list.ContentTypes[*reqiured-content-type-index*].Fields.ContainsField(*field-name*)
If this function returns true, most likely your field is not in the required view.
If this function returns false try to add your field to the content type. Go to list settings -> manage content types. Choose 'Add a field from site columns'. If your field is really added to the site columns, you will be able to add it. Find it among the group you specified in Elements.xml of your field.
If you try to update a content type inside a testing environment and it's okay to lose all of the data, delete all of the lists associated with this content type. Then check both Recycle bins and clear all instances of your list and elements of that list. Then deactivate your feature. Check site content types and columns, your content type and columns must have disapeared. Only after this you should uninstall old solution and install new one.
It is also possible to update a content type with out losing all of the data, but it's a bit more tricky. The best way I know is to make one more feature, which will be your old feature updater. Make an event receiver for the new feature and inside FeatureActivated method add your new column to your site columns, content type, list and list's content type by using AddFieldAsXml method of SPFieldCollection (https://msdn.microsoft.com/en-us/library/office/ms457586.aspx)
I really hope this helps

JSF listeners in selectOneMenu

I have a selectOneMenu item with some products. Some of them are unavailable so after you click on it the button "Add" should be disabled and some message should appear that "Sorry the product you chose is currently unavailable". I have no idea how to achieve that. Tried listeners, ajax and still nothing.
This is one of many versions of my JSF Page:
<h:form>
<h:selectOneMenu value="#{productBean.productName}">
<f:selectItems id ="other" value="#{productBean.other}" var="other" itemValue="#{ordersBean.productName}" itemLabel="#{other.name}" />
<f:ajax listener="#{productBean.valueChanged}" />
</h:selectOneMenu>
<h:commandButton value ="Dodaj do zamówienia" rendered="#{productBean.available}"/>
<h:outputLabel id="orderSummary"/>
</h:form>
Beans are rather standard. I just need a clue how to do that and probably I will be able to do it myself.
Thanks in advance.
Here's one of the ways:
In your AJAX listener you could check if a product is available and set up bean field accordingly, or add a message for a component.
Introduce a component in your view that'll hold the message to the user, for example with the #{bean.available ? '' : 'Sorry, out of stock'} value, or enclose it within a <h:panelGroup> and let that component have a rendered attribute, or attach <h:message>/<h:messages> somewhere in your view.
Specify id of the message holder to be rendered within render attribute of <f:ajax> tag.

How can I display extra details in the autosuggest, but only ID in the input field?

I'm using a ColdFusion autosuggest for my UserID field. When a user starts to type in a UserID, a list of user ids and the user names associated with it pop up (populated by a cfc function). Sample code:
<cfinput name="userID" type="text" value="#userID#" autoSuggest="cfc:Utilities.suggestUser({cfautosuggestvalue})" matchcontains="true" />
The suggestions are listed in the format "User Name <userID>". So if the user would start typing 123, a sample suggestion that would pop up would be "Harvey Mann <1234>".
The problem is that if the user chooses that suggestion, I don't want to insert the whole suggested text into the input field - I just want to insert the user id ("1234" in this case). I would also like to be able to insert the user name ("Harvey Mann") into an adjacent field/area if possible. Is there any way to accomplish this?
Since you are using CF's built-in implementation of autosuggest, you are stuck with only having access to one returned value. Thus if the value consists of mutliple 'parts' and you want to insert different 'parts' of the value into different columns, you will have to parse the value and extract appropriate parts from the string. In your example case you could treat the value as a list delimited by <. In this case you can get the name 'part' with
trim(listfirst(form.userID, "<"))
and the id 'part' with
replace(listlast(form.userID, "<"), ">", "")
Alternatively, you can always use jQuery UI Autocomplete implementation - you'll have to write your own javascript for it, but it gives you far more control than the built-in cf's implementation. Check jQuery UI docs for more info: http://jqueryui.com/demos/autocomplete/
UPDATE:
On second thought, if you just want to display selected value's 'name' part in another area on the same page, you may be able to do it using just CF's built-in autosuggest and a bit of javascript. Try adding this code to the HEAD section of your page:
<cfajaxproxy bind="javaScript:showName({userID})">
<script type="text/javascript">
showName = function(strUserId) {
document.getElementById("someID").innerHTML = strUserId.split('<')[0];
}
</script>