Uncheck Send an Email Invitation in SharePoint Grant Permissions Dialog

In SharePoint 2013, when you want to grant permissions, this dialog opens, with the secret “Send an email invitation” checkbox hidden in the Options section.

Share Dialog

Most of the time, I would uncheck that before sharing, to avoid email spams.

One of our clients wanted it unchecked by default, so that users don’t have to always remember to manually uncheck it to prevent spams, if they even knew it existed there in the first place.

You could easily default it to uncheck by updating the OOTB layouts page in the 15 hive at TEMPLATE\LAYOUTS\AclInv.aspx, and updating the chkSendEmailv15 asp:CheckBox control and setting Checked=”false”.

But we don’t want to do that! Updating OOTB components is not recommended and we like to stick to Microsoft best practices.

So we’ll do it the fancy pants way of using JavaScript embedded as a Script Link in a Site Collection User Custom Action.

Continue reading

Advertisements

Handy CAML Query Snippets

Getting Checked out Files

<Where>
  <IsNotNull>
    <FieldRef Name='CheckoutUser' />
  </IsNotNull>
</Where>

or

<Where>
  <Eq>
    <FieldRef Name='_Level' />
    <Value Type='Integer'>255</Value>
  </Eq>
</Where>

Getting Published Files

<Where>
  <Eq>
    <FieldRef Name='_Level' />
    <Value Type='Integer'>1</Value>
  </Eq>
</Where>

Getting Checked-in Files

<Where>
  <Eq>
    <FieldRef Name='_Level' />
    <Value Type='Integer'>2</Value>
  </Eq>
</Where>

Getting Files Only (i.e. excluding Folders)

<Where>
  <Eq>
    <FieldRef Name='FSObjType' />
    <Value Type='Integer'>0</Value>
  </Eq>
</Where>

Getting Folders Only (including Document Sets)

<Where>
  <Eq>
    <FieldRef Name='FSObjType' />
    <Value Type='Integer'>1</Value>
  </Eq>
</Where>

Comparing URLs

<Where>
  <Eq>
    <FieldRef Name='WorkflowLink' />
    <Value Type='URL'>/subsite/listname/item-url.docx</Value>
  </Eq>
</Where>

Note that you must use a server relative URL when querying against a URL field.

Querying Content Type ID

<Where>
  <Eq>
    <FieldRef Name='ContentTypeId' />
    <Value Type='ContentTypeId'>0x0120D52000058D5968BC2445489FC509B9E038862900A88F92769A306640872EDF8D34E64427</Value>
  </Eq>
</Where>

Disabling Select Drop Down List using jQuery without ‘disabled’

Say you have a drop down list defined as a select tag:

<select id="dropdown">
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3" selected>Three</option>
</select>

You can very easily disable the drop down list with jQuery by adding a disabled property to the tag.

$('#dropdown').attr('disabled', 'disabled')

However, in doing that, the selected value of the drop down list is no longer posted back on a form submit. And some systems (such as SharePoint) may then persist the default value when saving changes, which in the example above is “1” instead of the selected “3”.

So instead of a straight forward disable, we’re forced to do some extra work to make sure the control remains disabled on the front end to the user, but still posts back the corrected selected value to the back end.

The JavaScript below achieves this:

Continue reading