Get values on DispForm

Forums Dynamic Forms for SharePoint Get values on DispForm

Tagged: ,

This topic contains 3 replies, has 3 voices, and was last updated by  Kelly Meegan 1 year, 5 months ago.

  • Author
    Posts
  • #11244

    Kelly Meegan
    Participant

    I wanted to do some custom layout on a form (mostly checkboxes that get assigned different values based on whether they are checked or not) so I used some HTML and jquery to place the checkboxes and assign their values to their corresponding sharepoint columns. Then on the editform I use jquery to pull the value from the sharepoint column and check the checkbox if the sharepoint column value does not equal 0. This works great on the editform, however the it does not work on the dispform. I went ahead and added an alert to the code and noticed that the same alert code shows the correct value in the editform, but returns as ‘undefined’ in the dispform. I also added the fields to the tab on the dispform and they returned the proper values.

    Code being used:

    alert($(“input[title=’RefArch’]”).val());
    alert($(“input[title=’NewTech’]”).val());

    First screenshot shows the working editform, second shows the dispform which does not recognize the value assigned to the sharepoint columns.

    Thanks.

  • #11262

    Julian Knight
    Participant

    I don’t think they will be INPUT tags on the display form. You should refer to them by their ID’s instead.

  • #11280

    Alexander Bautz
    Keymaster

    Hi,
    As Julian mentions above, you will not find any INPUT tags in DispForm. What you have here is the Yes / No values (depending on which language your SharePoint uses), or if you use DFFS the unicode representation of a checked / unchecked checkbox.

    You can use something like this to read the current value form the form:

    var fieldValue = getFieldValue("YourBooleanFieldName), newVal = "";
    if(fieldValue === "No"){
    	newVal = "NO - add your text or HTML code here";
    }else if(fieldValue === "Yes"){
    	newVal = "YES - add your text or HTML code here";
    }
    $("#dffs_YourBooleanFieldName").find("td.ms-formbody").html(newVal);

    Hope this gets you a bit further.

    Alexander

  • #11291

    Kelly Meegan
    Participant

    Thanks guys,

    got it working as expected with:

    
    
    if(getFieldValue("RefArch") != "0") {
      $('#refarch').prop('checked', true);} 

You must be logged in to reply to this topic.