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 
  • In which context this js code run? web part page, or application page, or other? Commented Dec 21, 2011 at 17:37
  • refer answer from this, it may be helpful. Commented Dec 21, 2011 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
    Commented Dec 22, 2011 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. Commented Dec 22, 2011 at 8:23
  • if i comment this line itself i got the same issue, do you have any idea?
    – Rasu
    Commented Dec 22, 2011 at 14:10

4 Answers 4


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

ExecuteOrDelayUntilScriptLoaded(OpenEditDialog, "SP.js")

I suggest get rid of the first script reference...

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

...and load the scripts by page or master page server controls. Then control the error situation in your component code like http://microsoft-techies.blogspot.com/2014/05/script5007-unable-to-get-property.html.

Code sample:

try {
catch (error) {
    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
  • this approach is more promising.
    – Shawn
    Commented Sep 24, 2014 at 5:54

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.

  • 1
    As you can see in the question, the scripts are not loaded with the ScriptLink control, so this does not really apply Commented May 17, 2013 at 13:15

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.

  • 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 Commented Nov 12, 2013 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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