Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I got "Type is undefined" and "SP is undefined" message when I try to open the list form in sharepoint modal dialog. Could anyone help me to resolve this issue?

This is the code:

<script type="text/javascript" language="javascript" src="/_layouts/SPP.ContentDesigner/Scripts/SP.UI.Dialog.js"></script>     
<script type="text/javascript">

     //Handle the DialogCallback callback 
          function DialogCallback(dialogResult, returnValue){ 

 //Open the Dialog 
          function OpenEditDialog(id) {
       var options = { 
         width: 700, 
         height: 700, 
         dialogReturnValueCallback: DialogCallback 
share|improve this question
In which context this js code run? web part page, or application page, or other? –  Kai Dec 21 '11 at 17:37
refer answer from this, it may be helpful. –  Kai Dec 21 '11 at 17:43
i got this error in sharepoint application page, my actual requirement is it should work on all type of pages(webpart page, application page, publishing page). could you guide me please? –  Rasu Dec 22 '11 at 6:09
Hm, it works on application page for me, why do you include this script - src="/_layouts/SPP.ContentDesigner/Scripts/SP.UI.Dialog.js"? Try to rename it, may be some conflicts with standard file occure. –  Kai Dec 22 '11 at 8:23
if i comment this line itself i got the same issue, do you have any idea? –  Rasu Dec 22 '11 at 14:10
add comment

3 Answers

SP.js uses "lazy load". Invoke your function inside ExecuteOrDelayUntilScriptLoaded:

ExecuteOrDelayUntilScriptLoaded(OpenEditDialog, "SP.js")
share|improve this answer
add comment

I battled with this for a good while - in my case changing "LoadAfterUI" attribute in the ScriptLink to "true" fixed it where nothing else worked.

share|improve this answer
As you can see in the question, the scripts are not loaded with the ScriptLink control, so this does not really apply –  Robert Lindgren May 17 '13 at 13:15
add comment

You can fix this issue by using a generic object for option instead of the DialogOptions class. that mean you have to write option like this:

//Using a generic object.
var options = {
    title: "My Dialog Title",
    width: 400,
    height: 600,
    url: "/_layouts/DialogPage.aspx" };

for more information about using it, visit: http://msdn.microsoft.com/en-us/library/ff410058%28v=office.14%29.aspx and see the example.

share|improve this answer
The code above is already using a generic object... The issue is that the code after (SP.UI.ModalDialog.showModalDialog) is executed before SP.js is loaded –  Robert Lindgren Nov 12 '13 at 16:34
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.