0

I want to have two separate buttons in SharePoint 2013 Custom List Form. One is Save As Draft and the other is Submit. I have a choice field with column name Status with values Draft, Submitted, Approved, Rejected. The draft should only be seen by Creator.

<td class="ms-toolbar" nowrap="nowrap">
    <SharePoint:SaveButton runat="server" ControlMode="New" id="savebutton3" Text="Save As Draft"/>
</td>
<td class="ms-toolbar" nowrap="nowrap">
    <SharePoint:SaveButton runat="server" ControlMode="New" id="savebutton1"/>
</td>

How can I set values of status column based on button click like if I clicked Save As Draft status should be Draft and when Clicked on Submit value of status column should be submitted?

2 Answers 2

1
  • Set "Submitted" as default value of "Status" field
  • Paste

    <td> <input name="saveAsDraft" type="button" value="Save as draft" onclick="saveAsDraft();"/> </td>

    instead of

    <td class="ms-toolbar" nowrap="nowrap"> <SharePoint:SaveButton runat="server" ControlMode="New" id="savebutton3" Text="Save As Draft"/> </td>

  • Write JS function "saveAsDraft()". Code:

    function saveAsDraft(){ var t = $("select[title='Status']"); t.val('Draft'); $("input[value='Save']").click(); }

  • Place JS script on the page

0
  1. Add two buttons into your list form
  2. Add js file into form
  3. Trigger the Workflow to assign permission based on the dropdown value

HTML Example

<td>
    <input name="saveAsDraft" type="button" value="Save as draft" id="SaveAsDraft();"/>
</td>
<td>
    <input name="Submit Data" type="button" value="Submit Data" id="SubmitData();"/>
</td>

JS File Example

$(document).ready(function (){  
    $('#SaveAsDraft').click(function (){
        $('#dropdown option').val('SaveAsDraft');
        PreSaveUpdates();
    });
    $('#SubmitData').click(function (){
        $('#dropdown option').val('Submitted');
        PreSaveUpdates();
    });
});
function PreSaveUpdates(){
    return true;
}

Note: If you are using "$(document).ready" in your code, make sure PreSaveAction function is written outside this block, as in above code or else PreSaveAction method will not be called.

Workflow Steps:

  1. Trigger the WF when an item created and modified
  2. Based on the dropdown value check the condition
  3. Assign Item level permission to created by user, if the dropdown value is "Draft".

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.