Feeds:
Posts
Comments

Archive for the ‘MOSS’ Category


Recently had a requirement to update the title of the document with the same name as of document irrespective of what user sets, thought to do it via javascript but then given 2013 changed my mind to give it a try with ECMA script, it took an hour(most of it in finding the name of the document:( ) of troubleshooting but got it working ūüôā

Could have done it in lesser steps may be only one query load, but left it in a raw state for others to read through and refine as required ūüėČ

in case someone want to go through some extra steps

UpdateListItemTitle


<script type='text/javascript'>

function getContext()

{

    try

    {

        var context = new SP.ClientContext.get_current(); 

        var list = context.get_web().get_lists().getByTitle('Documents');; 

        var camlQuery = new SP.CamlQuery();

        camlQuery.set_viewXml('');

        this.collListItem = list.getItems(camlQuery);

        context.load(collListItem);

        context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));        

    }

    catch(exception)

    {

        alert(exception);

    }

}

function onQuerySucceeded(sender, args) {

    try

    {

        var listItemInfo = '';

        var listItemEnumerator = collListItem.getEnumerator();

        while (listItemEnumerator.moveNext()) {

            var oListItem = listItemEnumerator.get_current();

            alert("Updating item with ID-->"+oListItem.get_item('ID')+" with Title-->"+oListItem.get_item('Title')+" To new Title -->"+oListItem.get_item('FileLeafRef'));

            //if(oListItem.get_item('Title')==null){}

            updateListItem(oListItem.get_item('ID'), oListItem.get_item('FileLeafRef'));

        }

    }

    catch(ex)

    {alert(ex);}

}

function onQueryFailed(sender, args) {

    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

}

function updateListItem(ItemID, title) {

    var clientContext = new SP.ClientContext.get_current();

    var oList = clientContext.get_web().get_lists().getByTitle('Documents');

    this.oListItem = oList.getItemById(ItemID);

    oListItem.set_item('Title', title);

    oListItem.update();

    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededUpdate), Function.createDelegate(this, this.onQueryFailedUpdate));

}

function onQuerySucceededUpdate() {

    alert('Item updated!');

}

function onQueryFailedUpdate(sender, args) {

    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

}

_spBodyOnLoadFunctionNames.push("getContext");

</script>
Advertisements

Read Full Post »


received¬†a question recently thought would share with all :), Especially for those who haven’t planned upgradation to¬†Project Server¬†2010, be aware that MS Project Server & MS Portfolio Server¬†main stream support end date is 4 /10/2010, though extended support end date is¬†far enough,¬†hence Plan your upgrade¬†accordingly ūüôā

For other MS product life cycle refer to : http://support.microsoft.com/lifecycle/search/default.aspx?sort=PN&alpha=project&Filter=FilterNO

Read Full Post »


While trying to save / open¬†an office 2010 excel workbook¬†to / in¬†sharepoint site, you get an error “Unexpected Error” or “File cannot be saved to this location” , this error is specific to MS office 2010, in office 2010,¬† “Protected View”¬†is a new security feature in Microsoft Office 2010. It removes support for legacy document formats and causes files deemed unsafe to be opened in read-only mode.¬†When installing Office 2010 on the same machine as SharePoint¬†Server 2010, you must disable the protected view to save files to the SharePoint¬†Server and view the Office 2010 documents from the SharePoint¬†2010. Please remember that if you want to enable the readonly¬†view of the Office documents like Word, Excel, PowerPoint, or¬† OneNote¬†on the SharePoint, you may enable similar feature using the Office Web Applications without disabling the protected view

How to Disable Protected View :: Follow the steps

Open Office Application Excel 2010 >> File >> Options >> Trust Centre >> Trust Centre Settings >> Protected View >> uncheck all 3 check boxes under protected view section

Read Full Post »


 

