none
Create sharepoint list column based on condition

    Question

  • Hello,

    I have require where I need a sharepoint column based on codition. Here is the example.

    let say i have one column created with radio button type so my choices would be A and B. Now if user chooses option B, there is one more column should show up which would be required field and let say It's column C. Now if the user choose A, I dont want column C to be apprear. Can anyone tell me how i can achieve this?

    Thanks, 

    Thursday, July 26, 2012 7:15 PM

Answers

  • Hello,

    Yes. you can use SharePoint Designer to create the custom aspx form and do the above requirement.

    In the SharePoint Designed you can see that list will be having 3 forms NewForm.aspx, EditForm.aspx & DispForm.aspx. If you want the requirement to be implemented in both the new form & edit form means do the changes in both the forms. Follow the below steps.

    1. Dont use the existing forms to implement the changes.
    2. Create the new NewForm & EditForm and save it in another name. Now delete the existing forms and rename the newly created ones to the respective names.
    3. Now you can implement the changes whatever you want in the aspx file.

    Thanks.

    Friday, July 27, 2012 4:43 AM

All replies

  • Hi abc67,

    to be able to achieve this you will

    1. create the column and add it to the list already
    2. create custom input form 
    3. in the custom form you will show and hide the Column C  based on the selection ->this can be achieved by Jquery the code will be something like below

    $("choice A radio button ID").click(

    function(){

        $("ColumnC Div ID").hide();

    deactivate validation here;

    }

    );
    $("choice B radio button ID").click(

    function(){

    $("ColumnC Div ID").show();

    activate validation here

    });

    the column C div will contain the UI representation for the column and the jscript validation which should be deactivated when choice a selected 

    it can be done by Server Side Event , but it's better to be done in client script



    Hope that helps Amr Fouad MCTS,MCPD sharePoint 2010

    • Proposed as answer by Amr FouadMVP Tuesday, July 31, 2012 12:48 AM
    Thursday, July 26, 2012 8:04 PM
  • Thanks ministainer. Question - What is custom input form? Do i have to use Sharepoint designer for it? Thanks.
    Thursday, July 26, 2012 8:23 PM
  • Hello,

    Yes. you can use SharePoint Designer to create the custom aspx form and do the above requirement.

    In the SharePoint Designed you can see that list will be having 3 forms NewForm.aspx, EditForm.aspx & DispForm.aspx. If you want the requirement to be implemented in both the new form & edit form means do the changes in both the forms. Follow the below steps.

    1. Dont use the existing forms to implement the changes.
    2. Create the new NewForm & EditForm and save it in another name. Now delete the existing forms and rename the newly created ones to the respective names.
    3. Now you can implement the changes whatever you want in the aspx file.

    Thanks.

    Friday, July 27, 2012 4:43 AM