SharePoint Development
The purpose of this blog is to show techniques involving SharePoint development which is a platform I'm really passionate about. Some of techniques will include InfoPath, Nintex, Flow, REST API, CSOM/JSOM, PowerBI, etc...
Friday, December 20, 2019
Saturday, September 28, 2019
Using JSOM to make the Title column clickable on a SP list
I recently had a request to make the Title column of a SharePoint list clickable. You can simply use JSOM to override the template and render the Title column clickable. Don't forget to use "encodeURI" when returning the function in order to prevent issues with & ampersand in the URL.
(function () {
var overrideContext = {};
overrideContext.Templates = {};
overrideContext.Templates.Fields =
{
'Title': { 'View': overrideTemplate }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext);
})();
function overrideTemplate(ctx) {
var title = ctx.CurrentItem.Title;
var name = ctx.CurrentItem["FileLeafRef"];
var myLink = "https://URL.../" + name;
return "<a id='myAnchor' href=" + encodeURI(myLink) + ">"
+ title + "</a>";
}
Adding multiple accounts to a SP group using MS Flow and REST API
Here are the steps to include multiple accounts into a SharePoint group using Microsoft Flow and REST API.
1 - Create a SharePoint list with the accounts that you would like to include the SP group.
2 - Create a MS Flow workflow with the following steps:
A) Include a "Get Items" step to retrieve all the accounts from the SP list containing the accounts,
method: “POST”,
body: “{ ‘__metadata’: { ‘type’: ‘SP.User’ }, ‘LoginName’:’i:0#.w|domain\\user’ }”,
headers: {
“accept”: “application/json; odata=verbose”,
“content-type”: “application/json; odata=verbose”
},
success: successHandler,
error: errorHandler
});
3 - Run the workflow. When these steps are executed, the system will include the users to the SP group.
1 - Create a SharePoint list with the accounts that you would like to include the SP group.
2 - Create a MS Flow workflow with the following steps:
A) Include a "Get Items" step to retrieve all the accounts from the SP list containing the accounts,
B) Include a "Send an HTTP request to SharePoint". From the Microsoft URL https://msdn.microsoft.com/en-us/library/office/dn531432.aspx we see that the javascript REST call to add a user to a group is the following:
executor.executeAsync({
url: “<app web url>/_api/SP.AppContextSite(@target)/web /sitegroups(7)/users ?@target='<host web url>'”,method: “POST”,
body: “{ ‘__metadata’: { ‘type’: ‘SP.User’ }, ‘LoginName’:’i:0#.w|domain\\user’ }”,
headers: {
“accept”: “application/json; odata=verbose”,
“content-type”: “application/json; odata=verbose”
},
success: successHandler,
error: errorHandler
});
Thursday, November 27, 2014
Wednesday, January 8, 2014
Programmatically add a row to a repeating table using an XmlWriter object
- Add the following code to the Clicked event handler of the button:
C#string myNamespace = NamespaceManager.LookupNamespace("my");
using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1", NamespaceManager).AppendChild())
{writer.WriteStartElement("group2", myNamespace);writer.WriteElementString("field1", myNamespace, "Cell 1");writer.WriteElementString("field2", myNamespace, "Cell 2");writer.WriteElementString("field3", myNamespace, "Cell 3");writer.WriteEndElement();writer.Close();
}
Visual BasicDim myNamespace As String = NamespaceManager.LookupNamespace("my")
Using writer As XmlWriter = MainDataSource.CreateNavigator().SelectSingleNode( _"/my:myFields/my:group1", NamespaceManager).AppendChild()writer.WriteStartElement("group2", myNamespace)writer.WriteElementString("field1", myNamespace, "Cell 1")writer.WriteElementString("field2", myNamespace, "Cell 2")writer.WriteElementString("field3", myNamespace, "Cell 3")writer.WriteEndElement()writer.Close()
End Using - Save, build, and test your work.
Article taken from:
http://www.bizsupportonline.net/infopath2007/programmatically-add-row-repeating-table-xmlwriter.htm
Thursday, August 1, 2013
InfoPath 2010 Paging
Introduction
In this post I will try to show you how to implement a simple paging mechanism using InfoPath 2010. This approach is useful if you are considering a quick & fast solution to handle InfoPath Repeating Tables (or sections) that returns 100s of items without writing code behind and by following few simple steps.
How to do it:
In this scenario I already have an InfoPath Form that has a sample Repeating Table that returns more than 300 items. I would like to configure it to show a 100 item on each page, below are the steps:
1- Add a new field on you Main Data Source as following:
2- Add 2 new buttons on the form to handle Previous & Next Pages:
3- In the InfoPath Repeating Table (or Section) add a new column and inset a new Calculated Value Control from the Controls Ribbon. This Calculated Value will hold the Row Number of the data that you retrieve:
4- Open the newly added Calculated Value Property and update your Data Source using the Position() XPath:
5- Create a Rule for the Previous Page Button on Click as following:
Rule Name: Previous Rule
Condition: PageNumber != 1
Action: Set Fields Value of PageNumber = PageNumber - 1
6- Create a Rule for the Next Page Button on Click as following:
Rule Name: Next Rule
Condition: PageNumber <= Count(ID) / 100
Action: Set Fields Value of PageNumber = PageNumber + 1
Note:
7- Now the Tricky Part ... you need to create 2 new Formatting Rules on the Repeating Table as following:
Rule Name: Hide Rule 1
Condition (Expression): position() >= 100 * xdXDocument:get-DOM()/my:myFields/my:PageNumber
Check on: Hide this Control
Rule Name: Hide Rule 2
Condition (Expression): position() < 100 * (xdXDocument:get-DOM()/my:myFields/my:PageNumber - 1)
Check on: Hide this Control
In this post I will try to show you how to implement a simple paging mechanism using InfoPath 2010. This approach is useful if you are considering a quick & fast solution to handle InfoPath Repeating Tables (or sections) that returns 100s of items without writing code behind and by following few simple steps.
How to do it:
In this scenario I already have an InfoPath Form that has a sample Repeating Table that returns more than 300 items. I would like to configure it to show a 100 item on each page, below are the steps:
1- Add a new field on you Main Data Source as following:
2- Add 2 new buttons on the form to handle Previous & Next Pages:
Rule Name: Previous Rule
Condition: PageNumber != 1
Action: Set Fields Value of PageNumber = PageNumber - 1
6- Create a Rule for the Next Page Button on Click as following:
Rule Name: Next Rule
Condition: PageNumber <= Count(ID) / 100
Action: Set Fields Value of PageNumber = PageNumber + 1
Note:
- Whenever you see the number 100 it represents the page size.
- you can select any fields with the Count() function, in this scenario I used ID field.
7- Now the Tricky Part ... you need to create 2 new Formatting Rules on the Repeating Table as following:
Rule Name: Hide Rule 1
Condition (Expression): position() >= 100 * xdXDocument:get-DOM()/my:myFields/my:PageNumber
Check on: Hide this Control
Rule Name: Hide Rule 2
Condition (Expression): position() < 100 * (xdXDocument:get-DOM()/my:myFields/my:PageNumber - 1)
Check on: Hide this Control
And that all folks ... Run your form and start Paging :)
Article taken from:
http://blogs.technet.com/b/meamcs/archive/2013/03/17/infopath-2010-paging-without-coding.aspx
Tuesday, April 9, 2013
Alternating Color on Repeating Section
You need to apply two conditions for formatting alternating color:
1.Expression :count(preceding-sibling::my:group14) mod 2 = 1 and i set shading as "Yellow"--it has not worked.
2.Expression :count(preceding-sibling::my:group14) mod 2 = 0 and i set shading as "Blue"--it has worked.
when i use any one of those(1 or 2) its not working.
Only the combination(1 and 2) works
http://www.infopathdev.com/forums/p/20430/70754.aspx
1.Expression :count(preceding-sibling::my:group14) mod 2 = 1 and i set shading as "Yellow"--it has not worked.
2.Expression :count(preceding-sibling::my:group14) mod 2 = 0 and i set shading as "Blue"--it has worked.
when i use any one of those(1 or 2) its not working.
Only the combination(1 and 2) works
http://www.infopathdev.com/forums/p/20430/70754.aspx
Subscribe to:
Posts (Atom)