While working with Infopath Forms, i was suppose to move infopath forms from one library to another and then re-link them,
while moving was pretty easy using the library explorer view, re-linking was a pain going through manually marking check box for
each and every form and then re-linking those forms, but there is a solution you might find useful, Follow the steps and you will be relieved of the pain ūüôā

  • GOTO Form Library >> Form Library Settings >> Under Permission and Management >> Relink Documents to this library >>
  • Copy the URL >> Opent this Repair.aspx page in sharepoint designer
  • Change the page view to Split so that code part is visible >> View >> Page >> Split
  • Locate the <FORM> Tag, scroll bottom, usually will find around line 204
  • Just beneath the </FORM> form closing tag paste the code given below, remember to change the double quotes as due to different webpage font it may not be recognized and will result in error,
  • Save the page and refresh the page in browser and scroll to the bottom of the page, you will get a ‚ÄúCheck All ‚Äú button at the bottom
  • click on that and Viola, your all check boxes are marked ‚Ķ‚Ķ. ūüôā

 

<FORM id="SubmitRepairDocsForm" method="POST" action="">
        <INPUT id="SubmitRepairRedirectList" type="hidden" name="SubmitRepairRedirectList" />
        <INPUT id="SubmitRepairRedirectFolder" type="hidden" name="SubmitRepairRedirectFolder" />
        <INPUT id="SubmitRepairDocs" type="hidden" name="SubmitRepairDocs" />
        <SharePoint:FormDigest runat=server ForceRender="true"/>
    <script type="text/javascript" language="javascript">
        function CheckAll(chk)
        {
            for (i = 0; i < chk.length; i++)
            chk[i].checked = true ;
        }
    </script>
    <input type="button" value="Check All" onclick="CheckAll(document.forms.aspnetForm.chkRepair)" >
</FORM>

 

image

image

Read Full Post »


Read Full Post »


——————————————–PROBLEM STATEMENT——————————————————————————-
Actually , I ve created a Discussion Forum on root site and set a default workflow on discussion forum (on Discussion content type). Whenever any domain user added a Topic for discussion a mail shooted to the moss admin and the user.
Requirement is to change the BODY and Subject line of this email with some dynamic parameters.
Actually i ve only Staging server access whr other site and workflows r running on, i cant  much R&D on that because Admin is daily accessing the server.
 
Pls help how to Customize the Subject and Body line of Default Workflow mail notification for Disussion forum(using Sharepoint designer or Visual studio)?? — BY Devendra
——————————————————————————————————————————————————————¬†
SOLUTION :
 
There could be 2 approached either create a custom workflow, or edit notification.xml
editing notification.xml will modify all notification going out for all discussions on a Web App Level, whereas Custom
Workflow Gives you more flexibility and control over what you want to do, hence recommended approach would be creating Workflow
 
Now Workflow creation for sending mails was pretty easy along with dynamic contentsin body line, but if you¬†are a beginner¬†Click Here¬†,¬†Problem comes when you need to have a dynamic subject line,¬† but that can be done using a wrokaround ūüôā
 
For the Subject line unfortunately you could do is add only one dynamic field as Subject, thats a limitation, but a workaround could be have a column in current list with formula concatenating 2-3 different columns, forming your complete subject text in one column, and use that in subject, For eg Р Col 1 = Sunil , Col 2=Singh, Col3 =Col1&" Your Text Here "&Col2, or =CONCATENATE(Col1,"Yourtext",Col2) and use this column in your Subject Line,
 
 For more functions that can be used Click to Here

 

 
 
 

Read Full Post »


Find hereby code which can be used to update MOSS List Items, Specially check for the CAML Query add and modify fields as required,
Note : you would need to provide the intrinsic field name of List Columns, they can be obtained easily using SPUD Alpha MOSS utility refer to the Link SPUD Client Alpha And For building CAML Query refer to U2U CAML Query Builder, Remember to Add List Web Service to your solution
 
 

public void UpdateListItemForCompletedORCanceled(string ProjectName , string ProjectStatus)

