Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have to update formula of calculated field. I wrote method for that, it is working fine and is updating formula as well. But it takes really long time to update formula in large library ie library with more than 5000 documents.

    private void changeFormulaForThisField(SPField field, String newFormula)
    {
        if (field.Type == SPFieldType.Calculated)
        {
            SPFieldCalculated calcField = (SPFieldCalculated)field;

            if (calcField.Formula == newFormula)
            {
                writeLogMessage("Column [" + field.Title + "], Old and new formula same");
            }
            else
            {
                calcField.Formula = newFormula;

                if (!TESTMODE)
                {
                    calcField.Update(true);
                }

                writeLogMessage("Column [" + field.Title + "], updating formula...done");
            }
        }
    }

I checked doing same ie updating formula using SharePoint UI. It seems it also depends on number of documents in library. For small library, it is really fast. For large library, it takes also long time in UI, but not so long as using my code.

Am I doing something wrong or inefficient way in my code ? Does updating formula/title for one spfield also needs to update formula/title for each items or what ? Have you experienced such behaviour before ?

Any response would be helpful.

Thanks.

share|improve this question
add comment

1 Answer

Calculated columns in SharePoint are precalculated, the assumption being that they are going to be used a lot more than changed.

So when you change the formula SharePoint has to update the calculated value in each item.

share|improve this answer
1  
ok, then it makes sense for Calculated Columns. But do you have some article that mentions this ? It would be helpful. Also, it takes long time for changing titles using resources (for 2 languages) in large lists ? –  newcoderintown May 31 '12 at 19:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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