General tips

Insert webpart on NewForm, DispForm or EditForm in SP 2007:

Add “toolpaneview=2” behind the URL in this format:

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.

Find List Guid or view Guid:

In the list view – right click and view source. Then search for “ctx.Listname”.
The Guid looks like this:

The view Guid is found by searching for “ctx.view” and looks similar to the list Guid above.

Find FieldInternalName:

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"

The fields InternamName never changes and is therefore the safest method of identifying a field.

Find the “BaseUrl” of a website:

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

How to use the code examples in a customized form:

How to use these scripts in a customized form

34 thoughts on “General tips”

  1. 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?

    1. Hi,
      To remove the “Edit page” option for NewForm. DispForm and EditForm, just include this line in the code (requires jQuery):



      1. 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!

      2. Hi,
        You must wrap this in a script tag like this:

        <script src=""></script>


    1. 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.


  2. 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.

  3. 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)??

  4. 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

    Jack Schaufele

  5. 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 🙂

  6. 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() {
    fields = init_fields_v2();

    // Get Values
    var NewTitle = getFieldValue(‘Title’,false);

    // Test Values

    1. 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”

      1. 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.

  7. 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

    1. 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”.

      <script type="text/javascript" src="/Scripts/jquery-1.10.2.min.js"></script>
      <script type="text/javascript">
      $("#ctl00_MSO_ContentDiv").find("tbody:first >tr").each(function(i,tr){	
      	$(tr).append("<td class='s4-wpcell-plain' valign='top' id='myPlaceholder_"+i+"'></td>");

      Have a nice Christmas,


  8. Hi Alexander,

    Is there a way to hide the Approval Status field on the display form (DispForm.aspx) for lists that require content approval?


  9. 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..

      1. 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..

  10. 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)

  11. 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


    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?

    1. 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”);

  12. 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.


  13. 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.


  14. 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?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.