Archive for September, 2013

Recursive rules in InfoPath–How to prevent

September 24, 2013 Leave a comment


A while ago I had a scenario in an InfoPath form where the user could either enter an amount or a percentage value. This value would then get added to a total already in the form. The requirement is that the user enters either value and the form then calculates the other one.

So if I enter a number then the percentage gets calculated. If I entered the percentage then the number value gets calculated.

So I quickly setup some rules so that when the value changed the percentage or the whole numbers gets calculated and updates the relevant field. This creates a loop of continually updated fields.


I had hoped that some clever InfoPath “stuff” would just make this work and I wouldn’t have to worry about the issue. This didn’t work and caused the form to fail or the fields would not update correctly.


The solution to this problem is that you need a third field to control the updates. Mine is called “Calculating” and is a simple Boolean field.


Now in the rules for Field1 (number) and Field2 (percentage) the first thing to do is to check that calculating = 0 then set calculating = 1 and then set your field. At the end set Calculating back to 0.


This is just a very simple implementation of a lock but it stops the InfoPath rules going crazy.



Pictures explain everything

Categories: work Tags: ,

Programmatically Disable Event Firing on List Item Update in SharePoint 2010

September 19, 2013 Leave a comment


All credit to the original post here


The short version for my future reference is


Create a simple class


public classEventFiring : SPItemEventReceiver
       public void DisableHandleEventFiring()
           this.EventFiringEnabled =false;

       public void EnableHandleEventFiring()
           this.EventFiringEnabled =true;


Then use this to disable events


 using (SPWeb web = site.OpenWeb())
                    SPList list = web.Lists.TryGetList("Custom");
                    SPListItem item = list.GetItemById(34);
                    item["Title"] ="Updated Successfully";
                    EventFiring eventFiring = newEventFiring();
                    Console.WriteLine("Updated Successfully");
Categories: work Tags: ,

Always open Visual Studio 2012 in admin mode

September 13, 2013 Leave a comment


So i have just started again using windows server 2012 and Visual Studio 2012. I had forgotten that you always have to run as an admin or lots of things don’t work. After this i forgot this twice i figured there must be a better solution.


Google to the rescue and all credit to the answer from this stack overflow question. These steps work great.

In Windows 8, you have to right-click devenv.exe and select "Troubleshoot compatibility".

1. select "Troubleshoot program"

2. check "The program requires additional permissions"

3. click "Next", click "Test the program…"

4. wait for the program to launch

5. click "Next"

6. select "Yes, save these settings for this program"

7. click "Close"

Categories: work Tags: ,