Saturday, 28 June 2014

SharePoint external List data from BDC read using c#

string txt = "Fieldvalue";

                string url = SPContext.Current.Site.Url.ToString();
                SPUserToken token = SPUserToken.SystemAccount;
                using (SPSite osite = new SPSite(url, token))
                {
                    using (SPWeb oweb = osite.OpenWeb())
                    {
                        BdcServiceApplicationProxy proxy = (Microsoft.SharePoint.BusinessData.SharedService.BdcServiceApplicationProxy)SPServiceContext.Current.GetDefaultProxy(typeof(Microsoft.SharePoint.BusinessData.SharedService.BdcServiceApplicationProxy));
                        DatabaseBackedMetadataCatalog catalog = proxy.GetDatabaseBackedMetadataCatalog();
                        IEntity ectResource = catalog.GetEntity(url, Name);
                   
                        foreach (KeyValuePair<string, IMethod> method in ectResource.GetMethods())
                        {
                            IMethodInstance methodInstance = method.Value.GetMethodInstances()[method.Key];
                     
                       
                            if (methodInstance.MethodInstanceType == MethodInstanceType.SpecificFinder)
                            {
                                Identity identity = new Identity(txt);
                                IEntityInstance entInstance = ectResource.FindSpecific(identity, ectResource.GetLobSystem().GetLobSystemInstances()[0].Value);

                                if (entInstance[Const.ITEM_NO].ToString() == txt)
                                {
                                    if (ddlBrandName.Items.Count > 0)
                                    {
                                        ddlBrandName.Items.Clear();
                                    }
                                    ddlBrandName.Items.Add(new ListItem(entInstance[Const.BRAND_DESCRIPTION].ToString()));
                                    txtSameAsDesc.Text = entInstance[Const.ITEM_DESC].ToString();
                                    txtSize.Text = entInstance[Const.PACK_SIZE].ToString();
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }

Thursday, 29 May 2014

Office 365 Get User Photo using jsom error

try with src="/_layouts/15/userphoto.aspx?size=S&url="+imageurlfromuserProfile

Wednesday, 21 May 2014

update multiple people column using spservices
http://spservices.codeplex.com/discussions/277482

Monday, 19 May 2014

Enable debugging in sharepoint 2013 visual studio workflow



http://msdn.microsoft.com/en-us/library/office/jj163199(v=office.15).aspx#bkm_Developing

Monday, 12 May 2014

Display fields from a view in gridview 

while creating grid view column check


 SPView view = curList.Views[Convert.ToString(Property2)];
  SPListItemCollection oitem = curList.GetItems(view);
                        ViewTable = oitem.GetDataTable();
 foreach (DataColumn column in ViewTable.Columns)
                        {
                            if (view.ViewFields.Exists(column.ColumnName))
                            {
                                BoundField Boundcolumn = new BoundField();

                                Boundcolumn.DataField = column.ColumnName;
                                Boundcolumn.HeaderText = column.ColumnName;
                                Boundcolumn.SortExpression = column.Caption;
                                gdv.Columns.Add(Boundcolumn);
                            }
                        }

Sunday, 11 May 2014

Custom people picker control set data


  <span class="formlable">
                    <spuc:PeopleEditor ID="pplAssignedTo" runat="server"  AllowEmpty="true" MultiSelect="false" SelectionSet="User" />
                </span>


   string primaryUser = string.Empty;

                if (pplAssignedTo.ResolvedEntities.Count > 0)
                {
                    PickerEntity pickerEntity = (PickerEntity)pplAssignedTo.ResolvedEntities[0];
                    primaryUser = pickerEntity.Key;
                    SPUser user = SPContext.Current.Web.EnsureUser(primaryUser);
                    oCurrentItem[Const.QA_DOC_REVIEWER] = user.ID;
                }


Friday, 9 May 2014

hide fields in sharepoint forms by name using jquery


$('tr:has(input[title=Disclaimer])').not('tr:has(tr)').hide();
$("nobr:contains('Packaging Number')").closest('tr').hide(); 


disable fields 
  jQuery("SELECT[title*='ClientName']").attr('disabled', true);


http://davidlozzi.com/2014/01/14/sharepoint-2013-script-hide-or-disable-your-fields/