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 want to have the initiation form inside a modal popup. Here's what I've figured out so far:

To open the form insisde a modal dialog, I've included this inside the "Navigatate to Url" in the custom action.

javascript:function openDialog() {  
    var options = { 
    url: "http://<server>/srd/Workflows/wf_lobEnd/wf_lobEnd.aspx",
    width: 800,
    height: 600,
    title: "User Story"
    };
    SP.UI.ModalDialog.showModalDialog(options);
}
openDialog();

This works fine. Question is how to modify the wf_lobend.aspx form so that the popup closes, and the initiation form get submitted.

This is the javascript that gets generated for me behind the ok buttun of the initiation form:

            <input type="button" value="Start" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent(concat('__insert;__commit;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}" />

That is a bit cryptic to me, so I'm not sure what to replace. I know that I must use something like this to get the dialog closed, but that does not seem to submit the form:

onclick="SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, 'Ok clicked'); return false;"

Question is: How to close the dialog and still post the data?

(or maybe I've take the complete wrong approach, in case please let me know)

Regards

Larsi

Larsi

share|improve this question
add comment

1 Answer 1

I have done something similar, starting a workflow from a modal dialog. The form that i used does not have any fields, but it still posts back and starts the workflow.

http://djeeg.blogspot.com/2010/11/sharepoint-designer-custom-action-in.html

The code i used to open the dialog is this

SP.UI.ModalDialog.showModalDialog({
    url:"{SiteUrl}/_layouts/Com.CodePlex.SPC3/StartWorkflow.aspx?List={ListId}&ItemID={SelectedItemId}&Workflow=WorkflowName",
    dialogReturnValueCallback: function(dialogResult, returnValue) { 
        SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK) 
    }
})

Try adding the dialogReturnValueCallback property to the open dialog options. I did not have to modify any of the automatically generated dialog button javascript.

EDIT

Though looking at the page source i did have to do something extra to get it to redirect

http://spc3.codeplex.com/SourceControl/changeset/view/55971#985217

if (Request["IsDlg"] == "1") {
    Context.Response.Write("<script type='text/javascript'>window.frameElement.commitPopup();</script>");
    Context.Response.Flush();
    Context.Response.End();
} else {
    SPUtility.Redirect(list.DefaultViewUrl, SPRedirectFlags.UseSource, Context);
}
share|improve this answer
    
Hi! Thanks for the feedback. But I still don't understand how to get the data posted? If I use the default implementation, I get a error saying "The data source control failed to execute the insert command". The script the gets exceuted is the same: javascript: __doPostBack('ctl00$PlaceHolderMain$InitiationForm$ctl01','__insert;__commit;__redir‌​ectsource;__redirectToList={{2ff87457-1767-4402-b04f-a28d841b40be}};') Any idea what causing this? –  Larsi Jan 11 '11 at 11:14
    
In your form wf_lobEnd.aspx, how are you creating the Save button? My forms looks like this <input type="submit" class="ms-ButtonHeightWidth" id="ctl00_PlaceHolderMain_ButtonOk" value="Ok" name="ctl00$PlaceHolderMain$ButtonOk"> –  djeeg Jan 11 '11 at 12:12
    
Save button is created with xslt using this magic code: <input type="button" value="Start" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent(concat('__insert;__commit;__redirectsource;__redirectToLis‌​t={',ddwrt:EcmaScriptEncode($ListName),'};'))}" /> –  Larsi Jan 11 '11 at 14:35
    
Did you create the page wf_lobEnd.aspx or was it generated from something? What webparts are on it? Or is it an InfoPath form? –  djeeg Jan 11 '11 at 14:53
    
It's generated from SD Sharepoint WF designer. It has a DataFormWebPart on it. –  Larsi Jan 13 '11 at 7:51
show 1 more 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.