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'd like to create a task with a pre-filled title, as well as set some other properties. I found this documentation that says I can pass arguments when i call

SP.UI.ModalDialog.showModalDialog(options);

http://msdn.microsoft.com/en-us/library/ff410058.aspx

This is what I have so far:

<script type="text/javascript">
    var modalDialog;
    function ShowActionItemDialog(title, questionId) {
        var options = {
            url: '/Lists/Tasks/NewForm.aspx',
            title: questionId + ': ' + title,
            questionId: questionId,
            allowMaximize: false,
            showClose: false,
            width: 800,
            args: {
                title: title,
                questionId: questionId
            },
            height: 600
        };
        modalDialog = SP.UI.ModalDialog.showModalDialog(options);
    };
</script>

I have not been able to find any documentation for what args are supported. I would accept either an answer showing me how to find this information, or providing a better alternative for passing this information to the dialog. I need to invoke the dialog when a radio button is clicked, so I believe I need to do this with javascript.

Thank you!

Edit: The code from the link in the accepted answer works, but you'll need to make sure the client OM js is completely loaded

I added this code to NewForm.aspx in Sharepoint Designer:

<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(procAuditArgs, "sp.js");

function procAuditArgs(){
    var args = SP.UI.ModalDialog.get_childDialog().get_args();
}
</script>
share|improve this question
add comment

2 Answers 2

up vote 7 down vote accepted

This link might help you out:

http://www.chaholl.com/archive/2010/11/17/using-the-dialog-framework-in-sharepoint-2010.aspx

So according to this, you will have to do:

var args = SP.UI.ModalDialog.get_childDialog().get_args();

on the NewForm.aspx page to access the values passed on that page.

share|improve this answer
    
Thanks! I edited my NewForm.aspx in SharePoint Designer. This part wasn't in the link, but I had to add some code to wait for the Client OM to fully load: See edit to the original post. –  samspot Mar 19 '12 at 19:19
add comment

I believe SP.UI.ModalDialog.get_childDialog().get_args() works within the page opened in dialog only when this page is SharePoint-based, i.e. the page includes the all necessary SP js-files. So, I prefer using window.frameElement.dialogArgs to get access to the passed parameters. It works on whatever page you open in dialog. Some additional details are in my brief blog post here - How to pass parameters into a Modal Dialog Window and then access them.

share|improve this answer
3  
A word of notice from the moderator :-) When you include links to your own blog in your answers, please remembe to mention that it is your blog so that there is no confusion. Also read the faq especially about declaration and self promotion. Fix this and you are all good, thanx ;) –  Anders Rask Aug 27 '12 at 9:15
add comment

Your Answer

 
discard

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.