Let's Sharepoint
Friday, September 28, 2018
Tuesday, November 1, 2016
sharepoint column color coding based on field values and nowrap for long values
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("td.ms-cellstyle.ms-vb2").filter( function (index) { return $(this).text() == "Assigned to Commander";})
.css("color", "lightpurple").css("font-weight", "bold").css("white-space","nowrap");
$("td.ms-cellstyle.ms-vb2").filter( function (index) {return $(this).text() == "Assigned to Bureau";})
.css("color", "#a2aa0b").css("font-weight", "bold").css("white-space","nowrap");
$("td.ms-cellstyle.ms-vb2").filter( function (index) {return $(this).text() == "Assigned to Investigating Member";})
.css("color", "#85aa0b").css("font-weight", "bold").css("white-space","nowrap");
$("td.ms-cellstyle.ms-vb2").filter( function (index) {return $(this).text() == "Sent for Approval";})
.css("color", "#6baa0b").css("font-weight", "bold").css("white-space","nowrap");
$("td.ms-cellstyle.ms-vb2").filter( function (index) {return $(this).text() == "Approved For System Update";})
.css("color", "#4a8bd6").css("font-weight", "bold").css("white-space","nowrap");
$("td.ms-cellstyle.ms-vb2").filter( function (index) {return $(this).text() == "Approved";})
.css("color", "#226d04").css("font-weight", "bold").css("white-space","nowrap");
$Text = $("td.ms-cellstyle.ms-vb2:contains('Rejected')");
$Text.css("color", "#fc7735");
$Text.css("font-weight", "bold");
Tuesday, June 28, 2016
Web Part That Can Read and Write Data to an External Data Source Using BCS sharepoint 2013
CODE behind:
using System;
using System.Drawing;
using System.Web.UI;
using Microsoft.SharePoint.BusinessData.SharedService;
using Microsoft.BusinessData.MetadataModel;
using Microsoft.BusinessData.Runtime;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint;
using Microsoft.BusinessData.Infrastructure;
using Microsoft.BusinessData.MetadataModel.Collections;
namespace spvwp.CommanderWebPart
{
public partial class CommanderWebPartUserControl : UserControl
{
#region Properties
//protected string EntityNamespace
//{
// get { return ECTNamespace.Text.Trim(); }
//}
//protected string EntityName
//{
// get { return ECTName.Text.Trim(); }
//}
//protected bool EntityValuesAreSet
//{
// get
// {
// if (EntityNamespace == string.Empty ||
// EntityName == string.Empty)
// return false;
// else
// return true;
// }
//}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btncreate_Click(object sender, EventArgs e)
{
try
{
using (new Microsoft.SharePoint.SPServiceContextScope(SPServiceContext.GetContext(SPContext.Current.Site)))
{
// Get the BDC service and metadata catalog.
BdcService service = SPFarm.Local.Services.GetValue<BdcService>();
IMetadataCatalog catalog = service.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current);
// Get the entity by using the specified name and namespace.
IEntity entity = catalog.GetEntity("<entity namespace>", "<entity name>");
ILobSystemInstance LobSystemInstance = entity.GetLobSystem().GetLobSystemInstances()[0].Value;
IView createview = entity.GetCreatorView("Create");
IFieldValueDictionary valueDictionary = createview.GetDefaultValues();
// Set the values of the entity fields.
valueDictionary["CommanderName"] = txtCommanderName.Text;
// Call the creator method and display the returned
// Customer ID.
Identity id = entity.Create(valueDictionary, LobSystemInstance);
CommanderID.Text = id.GetIdentifierValues().GetValue(0).ToString();
StatusLabel.ForeColor = Color.Green;
StatusLabel.Text = "Commander added successfully With ID: " + CommanderID.Text;
}
}
catch (Exception ex)
{
StatusLabel.ForeColor = Color.Red;
StatusLabel.Text = "Unable to create Commander." +
ex.Message;
}
}
}
}
using System;
using System.Drawing;
using System.Web.UI;
using Microsoft.SharePoint.BusinessData.SharedService;
using Microsoft.BusinessData.MetadataModel;
using Microsoft.BusinessData.Runtime;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint;
using Microsoft.BusinessData.Infrastructure;
using Microsoft.BusinessData.MetadataModel.Collections;
namespace spvwp.CommanderWebPart
{
public partial class CommanderWebPartUserControl : UserControl
{
#region Properties
//protected string EntityNamespace
//{
// get { return ECTNamespace.Text.Trim(); }
//}
//protected string EntityName
//{
// get { return ECTName.Text.Trim(); }
//}
//protected bool EntityValuesAreSet
//{
// get
// {
// if (EntityNamespace == string.Empty ||
// EntityName == string.Empty)
// return false;
// else
// return true;
// }
//}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btncreate_Click(object sender, EventArgs e)
{
try
{
using (new Microsoft.SharePoint.SPServiceContextScope(SPServiceContext.GetContext(SPContext.Current.Site)))
{
// Get the BDC service and metadata catalog.
BdcService service = SPFarm.Local.Services.GetValue<BdcService>();
IMetadataCatalog catalog = service.GetDatabaseBackedMetadataCatalog(SPServiceContext.Current);
// Get the entity by using the specified name and namespace.
IEntity entity = catalog.GetEntity("<entity namespace>", "<entity name>");
ILobSystemInstance LobSystemInstance = entity.GetLobSystem().GetLobSystemInstances()[0].Value;
IView createview = entity.GetCreatorView("Create");
IFieldValueDictionary valueDictionary = createview.GetDefaultValues();
// Set the values of the entity fields.
valueDictionary["CommanderName"] = txtCommanderName.Text;
// Call the creator method and display the returned
// Customer ID.
Identity id = entity.Create(valueDictionary, LobSystemInstance);
CommanderID.Text = id.GetIdentifierValues().GetValue(0).ToString();
StatusLabel.ForeColor = Color.Green;
StatusLabel.Text = "Commander added successfully With ID: " + CommanderID.Text;
}
}
catch (Exception ex)
{
StatusLabel.ForeColor = Color.Red;
StatusLabel.Text = "Unable to create Commander." +
ex.Message;
}
}
}
}
Webpart After Deployed to SharePoint 2013:
Friday, March 25, 2016
jquery fileupload validation , allowing only specific file extensions
$("#FileUploadToServer").change(function () {
// var fileExtension = [ 'jpg', 'png', 'pdf'];
// if ($.inArray($(this).val().split('.').pop().toLowerCase(), fileExtension) == -1) {
// alert("Only formats are allowed : " + fileExtension.join(', '));
// $('#FileUploadToServer').val('');
// }
//});
// var fileExtension = [ 'jpg', 'png', 'pdf'];
// if ($.inArray($(this).val().split('.').pop().toLowerCase(), fileExtension) == -1) {
// alert("Only formats are allowed : " + fileExtension.join(', '));
// $('#FileUploadToServer').val('');
// }
//});
Friday, July 31, 2015
get current loggedin user ,hide iput fields fro specific users
<script type="text/javascript">
$(document).ready(function() {
//set text box width...
$('input[title="Name Required Field"]').width('200');
$('input[title="Office/Work Location"]').width('200');
// get current logged in user
var res = $().SPServices.SPGetCurrentUser({
fieldName: "Name",
debug: false
});
var rows = $('table.tg tr');
var tr1 = rows.filter('.tr1');
var tr2 = rows.filter('.tr2');
var tr3 = rows.filter('.tr3');
var tr4 = rows.filter('.tr4');
var tr5 = rows.filter('.tr5');
var tr6 = rows.filter('.tr6');
var tr7 = rows.filter('.tr7');
var tr8 = rows.filter('.tr8');
var tr9 = rows.filter('.tr9');
var tr10 = rows.filter('.tr10');
var tr11 = rows.filter('.tr11');
var tr12 = rows.filter('.tr12');
var tr13 = rows.filter('.tr13');
var tr14 = rows.filter('.tr14');
var tr15 = rows.filter('.tr15');
var tr16 = rows.filter('.tr16');
var tr17 = rows.filter('.tr17');
var tr18 = rows.filter('.tr18');
var tr19 = rows.filter('.tr19');
var tr20 = rows.filter('.tr20');
var tr21 = rows.filter('.tr21');
var tr22 = rows.filter('.tr22');
var tr23 = rows.filter('.tr23');
//alert(res);
var t=res.split('|');
//alert(t[2]);
//........................ members..............//
//jhenderson@****.com
//ajohnson@****.com
//anguyen@**.com(or)idruke@**.com
//krushe@***.com
//tgarrett@***.com
//
//
//hide specific input boxes(in my case its table,so hided <tr> in this code)
if(t[2]=="rkumar@***.com")
{
//alert(t);
//alert("iam the user");
tr1.hide();tr10.hide();tr4.hide();tr2.hide();tr1.hide();tr22.hide();
}
});
</script>
$(document).ready(function() {
//set text box width...
$('input[title="Name Required Field"]').width('200');
$('input[title="Office/Work Location"]').width('200');
// get current logged in user
var res = $().SPServices.SPGetCurrentUser({
fieldName: "Name",
debug: false
});
var rows = $('table.tg tr');
var tr1 = rows.filter('.tr1');
var tr2 = rows.filter('.tr2');
var tr3 = rows.filter('.tr3');
var tr4 = rows.filter('.tr4');
var tr5 = rows.filter('.tr5');
var tr6 = rows.filter('.tr6');
var tr7 = rows.filter('.tr7');
var tr8 = rows.filter('.tr8');
var tr9 = rows.filter('.tr9');
var tr10 = rows.filter('.tr10');
var tr11 = rows.filter('.tr11');
var tr12 = rows.filter('.tr12');
var tr13 = rows.filter('.tr13');
var tr14 = rows.filter('.tr14');
var tr15 = rows.filter('.tr15');
var tr16 = rows.filter('.tr16');
var tr17 = rows.filter('.tr17');
var tr18 = rows.filter('.tr18');
var tr19 = rows.filter('.tr19');
var tr20 = rows.filter('.tr20');
var tr21 = rows.filter('.tr21');
var tr22 = rows.filter('.tr22');
var tr23 = rows.filter('.tr23');
//alert(res);
var t=res.split('|');
//alert(t[2]);
//........................ members..............//
//jhenderson@****.com
//ajohnson@****.com
//anguyen@**.com(or)idruke@**.com
//krushe@***.com
//tgarrett@***.com
//
//
//hide specific input boxes(in my case its table,so hided <tr> in this code)
if(t[2]=="rkumar@***.com")
{
//alert(t);
//alert("iam the user");
tr1.hide();tr10.hide();tr4.hide();tr2.hide();tr1.hide();tr22.hide();
}
});
</script>
Change color of even row in the list for all pages SharePoint 2013
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("tr:even").css("background-color", "green");});
</script>
or try
<style> #MSOZoneCell_WebPartWPQ2 .ms-alternating { background-color: green; } </style>
Monday, July 27, 2015
Subscribe to:
Comments (Atom)




