locked
Sharepoint Calculated Column formula RRS feed

  • Question

  • Hi all,

               This is the scenario. I have few drop downs dropdown1,dropdown2,dropdown3 with choices "agree", "disagree". Even if one of the choice is "disagree", a History column(multiline text) gets populated. and if the user edits the record again , and there is still a "disagree" , the history gets appended to the existing history.

    Now i need a solution for this, I need a count on the number of times a record has failed. that is number of times the history is populated. (not number of times there is a "disagree").

    So, if there is only one set of history the count should be one,if there is two set of history the count should be two.

    I need a calculated column which calculates this count.

    Thanks!

                


    veena

    Tuesday, March 11, 2014 8:28 PM

Answers

  • Hi,

    According to your post, my understanding is that you wanted to count all Versions of “Append Changes to Existing Text”.

    There is no out of the box way to accomplish this with SharePoint.

    However, we can use JavaScript code to achieve it.

    Please follow the step as below:

    1. Open the list, add column: history count(Single line of text).
    2. Download the jquery-1.10.1.min.js and upload it the js folder in the Site Assets.
    3. Edit item, open the EditForm.aspx page.
    4. Edit the page, insert a Content Editor Web Part and add the below code into it.
    <script type="text/javascript" src="../../SiteAssets/js/jquery-1.10.1.min.js"></script> 
    <script type="text/javascript"> 
    _spBodyOnLoadFunctionNames.push("ready"); 
    
    // Make sure the SharePoint script file 'sp.js' is loaded before your 
    // code runs. 
    function ready() 
    { 
            var numItems =$('div[class^="ExternalClass"]').length;
            //alert(numItems);
            var $input = $("input[title='history count']");  
            $input.val(numItems); 
    } 
    </script>
    

         5.  Then the history count will be auto-poplulated.

    Thank you for your understanding.

    Best Regards,

    Linda Li


    Linda Li
    TechNet Community Support

    • Marked as answer by JasonGuo Friday, March 21, 2014 8:31 AM
    Thursday, March 13, 2014 8:01 AM