{

///////////////////////////////////FIND LIST ITEM USING TO BE UPDATED///////////////////////////

try

{

//this.UpdateStatus("Logging Onto¬†Sharepoint Site………….");

this.WriteLogFile("Logging Onto Sharepoint Site to Update Status for Project :: ");

SharepointLibraryListWebSvc.

Lists ListWebSvc = new SharepointLibraryListWebSvc.Lists();

ListWebSvc.Url =

@"http://ServerName/SiteColl/Site/_vti_bin/Lists.asmx&quot;;

ListWebSvc.Credentials =

CredentialCache.DefaultCredentials;

this.UpdateStatus("Successfully Logged Onto Site………….");

/*Get Name attribute values (GUIDs) for list and view. */

System.Xml.

XmlNode ndListView = ListWebSvc.GetListAndView("Custom Library Name", "");

string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;

string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;

this.UpdateStatus("Retrieving List Item To Update……….");

int ListItemID = this.GetIDForListItemToUpdate(ProjectName, ProjectStatus);

if (ListItemID != 0 )

{

/*Create an XmlDocument object and construct a Batch element and its attributes. Note that an empty ViewName parameter causes the method to use the default view. */

System.Xml.

XmlDocument doc = new System.Xml.XmlDocument();

System.Xml.

XmlElement batchElement = doc.CreateElement("Batch");

switch(ProjectStatus)

{

case "Sustainable":

string CompletionDate = getISOFormattedDateTime();

batchElement.SetAttribute(

"OnError", "Continue");

batchElement.SetAttribute(

"ListVersion", "1");

batchElement.SetAttribute(

"ViewName", strViewID);

batchElement.InnerXml =

"<Method ID= ‘1’ Cmd=’Update’> " +

" <Field Name=’ID’>" + ListItemID + "</Field> " +

" <Field Name=’FileName’>" + ProjectName + "</Field> " +

" <Field Name=’Completion_Date’>" + CompletionDate + "</Field> " +

" <Field Name=’OverallStatus’>" + ProjectStatus + "</Field> " +

" </Method>";

try

{

this.UpdateStatus("Updating List Item For ID…. " + ListItemID);

this.WriteLogFile("Updation Started in List ");

ListWebSvc.UpdateListItems(strListID, batchElement);

//this.UpdateStatus("Updation of \"Sustainable\" Done….");

this.WriteLogFile("Updation Done For List Item ");

}

catch (Exception ex)

{

//MessageBox.Show(ex.Message);

this.WriteLogFile(ex.Message.ToString() + " " + System.DateTime.Now.ToString());

this.UpdateStatus(" List Item Could Not be Update, Error Encountered, Contact Admin…..");

Application.Exit();

}

break;

case "Canceled":

string CancelationDate = getISOFormattedDateTime();

batchElement.SetAttribute(

"OnError", "Continue");

batchElement.SetAttribute(

"ListVersion", "1");

batchElement.SetAttribute(

"ViewName", strViewID);

batchElement.InnerXml =

"<Method ID= ‘1’ Cmd=’Update’> " +

" <Field Name=’ID’>" + ListItemID + "</Field> " +

" <Field Name=’FileName’>" + ProjectName + "</Field> " +

" <Field Name=’Cancellation_Date’>" + CancelationDate + "</Field> " +

" <Field Name=’OverallStatus’>" + ProjectStatus + "</Field> " +

" </Method>";

try

{

this.UpdateStatus("Updating List Item For ID…. " + ListItemID);

this.WriteLogFile("Updation Started in List ");

ListWebSvc.UpdateListItems(strListID, batchElement);

//this.UpdateStatus("Updation of \"Sustainable\" Done….");

this.WriteLogFile("Updation Done For List Item ");

}

catch (Exception ex)

{

//MessageBox.Show(ex.Message);

this.WriteLogFile(ex.Message.ToString() + " " + System.DateTime.Now.ToString());

this.UpdateStatus(" List Item Could Not be Update, Error Encountered, Contact Admin…..");

Application.Exit();

}

break;

}

}

else

{

this.UpdateStatus("Skipped Project ::" + ProjectName + " …… As Status Is Already Set to :: " + ProjectStatus);

this.WriteLogFile("Skipped Project ::" + ProjectName + " As Status Is Already Set to :: " + ProjectStatus);

}

}

catch (System.Web.Services.Protocols.SoapException ex)

{

this.WriteLogFile(ex.Message.ToString() + " " + System.DateTime.Now.ToString());

this.UpdateStatus(" List Item Could Not be Update, Error Encountered, Contact Admin…..");

Application.Exit();

}

////////////////////////////////////////////////////////////////////////////////////////////////

}

