1

I want to set the default value from a dropdown field based on the content type. So basically: If Contenttype equals "HW" than set dropdown default value to "1". Each time I try to set the following formula

=IF([Contenttype]="HW",1,2)

I get the error

The formula has errors or is not supported

Screen from the UI (display language is set to german)

enter image description here

1

You are on the right track. Have you tried to using a calculated column yet? (List Settings>Create Column>Calculated Column).

I think you are using a normal field (number field or text field)? The formula in these fields types is not powerful, the Calculated Column will be able to do what you need.

Calc column picture

In my example I have a field called Unit. Possible values in this field are Unit 1, Unit 2, Unit 3 and so on. I have defined my formula to return a '1' if the value is 'Unit 1'. If the value is not 'Unit 1' the formula returns a '2'.

You just need to create a Calculated Column and use your own field name and values.

  • Sorry for the late reply! Sure a calculated column would be an option. But I need it in the new form directly so the user do not have to change the option, but if they need to change the value it should be still possible. – Oskar Mar 22 '18 at 14:11
0

Maybe this is helpful:

One workaround I have used for this issue is to add a custom field to a content type, and then check its value. For example, I might add a yes/no field called IsTask to the Task content type, and default it to Yes. The the formula would look like this:

=IF([IsTask], "This is a task", "Not a task")

There are some additional complications in using a yes/no field this way, since the UI won't let you mark them as hidden. (Why not?) But you can hide them behind the scenes by setting the ShowInDisplayForm, ShowInEditForm, and ShowInNewForm values. Or if you don't like going behind the scenes, simply use a text field instead.

link

  • Sorry for the late reply! This wasn't the approach I wanted, but the mention about the forms was the hint I needed: I ended up editing the NewForm.aspx and add some javascript that will do the selection for me. – Oskar Mar 22 '18 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.