Edit Add New Item link in certain view of list in SharePoint Programmtically
this is my requirements
i have one list called List 1 and two content types on it
CT 1 and
CT 2 and create two views on the list
View 1 to display items of CT 1
View 2 to display items of CT 2
the creation of list and views is done via XML
now i need to change the URL of add new item link in every view to open its content type, i.e. when i was on view 1 i click on add new item, it will open new item form of CT 1 and hen i was on view 2 and click on add new item, it will open new item form
of CT 2
i do a lot of search on the internet but get the following code but it doesn't work for me, i already wrote it in event receiver
SPSecurity.RunWithElevatedPrivileges(delegate()
SPWeb web = properties.Feature.Parent as SPWeb;
web.AllowUnsafeUpdates = true;
SPList contractList = web.Lists.TryGetList("Contract");
SPLimitedWebPartManager webpartManager = web.GetLimitedWebPartManager("Lists/ContractList/SICET%202A%20Contract.aspx", PersonalizationScope.Shared);
foreach (System.Web.UI.WebControls.WebParts.WebPart item in webpartManager.WebParts)
if (item.GetType().Name == "XsltListViewWebPart")
XsltListViewWebPart listViewWebPart = (XsltListViewWebPart)item;
Guid guid = new Guid(listViewWebPart.ViewGuid); // get the view details which is applied to web part
SPView sicet2AView = contractList.Views[guid];
sicet2AView.GetType().InvokeMember("EnsureFullBlownXmlDocument",
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod,
null,sicet2AView,null);
PropertyInfo nodeProp = sicet2AView.GetType().GetProperty("Node", BindingFlags.NonPublic | BindingFlags.Instance);
XmlNode node = nodeProp.GetValue(sicet2AView, null) as XmlNode;
XmlNode toolbarNode = node.SelectSingleNode("Toolbar");
//sicet2AView.ViewFields.DeleteAll();
if (toolbarNode != null)
string toolbarType = toolbarNode.Attributes["Type"].Value;
string linkText = "abdeen";
toolbarNode.Attributes["Type"].Value = "Freeform";
XmlAttribute positionNode = toolbarNode.OwnerDocument.CreateAttribute("Position");
positionNode.Value = "After";
toolbarNode.Attributes.Append(positionNode);
//toolbarNode.InnerXml = @"<IfHasRights><RightsChoices><RightsGroup PermAddListItems=""required"" /></RightsChoices><Then><HTML><![CDATA[ <table width=100% cellpadding=0 cellspacing=0 border=0 > <tr> <td colspan=""2"" class=""ms-partline""><IMG src=""/_layouts/images/blank.gif"" width=1 height=1 alt=""""></td> </tr> <tr> <td class=""ms-addnew"" style=""padding-bottom: 3px""> <img src=""/_layouts/images/rect.gif"" alt=""""> <a class=""ms-addnew"" ID=""idAddNewItem"" href=""www.facebook.com""]]></HTML><URL Cmd=""New"" /><HTML><![CDATA["" ONCLICK=""javascript:NewItem(']]></HTML><URL Cmd=""New"" /><HTML><![CDATA[', true);javascript:return false;"" target=""_self"">]]></HTML><HTML>" + linkText + @"</HTML><HTML><![CDATA[</a> </td> </tr> <tr><td><IMG src=""/_layouts/images/blank.gif"" width=1 height=5 alt=""""></td></tr> </table>]]></HTML></Then></IfHasRights>";
toolbarNode.InnerXml = @"<IfHasRights><RightsChoices><RightsGroup PermAddListItems=""required"" /></RightsChoices><Then><HTML><a class=""ms-addnew"" ID=""idAddNewItem"" href=""www.facebook.com"">Test</a></HTML></Then></IfHasRights>";
sicet2AView.Update();
//listViewWebPart.ViewGuid = sicet2AView.ID.ToString("B").ToUpper();
//listViewWebPart.Visible = true;
webpartManager.SaveChanges(listViewWebPart);
web.Update();
but it doesn't work, my first trail is changing the text of the link then go to change the link any help plz
Mohamed Abdeen
Hi,
The “Add new item” button will redirect users to add new item with the default Content Type of the current list.
So a workaround can be like this: We can change the default Content Type of this list every time when users open this list view page, then the “Add new item” button will work
as you expected.
Here is a link with code demo about how to programmatically set a content type as default content type in a SharePoint 2013 List:
http://www.ashokraja.me/tips/How-to-programmatically-set-a-content-type-as-default-content-type-in-a-SharePoint-2013-List
We can put the code into a Visual Web Part and add it into your two views, then when users open a list view page, the code will be executed to change the default Content Type
of the current list.
To develop a custom web part, you can take a look at the links below with steps in detail for a start:
Creating Web Parts for SharePoint
http://msdn.microsoft.com/en-us/library/ee231579.aspx
SharePoint 2013 Create a Visual Web Part
http://raquelalineblog.wordpress.com/2013/04/25/sharepoint-2013-create-a-visual-web-part/
Thanks
Patrick Liang
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Patrick Liang
TechNet Community Support
Similar Messages
-
Add new items to the top of a list in iWeb
One of my sites is for a cat charity :
www.catsprotectionshop.com
When a new cat is added it is easiest to add it to the bottom of the page. The alternative would be to move all the others down to put it at the top.
Is there an easy way to move the existing items down, please?Here's the page in iweb :
And this is thepage on the web :
http://wyodor.byethost8.com/cats/Adoption/Adoption.html -
I have a list which has a underlying infopath form for insert and edit a record.
The list has various views spread across different pages .
Now depending on different pages "New Item", a value for the form will have a corresponding value.
If there is a single line of text control in the list, and depending ona page name, the value for the single line text should be autofilled when Add new item is clicked.
How do i achieve that?
Thanks...Hi,
According to your description, there are several list views in your list, there is a textbox control which holds the “Single Line of Text” type of data in your custom
form. When users click the “Add new item” button in one of the existing list views, you want the textbox control in the custom form to be populated automatically.
By default, when user clicks the “Add new item” button in a list view, the URL of the custom form page will contain the name of that list view page, thus, a workaround
which requires custom code can be like this:
After the form page loaded, we can extract the name of the list view page from the URL, then populate it into the textbox control immediately. This can be achieved
using jQuery.
About how to
get URL parameters of current page using jQuery:
http://www.jquerybyexample.net/2012/06/get-url-parameters-using-jquery.html
About
adding jQuery into InfoPath form:
http://riteshudupak.blogspot.com/2010/09/add-jquery-to-browser-enabled-infopath.html
Best regards,
Patrick
Patrick Liang
TechNet Community Support -
Why "New Item" in ribbon and "Add new item" in xsllistview link to different form
Hi all,
I have a question. I have a list with two new forms, one is created in SPD the other one is created in InfoPath (both forms are created by developer).
I don't know why the new form link to different page when I click "New Item" in ribbon and "Add new item" in list view.
1. Will open new form that created in InfoPath when click on "New Item" in ribbon.
2. Will open new form that created in SPD when click on "Add new item" in list view.One way to do this would be to hold the urls for the pages you need to display in a table. You could then build the links as one of the columns of a report using some fancy SQL.<br>
<br>
Or you could make a simple function to return the correct link based on the relevant parameters:<br>
<br>
create or replace function get_url (p_criteria in varchar2) return varchar2<br>
is<br>
lv_url varchar2(500);<br>
begin<br>
if p_criteria = 'Personal' then<br>
lv_url := 'http://host:port/pls/portal/etc...';<br>
end if;<br>
etc...<br>
return '<a href="' || lv_url || '">' || p_criteria || '</a>';<br>
end;<br>
<br>
Your report could then include the function as one of the columns in your report.<br>
Not very elegant but it should do the job.
Patrick. -
How to add a new url link in a view of an existing webdynpro component?
How to add a new url link in a view of an existing webdynpro component?
hi ,
refer SAP online hep :
Implementing Enhancements in a View
http://help.sap.com/erp2005_ehp_04/helpdata/EN/46/233f2189f74f08e10000000a114a6b/frameset.htm
To enhance the layout of the view, you can create new UI elements. This procedure is no different u2013 from a technical viewpoint u2013 from creating UI elements in components themselves. All UI elements created within the enhancement implementation can then be processed as usual.
Enhancements means inserting user developments into SAP development objects at predefined positions.
The Enhancement Framework enables you to add functionality to standard SAP software without actually changing the original repository objects, and to organize these enhancements as effectively as possible.
refernce :
have a look at this article
How to Create Enhancement Implementation in Web Dynpro ABAP
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/700317da-bd79-2c10-368e-8f18bf5d8b81&overridelayout=true
as pointed correctly by Saurav in earlier thread
regards,
amit -
Changing the default "New Item" link url in SharePoint
Is it possible to change the default url of the New Item button on a list.
When i hover over or click on new item link it show the ......../15/listform.aspx?Page type=blah.....blah......
I want it to be something like :/newform?source=xxxx
Please help me !
Thank you !Hi,
The following code for your reference, please add the code into a Content Editor Web Part in the list view page.
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript">
$(function () {
$("#idHomePageNewItem").attr("href", "http://site/list/newform.aspx?source=http://...........");
$("#idHomePageNewItem").attr("onclick", "");
</script>
Best Regards
Dennis Guo
TechNet Community Support -
Crystal Report not listed Add New Item for Visual Studio 2010
I just finished installing cryestal report for visual studio 2010.
During the installation a visual studio error dialog popped up "Operation cannot be completed. Access Denied", the crystal report installation continued and was informed that the installation was successful.
But on opening my visual studio project to add new item, crystal report item is not listed there.
Is there anything that needs to be done to get it listed in the Add New Item dialog for visual studio?I wonder what file you ran to install CRVS2010? Was it the MSI as opposed to the actual install file?
The link to the correct install is here:
http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_13_0_2.exe
Is that the file you ran to install CRVS2010? E.g. as opposed to:
http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_redist_install_32bit_13_0_2.zip
- Ludek -
How to change the url of "Add New Item" of a particular list in SharePoint 2013???
Hi Guys,
How to change the url of "Add New Item" of a particular list in SharePoint 2013???
I need to redirect it into the page where I have created my Visual web part.
Please suggest
Warm Regards,
Tony JoyHi,
There are multiple ways to change the form url like javascript, SharePoint designer, custom code, editing default form to have custom web part etc, Please follow the url below that describe diffent methods and steps
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/ec2769a0-683c-4023-8804-b596e4f92a3a/change-default-forms-on-custom-list?forum=sharepointcustomizationlegacy
Hope it helps!!!
Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. Thanks, Ajeet -
Cannot add new items to a value list in AW database
I have a database which I have been using for many years. One of the fields is a value list. I just went to add another item to the list, and no matter what I do, the Create button is grayed out. I have another value list in the same database that works fine.
There are currently 170 items in the value list that is causin the problem, but I didn't think that there was a limit to the number of items that can be is a value list. (At least there is nothing in the AW technical specifications to indicate thin. I duplicated the existing database, deleted about 20 items from the list, then saved the file, and reopened it, and still cannot add new items to that value list. Does anyone know what might be causing the problem?Oops
I read too fast.
Here is a short script which may help.
Replace the pop-up item by a text one and edit the property myList in my script to fit your needs.
Select the field to fill and run the script.
Then choose an item in the displaid list. It will be pasted in the selected field.
This trick would give you to work with a "no limit" list of items.
-- [SCRIPT DB fillFieldFromAlist ]
Assuming that
the front document is a database one
and that a text field is selected,
run the script to select an item in a list
and paste it in the field.
Yvan KOENIG, Vallauris (FRANCE)
le 19 mars 2007
property MyList : {"item 1", ¬
"item 2", ¬
"item 3", ¬
"item 4", ¬
"item 5", ¬
"item 6", ¬
"item 7", ¬
"item 8", ¬
(* edit the list to fit your needs *)
tell application "AppleWorks 6"
activate
tell document 1
set laClasse to (get class of selection)
if laClasse is not field then return (* the selection is not a field *)
set myItem to choose from list MyList
if myItem is false then return
set the clipboard to myItem's item 1
select menu item 7 of menu 3 (*
Tout sélectionner •• Select All *)
paste
end tell -- document 1
end tell -- AppleWorks
-- [/SCRIPT]
Yvan KOENIG (from FRANCE lundi 19 mars 2007 16:44:53) -
User exit in sales order to add new item condition
Hi,
Our business requirement is to add new item conditions in an order (VA01/VA02) using ABAP coding. Has anyone done this before?
I'm thinking of using USEREXIT_NEW_PRICING_VBAP in MV45AFZB ?
Thanks.
Edited by: William Lawlor on Jul 8, 2008 12:19 PMHi,
This exit USEREXIT_NEW_PRICING_VBAP in MV45AFZB is used only to determine or not a new price calculation according to a modification of specific field (ex : if shipping condition is changed, then new price determination).
To add new condition type, you can used requirement in pricing procedure (V/08) with condition formula.
What is the condition to add this new condition type ?
Regards,
Lionel -
Sharepoint 2010 - Cannot make field Required in Add New Item form.
I made a fleld Required by making the proper selection in List Settings > Editing the column. It now shows as required when I edit an existing record in the list, but is not required when adding a new item. Why does the setting not apply
to the Add New Item form? How can I make it apply/required?
btw, there are no content types associated with the list.Hi ,
According to your description, my understanding is that you cannot make field required in the list new form.
For my test, I created a custom list , added a non-required field and added some records. Then I made the field required. But it worked fine as expected both in existing records and in Add New Item
form.
Do you have some customization in your list new form?
You can go to your list -> Customize Form under list tab, then the new form will be opened in the InfoPath. In the InfoPath, right click the field and select Text Box Properties, make sure “Cannot
be blank” has been checked.
Best Regards,
Eric
Eric Tao
TechNet Community Support -
Add New Item in WM Cycle Count - LI11N
Can someone tell me the purpose of the new item button in transaction LI11N. I thought it would be for adding items NOT on the invenory document while entering count results, but that does not appear to be the case. When I select the new item button to add new items, I receive error "XXX storage bin does not belong to inventgory number." However if I add an item that already exists on the inventory docuemnt it allows the addition. That doesn't make sense to me because that's not an addition, its' really just a funciton of adding the counts for an existing item. Perhaps I'm missing something in my configuration or settings for WM or my materials and that's why this does not allow additions of items NOT on the document.
Thanks in advance for your response
Kathleen Phillips
Edited by: Kathleen Phillips on Jul 17, 2009 7:23 PMThank you for your response Sarita,
Just before I received your message I found some documentation that explained further the use of the "add item" button. You are correct, the add item button is only for entering counts for bins already listed on the inventory document, but it allows the addition of different materials for that bin - in the event that the bin is a "mixed" bin.
Thank you!
Kathleen Phillips -
Hello,
I am using Internet Explorer 9 to create a new item by launching Performance Point Dashboard Designer from browser.
When i click on "Add new item", an Iframe will open showing dashboard design redirect which keep loading for couple of minutes and the designer never opens.
Yes, there are working workarounds like opening these links in other tab or opening dashboard designer directly or by clicking on "Run Dashboard Designer" from BI Center homepage.
However, Can someone please help me how to get designer opened when "Add new item" has been clicked from PerformancePoint Content List from browser?
Thanks in advance.
NKV Prasad PanthangiAn Update :
I found this is due to the browser limitation.
I have downgraded my Internet Explorer Browser to IE 8 and did the following changes in my browser settings.
Tools --> Internet Options --> Navigate to Security Tab --> Click on Custom Level Button --> Under Download --> Select "Enable" radio box for Automatic Prompting for File Downloads.
Sadly, I cannot ask users to downgrade their browser to IE 8 because MS already stopped support for this browser and there are no other solution for this except going by workarounds.
This clearly says why people are moving away from PerformancePoint Services in SharePoint.
Thanks
NKV Prasad Panthangi -
Add new item to OPC server in LabView
Hi. I want to connect my PLC Unitronics Jazz to LabView using OPC Server. It have OPC Server called UniOPC Server. I don't know how to add an Item in LabView.
UniOPC don't have option to add new Item - I have to do this by opc client. In OPC QuickClient I can see UniOPC server, and there I can add Item and change values of variables (for example I can change value of MB0 - Memory Bit 0) but in LabView when I try to use this in VI project I have error: "Error 0x0000002A connecting to .../plc.MB0".
I would like to try to add new Item without QuickClient - in LabView and see if that works. Can someone help me, please?Hi there,
According to the following link, you might not be able to connect your PLC to LabVIEW:
http://www.ni.com/white-paper/6417/en
In general, if you would like to establish a connection between LabVIEW and a PLC, here is a step-by-step guide:
http://www.ni.com/white-paper/7450/en
Regards,
Norbert -
Add new document link not working in upgraded sharepoint 2013?
Hello there,
Upgraded SharePoint team sites from 2010 to 2013. add new document link not working for shared document in upgraded sharepoint 2013?. it is specially not working on machine where Office web apps set up with this sharePoint server and it
is working fine with environment Office web apps not configured with Sharepoint.
Looking resoluion /suggestion, thanks in advance.
Regards,
SushilHi Sushil,
According to your description, my understanding is that the add new document link was not working on machine where Office web apps set up with this SharePoint server after you upgraded SharePoint team sites
from 2010 to 2013.
For your issue, it can be caused by integrating Office Web Apps with upgraded SharePoint Site.
Firstly please make sure claims-based authentication is used by the SharePoint web application that is used to create the new document. Only web applications that use claims-based authentication can open
files in Office Web Apps. To determine the authentication provider for a web application, follow these steps:
1.In SharePoint 2013 Central Administration, click Manage web applications.
2.Select the web application that you want to check, and click Authentication Providers on the ribbon.
The authentication provider must be displayed as Claims Based Authentication for Office Web Apps to work correctly with the web application. To resolve this issue, you can delete the web application and recreate
it using claims-based authentication, or you can change the authentication method of the web application.
Secondly, make sure the WOPI zones match on the SharePoint 2013 and the Office Web Apps Server farm.
To do this, run the following command on the SharePoint Server:
Get-SPWopiZone
The result will be one of the following:.
internal-https
internal-http
external-https
external-http
Next, run the following command on the SharePoint Server.
Get-SPWOPIBinding
In the output, look for WopiZone: zone. If the results from Get-SPWopiZone don’t match the zone that is returned by Get-SPWOPIBinding, run the Set-SPWOPIZone -Zone cmdlet on the SharePoint Server to change
the WOPI zone to match the result from Get-SPWOPIBinding.
If not work, you can try to disconnect SharePoint 2013 from Office Web Apps Server and re-configure Office Web Apps for SharePoint 2013.
For more information, please refer to the article:
http://technet.microsoft.com/en-us/library/ff431687(v=office.15).aspx
Best Regards,
Eric
Eric Tao
TechNet Community Support
Maybe you are looking for
-
Error when trying to extend network from airport express to airport express
I have an airport express in my house. I am trying to connect another airport express to extend the network. I am following the instructions but keep getting an error when it is resetting itself. I have done a hard reset on the airport express so it
-
Firefox 3.6.3 closes the first window when I close the 2nd window
Firefox 3.6.3 seems so buggy. When I have 2 windows open and I close the 2nd one, the first one also closes. When I open a new window, it sometimes shows up minimized in the top left corner. == This happened == Every time Firefox opened == I started
-
Studio Creator and Swing applications
Is there any plan that Studio Creator will have ICS BX like simple swing/GUI creation features for the client/server development? Client/server is not dead and lots of us out there are still looking for easy Java client/server develokpment tools. Tha
-
HT4098 Apple TV radio auto-scrolls through stations
When I play a radio station on my apple tv (drone zone for instance), after a few minutes Radio will automatically switch to the next station (Elium) without being prompted. I can't find any selection in settings where I can turn off this function, i
-
Still have sell Iphone 5 at online store?
Still have sell Iphone 5 at online store?