/////////////////////////////////////// FIND LIST ITEM ID WHICH NEEDS TO BE UPDATED ////////////////////////////////////////////

public int GetIDForListItemToUpdate(string ProjectName, string ProjectStatus)

{

int ID = 0;

try

{

ListWebSvc.

Lists ListWebSvc = new ListWebSvc.Lists();

//System.Net.NetworkCredential NetCred = CredentialCache.DefaultCredentials;

ListWebSvc.Url =

@"http://ServerName/SiteColl/Site/_vti_bin/Lists.asmx&quot;;

ListWebSvc.Credentials =

CredentialCache.DefaultCredentials;

this.WriteLogFile("Retrieveing List Item ID for Project ::" + ProjectName);

/*Get Name attribute values (GUIDs) for list and view. */

System.Xml.

XmlNode ndListView = ListWebSvc.GetListAndView("JARED Library", "");

string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;

string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;

string rowLimit = "3";

XmlDocument xmlDoc = new XmlDocument();

XmlElement query = xmlDoc.CreateElement("Query");

XmlElement viewFields = xmlDoc.CreateElement("ViewFields");

XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");

string ProjectStatusVal = "";

query.InnerXml =

"<Where><Eq><FieldRef Name=’FileName’/><Value Type=’Text’>" + ProjectName.Trim() + "</Value></Eq></Where>";

queryOptions.InnerXml =

"";

XmlNode nodeListItems = ListWebSvc.GetListItems(strListID, strViewID, query, viewFields, rowLimit, queryOptions, null);

if (nodeListItems.ChildNodes.Count > 0)

{

ID =

Convert.ToInt16(nodeListItems.ChildNodes[1].ChildNodes[1].Attributes["ows_ID"].Value);

ProjectStatusVal = nodeListItems.ChildNodes[1].ChildNodes[1].Attributes[

"ows_OverallStatus"].Value;

this.UpdateStatus("List Item ID Found :: " + ID + " Current Status :: " + ProjectStatusVal);

this.WriteLogFile("List Item ID Found :: " + ID + " Current Status :: " + ProjectStatusVal);

if (ProjectStatusVal == ProjectStatus)

{

return 0; }

}

}

catch (Exception ex)

{

this.WriteLogFile(ex.Message.ToString());

Application.Exit();

}

return ID;

}

//////////////////////////////////////////// DATE TIME ISO FORMATTING ///////////////////////////////////////////////////

public string getISOFormattedDateTime()

{

DateTime CurrentDateTime = new DateTime();

CurrentDateTime = System.

DateTime.Now;

//Generate ISO 8601 date/time formatted string

string FormattedDate = "";

FormattedDate += CurrentDateTime.Year +

"-";

FormattedDate += CurrentDateTime.Month +

"-";

FormattedDate += CurrentDateTime.Day;

FormattedDate +=

"T" + CurrentDateTime.Hour + ":";

FormattedDate += CurrentDateTime.Minute +

":";

FormattedDate += CurrentDateTime.Second +

"-06:00"; //time zone offset (eg "+10:00" – Australian EST)

return FormattedDate;

}

 

 

Read Full Post »

Older Posts »