Sunday, 17 August 2014

Well, I decided Id use this blog to tell my story. Its 17th August, 2014.
In a few days, My mum would have been 81, but she passed away in 2013, whilst I was stuck in the Walton Neurological and Spinal hospital, after my regular check up discovered a bone in my lower spine had collapsed doe to a tumor growing inside it

So, having said that, where to start...

I was born in Kendal in 1963 to Muriel Anne. "Moo" wasn't even 17. Even in the sixties, young , unmarried mothers weren't "approved"  of. My mother was sent to a home to give birth to me.

I was adopted when I was about 9 months old, by Eric and Thelma, who already had a son John. John was , I think, not prepared for a brother

"What? share my toys with that? NO WAY!"

We resolved the problem by playing with (and breaking) my toys, whilst John's remained pristine in their boxes, with a few exceptions (I still bear the scars)

Friday, 11 May 2012

The Whole Thing

Replace "<<" with "<" and ">>" with ">"
then save as a HTML file and load into a sharepoint web part

Change the variales at the topto point to your own sharepoint list

 <<style type="text/css">>
 Button {

  background:#FFFFFF;
  height:50px;
  width:100px;
  background.colour:#AAAAAA;
  margin:0;
  padding:0;
  cursor:pointer;
 
  border-style:hidden;
  border-spacing:0px;
  border-width:0px;
 
  font-size:9px;
  font-family:Verdana;
  font-weight:bold;
  }
  .TxtBlk{
   color:#330000;
   }
  .TxtWht{
   color:#FFFFFF;
   }
  .BtnR{
   color:#FFFFFF;
   }
 <</style>>

 <<script type="text/javascript">>
  // REMEMBER THIS ONLY WORKS WHEN ITS IN A WEB PART PAGE IN A CONTENT EDITOR WEB PART
  var strReplace = null;
   var siteUrl = '/sites/10066';  //Enter your site details here. remember its the site we want, not the "list" folder in the site we want
           // You basically remove the first bit "https://a.b.c
   var strList = 'TestList';  //Enter the name of the list
   var strField = 'Title';   //Enter the name of the field you want to change
   var strTextSet = 'Set';  //Enter the test you want to toggle
   var strTextReset = 'Reset';
  
   function UpdateAllThat(strThisThat)
    {
    strReplace = strThisThat;
    //alert ("Update All " + strReplace + " , " + strList + " , " + siteUrl);
    var context = new SP.ClientContext(siteUrl);
    //var context = new SP.ClientContext.get_current();
    var web = context.get_web();
    var list = web.get_lists().getByTitle(strList);

    var query = SP.CamlQuery.createAllItemsQuery();
    allItems = list.getItems(query);
     var strTemp = "'Include(ID,Title,Department)')";
    context.load(allItems, 'Include(ID,Title,Department)');
    context.executeQueryAsync(Function.createDelegate(this, this.UpdateAllThatSuccess), Function.createDelegate(this, this.failed));

    }
   function UpdateAllThatSuccess()
   {
    //alert ("UpdateAllThatSuccess " + strReplace);
    var ListEnumerator = this.allItems.getEnumerator();
 
    while(ListEnumerator.moveNext())
    {
     var thiscurrentItem = ListEnumerator.get_current();
     var strthiscurrentItemID  = thiscurrentItem.get_item('ID');
     var strthiscurrentItem  = thiscurrentItem.get_item(strField);
     //alert ("strthiscurrentItem = " +  strthiscurrentItem + "," + strthiscurrentItemID  );
     Update(strthiscurrentItemID,strReplace);
    }
    //alert ("UpdateAllThatSuccess");
   }
   function Update(intItemNumber,strReplace)
   {
    //alert ("#1 Update " + strReplace + intItemNumber);
    var Updatecontext = new SP.ClientContext(siteUrl);
    //var Updatecontext = new SP.ClientContext.get_current();
    var Updateweb = Updatecontext.get_web();
    var Updatelist = Updateweb.get_lists().getByTitle(strList);
    var UpdatecurrentItem = Updatelist.getItemById(intItemNumber);
   
    UpdatecurrentItem.set_item(strField,strReplace + intItemNumber);
    UpdatecurrentItem.update();
    Updatecontext.executeQueryAsync(Function.createDelegate(this, this.UpdateSuccess(strReplace + intItemNumber)), Function.createDelegate(this, this.failed));
    //alert ("#2 Update " + strReplace + intItemNumber);
  
   }
   function UpdateSuccess(strString)
   {
    document.getElementById("aQ3").innerHTML = "Update Success - " + strString;
   }  
   function failed(sender, args)
   {
    alert("failed. Message:" + args.get_message());
   }  
   function DisplayButton()
   {
  
    var btnStart = "<<button type='button' ";
    var btnEnd =  "<</button>>";
    var ButtonStyleRed="class=' BtnR'";
   
    var QL1onClick =" onClick=UpdateAllThat(strTextSet)";
    var QL1ToolTip = " title='Set All Items'";
    var QL1btnEnd = ">>Set All<<br>>That<</button>>";
    var QL2onClick =" onClick=UpdateAllThat(strTextReset)";
    var QL2ToolTip = " title='Reset All Items'";
    var QL2btnEnd = ">>Reset All<<br>>This<</button>>";
    document.getElementById("aQ1").innerHTML = btnStart + ButtonStyleRed + QL1ToolTip + QL1onClick + QL1btnEnd;
    document.getElementById("aQ2").innerHTML = btnStart + ButtonStyleRed + QL2ToolTip + QL2onClick + QL2btnEnd;
   
   }
  <</script>>
  <<table>>
   <<tr>>
    <<td id="aQ1">>Q1<</td>>
    <<td id="aQ2">>Q2<</td>>
    <<td id="aQ3">>Click on a button to Set / Reset <</td>>
   <</tr>>
  <</table>>
  <<script type="text/javascript">>
   DisplayButton();
  <</script>>