Add “toolpaneview=2” behind the URL in this format:
…NewForm.aspx?toolpaneview=2
…EditForm.aspx?ID=12&toolpaneview=2
This sets the page in edit-mode and you can add webparts as if it was any other page.
Have you broken your page by adding a faulty script?
Add “?contents=1” behind the URL and you can delete any webpart from your page.
In the list view – right click and view source. Then search for “ctx.Listname”.
The Guid looks like this:
{DEF643C7-CF80-4DF8-866F-C16DC017DFC0}.
The view Guid is found by searching for “ctx.view” and looks similar to the list Guid above.
Open NewForm, EditForm or DispForm. Right click and view source. Then search for your field’s DisplayName and you will find the fields FieldInternalName like this:
<!-- FieldName="This is the DisplayName" FieldInternalName="ThisIsTheFieldInternalName" FieldType="SPFieldText" -->
The fields InternamName never changes and is therefore the safest method of identifying a field.
Go to any page in the web, right click and view source. Search for the variable “L_Menu_BaseUrl”. The variables value is the “BaseUrl”. In SP 2013 you might not find this variable. Look for “_spPageContextInfo” and “webServerRelativeUrl”.
How to troubleshoot when the scripts does not work
Hi, Alexander.
Very helpfull posts:)
I have a problem with adding CEWP. After this manipulation site action button appers for users, that have not access, with “change page” action. And they can add custom web parts on page (DispForm.aspx for example).
Are there any ways to avoid this?
Hi,
To remove the “Edit page” option for NewForm. DispForm and EditForm, just include this line in the code (requires jQuery):
Alexander
Hi!
I added the code above to code in the CWEP but the edit toolbar is still appearing. Using the line-$(“*[id$=’_MenuItem_EditPage’]”).remove();
How should I be posting this line of code (what additional information should I put around the line)? Should I paste this line in the CEWP, in the spjs-utility.js file, or in a new file?
Thank you!
Hi,
You must wrap this in a script tag like this:
Alexander
The site gets stalled in a stage where it says the script are getting loaded.
Please help
Though it’s a bit difficult to anaylse from here, if you have made changes to the page/a script and your browser stalls after reloading the page, try Firefox if possible. Firefox will notice a faulty script (or one that uses far too many resources) and will prompt you to stop it. After stopping the script execution you can correct the code.
Chris
I can never seem to find the list guid code as shown above..what could be the underlying reason for this?
Great write-up. It’s working for me except I have it linking to a view that is filtering getting the next 10 items when date >= [Today]. The view looks correct but when I link it to the scrolling webpart it isn’t filtered. I’ve double checked the view id and it is correct.
Please Disregard, I’ve figured it out.
This looks fantastic. Only concern i have is it seems that for adding this JS on NewForm.aspx of list, you will need to manually modify the url (ToolPaneView=2) and add this JS in CEWP. But my problem is i have 40+ lists.
is there any way in which this can be automated ( i don’t want to create a feature for list provisioning)??
Hi Alexander,
It works perfectly with EditForm, but for some reason I can’t fix NewForm. Here my url, if your able to help:
https://telenordenmark.col.wow.telenor.com/sites/hrsharepoint/hrprojects/performancemanagement/Lists/Talent%20List%202012/NewForm.aspx?RootFolder=%2Fsites%2Fhrsharepoint%2Fhrprojects%2Fperformancemanagement%2FLists%2FTalent%20List%202012&Source=https%3A%2F%2Ftelenordenmark%2Ecol%2Ewow%2Etelenor%2Ecom%2Fsites%2Fhrsharepoint%2Fhrprojects%2Fperformancemanagement%2FLists%2FTalent%2520List%25202012%2FValidering%2520til%2520360%2Easpx
Your scripts have really enlightened me to near OOTB possibilities – I would like to offer a fix to the spjs utility script – using setfieldvalue with the SPFieldLookup_Input option you check to see if the newval is an integer then assume it is an ID – in my case the associated value was a string with a number that could be resolved to an int – I examined lookup fields using ID and other column types and the internal lookup was the same – so i just commented out the test for ID –
Again i’ll be buying a beer or six-pacj soon
thanks
Jack Schaufele
very useful post !
i have 3 queries regarding share point
1) i want to redirect two buttons to two different locations in newForm.aspx(save and cancel)
2)can i create chat application inside share point ?(no third party solutions )
3)can redesign share point form using java script or jquery ?
thanx in advance 🙂
Hi,
You should find answer to Q1 and Q3 by reading trough the articles in this blog, start by going to the Archives
I have no solution for Q2, but you can find that elsewhere – like here.
Alexander
I am attempting to use your get and set field Javascript functions in a SP2010 newform page for a list but I keep getting undefined. I have been using your method to get the field internal name. I am looking for the Title field. When I search the source for it I find an input item but I am not seeing the internal name. I have tried using the “name” and the “id” fields as well as the internal name for the field “Title” as the field internal name in the script but these all return undefined. Can you help identify what I am doing wrong?
Here is the input field:
This is the javascript function:
function createAnnouncementsItem() {
window.alert(‘Look’)
fields = init_fields_v2();
// Get Values
var NewTitle = getFieldValue(‘Title’,false);
// Test Values
window.alert(NewTitle);
}
It seems it striped the input tag out so here are the values of it: input name=”ctl00$m$g_b001e91e_e6a1_49e5_add8_46d243f4a2fa$ff21$ctl00$ctl00$TextField” type=”text” maxlength=”255″ id=”ctl00_m_g_b001e91e_e6a1_49e5_add8_46d243f4a2fa_ff21_ctl00_ctl00_TextField” title=”Title” class=”ms-long ms-spellcheck-true”
Well, after looking at your posts in more detail I finally figured out what I was doing wrong. I was making some other changes using SPD and that was causing a disconnect.
Thank you for this information. It has been quite helpful.
Hi Alexandar,
Thanks for your tips, i have a small fix to do, in the SP 2010 Survey Overview.aspx page, i need to insert a CEWP on the right column , but there is only one column in the default page layout and it can not be changed too.. Can you help in that..
Thanks in advance
Sahil
Hi,
Add this code to a HTML Form Web Part below the default overview web part. You must change the number “3” in this string “#MSOZoneCell_WebPartWPQ3” to match your web part index in the page. Either use developer toolbar (hit f12) to find the number, or count the extra web parts you have added to the page – the original web part is “1”.
Have a nice Christmas,
Alexander
Hi Alexander,
Is there a way to hide the Approval Status field on the display form (DispForm.aspx) for lists that require content approval?
Thanks,
Steve
Sorry – I missed this comment. Use the developer console in IE to identify the ID or title of the field and use jQuery to hide the row.
Alexander
Hi Alexandar,
Thanks for your tips,i have a question,that i need to update someone list all items data by my app,but i do not know fields validation rules in that list..Can you help in that..
Sorry, I don’t think I can help you with this.
Alexander
Hi Alexandar,
Thanks you for your answer,this is a troublesome problem..And i have a another question,there are two same list at the same site,then the two list data to complete synchronization,now i can achieve data synchronization update and increased by SPD 2013,but cannot be deleted,so when the menu(delete item) clicked,how to catch the delete action? Or any other way to get deleted data?
Please help..
Hi,
To get this done in a reliable way you should use an event handler. This is not something I can do in JavaScript, sorry.
Alexander
Thanks for that Alex, all sorted, excuse my stupidity.
Is there anyway to include two queries in the title field? Where I can seperate it…for example
my suggested title field could be:
Title / Additional Title
Would be handy if I could put two column queries together in the preview, for example I could link two cells showing First name and Surname (obviously I wouldnt seperate the data this way so its merely an example)
Not sure which solution you are referring to. Please post in the article your question addresses.
Alexander
Thanks for giving me this resource Alexander. Maybe you can guide me to how to complete my task. When looking at the view source of the disp form of a custom list. I see an a href that has a url for the Look-up Field as follows:
Agreement Parent
Jil09034%
I am trying to save this url to a cookie, but have been unsuccessful. Do you know of a way to point to or grab the url of a Lookup field?
If the “fields = init_fields()” function returns an object containing “your field”, you should be able to use something like this:
var link = $(fields[“AgreementParent”]).find(“a:last”).attr(“href”);
Thanks for the guidance. The above code did give me the url I was looking for. Still not sure why the original attempt gave me a blank alert box.
Now I need to grab the “ID” in this query and pass it.
James
Hi,
I would like to have the Sharepoint:SaveButton on the New form after click display a new page as a popup, perhaps using OpenPopUpPage(), instead of the standard return to the default list view. I’m using the new page as “Thank You” page for form submission, unless if there’s a better user friendly way to display a Thank You message while still saving the new form and returning back to the root site.
Thanks,
Andy
Take a look a this one: https://spjsblog.com/2011/04/23/redirect-from-newform-to-dispform-or-editform/
Unfortunately, this is a bit tricky in SP 2013 – read the comments below the article for a possible workaround.
Alexander
Hi,
This is a great tool – thank you for developing it.
The only issue i am having is with the NewForm.aspx. When the form loads the addition information does not appear under the dropdown box. However, as soon as i change the selection within the dropdown the additional information is displayed.
I have tried this in both IE and Chrome.
Has anyone else experienced this?
Hi,
Which solution is it you refer to? – if possible, use the forum to post your question.
Alexander